Q&A - Question

Select shapes in Postgis layers

Question
FabD asked on March 20, 2017, keyword: Developer Kernel
I'm using .NET Developer Kernel.

I've got some TGIS_LayerSqlPgisLibpq and I would like to select some shapes.
I follow the MultiSelect example, but I'm not able to select the shapes. If I set the IsSelected property to true, it became false immediately.

Example:

           TGIS_Shape shp = lv.FindFirst();
            while (shp != null)
            {
                object idobj = shp.GetField("id");
                Console.WriteLine(idobj.ToString() + " " + shp.IsSelected);
                if (someCondition)
                {
                    Console.WriteLine(sel);
                    shp.IsSelected = true;
                    shp.Invalidate();
                }
                shp = lv.FindNext();
            }

            Console.WriteLine("**** check *****");

            shp = lv.FindFirst();
            while (shp != null)
            {
                object idobj = shp.GetField("id");
                Console.WriteLine(idobj.ToString() + " " + shp.IsSelected);
                shp = lv.FindNext();
            }

With this code, in the checking part I get always IsSelected == false even if I set it to true in the first part.
In the MultiSelect example you call MakeEditable() method on the shape. In my case, if I call MakeEditable() on a shape, it disappears (maybe because it is a LayerSqlPgisLibpq layer?)
Answers
Artur Redzko (TatukGIS) replied March 14, 2017
This code should work:

shp_im = shp.MakeEditable() ;
shp_im.IsSelected = true;
shp_im.Invalidate();


calling MakeEditable() is required to keep the shape in memory and remember its changes like setting IsSelected.
FabD replied March 14, 2017
Thank you for your quick answer.
Unfortunately, as I said in the question, if I call MakeEditable() on a shape, it disappears from the map. It seems that the shape is deleted (it is no more available also in the FindFirst-FindNext loop). I don't know if this is due to the used layer ( TGIS_LayerSqlPgisLibpq ) that (I think) is not editable.
Artur Redzko (TatukGIS) replied March 14, 2017
Ok, I will check this. Please report this issue to our support.
Artur Redzko (TatukGIS) replied March 20, 2017
The sample and the code above works fine. After support session the problem was found in the Scope usage in TGIS_LayerSqlPgis class.
If you would like to answer the question please Sign In.
*
*
Please review our recent Privacy Policy.
If you have any questions or requests, please contact us.
Rules
The Questions and Answers (Q & A) is intended to provide a means of communication between TatukGIS customers.
 
  1. Licensed users (with active maintenance play) of TatukGIS products may contribute to the Q & A content. Read-only access is available to anyone.
  2. Keep the content positive and professional.
  3. Be courteous to others by posting information when a question or issue asked on the Q & A is answered or resolved by other means (such as with help from TatukGIS technical support). Offer others at least a hint how the posted question was answered or the issue was resolved.
  4. The Q & A is not a replacement for TatukGIS technical support. TatukGIS team may or may not regularly follow or contribute content.