Unable to select a shape from shapefile of shpType.POLYGONZ using the Shapefile.SelectShapes method

Apr 4, 2013 at 9:26 AM
Hi,

I have the exact same problem with summi in this post:

http://www.mapwindow.org/phorum/read.php?3,13766,13784

I have tried to extend the Extent using maximum range for the Z coordinat:
ShapeExtents.SetBounds(X1, Y1, Double.MinValue, X1, Y1, Double.MaxValue);
But it's still not working...

Is there a solution without have to convert the polygon to 2D?
The requirement is only to select the polygon on mouse click.

Anyway, sample code for collapsing 3D polygons down to 2D will be appreciated also.

Thanks!
Coordinator
Apr 5, 2013 at 7:51 AM
In the toolbox you have a tool to convert 3d shapes to 2d shapes. You can have a look at its source code.
It is available at http://svn.mapwindow.org/svnroot/MapWindow4Dev/GISTools/Forms/Vector/frm3Dto2D.vb

Can you send me a sample shapefile so I can try to reproduce?
bontepaarden[at]gmail[D0T]com

Paul
Apr 5, 2013 at 10:31 AM
Hi Paul,

Thanks a lot for the reference to the converting tools source code!

I have request the 2D shapefile from my user for this purpose and now my code works perfectly.
Unfortunately I overwrite and don't have any backup of the 3D shapefile.
I will request the 3D shapefile again from my user and send it to you later... Just curious why after setting the Z coordinate to max range it's still not working.
Thinking about updating my code so it can handle 3D shape so latter when user upload new 3D shapefile there will be no problem.
I was spending 2 days tracing this problem just to find out that it has POLYGONZ format instead of POLYGON... T_T

Juky
Coordinator
May 6, 2013 at 2:14 PM
Hi Juky,

I finally have some time to look at your question.
I've received your 3D shapefile and managed to select some shapes.
I think your problem is that you don't use a rectangle as selection extent but a point.
This is my sample code. It is in C# but you'll get the idea:
     object result = null;
      testExtents.SetBounds(820348, 9828858, Double.MinValue, 822304, 9829571, Double.MaxValue);
      if (sfPolygonZ.SelectShapes(testExtents, 0.0, SelectMode.INTERSECTION, ref result))
      {
        int[] shapes = result as int[];
        for (int i = 0; i < shapes.Length; i++)
        {
          sfPolygonZ.set_ShapeSelected(shapes[i], true);
        }

        mapWin.View.Redraw();
      }
      else
      {
        testsMethods.ReportMessage("Error!No shapes selected: " + sfPolygonZ.get_ErrorMsg(sfPolygonZ.LastErrorCode));
      }