I can load shape layers… normally
I can load Images …normally
but…
Loading OGR layers something is going wrong:
The following sql statement:
sql := ‘select * from “db_db”.“public”.“layera”’;
with
Lay := Map1.AddLayerFromDatabase(ConnSt,sql,true) ;
or
layer := OGR.RunQuery(sql);
Lay := Map1.AddLayer(layer, true);
loads the records but they do not show in map, actual limits are set to 0 0 0 0
But if I use:
sql := ‘select st_buffer(geom, 0.0001), * FROM “db_db”.“public”.“layera”’;
loads and displays the data, with any of the methods described
…but I do not want buffers of the vectors, but the actual vectors to be able to edit etc.
We need to divide and conquer, to figure out if the issue is with the OGR datasource, the data itself, Delphi (unlikely), or the OCX. We recently discovered a bug in the OCX related to 3D data, although that applied to disk-based Shapefiles. By the way, what is the OGR datasource?
One thing to try would be to load the layer into memory (do not yet add it to the Map) and then get the Shapefile version of the layer (using GetBuffer). Then try adding the resulting Shapefile to the map to see if it behaves any differently.
Then try saving the Shapefile to disk (using SaveAs). You can try loading it from disk, understanding that there may be issues related to load due to the bug. If you don’t mind posting the Shapefile, please do so, and I can try loading it to see what the result may be (I am currently running a version of the OCX with the bug fix, but I have not yet posted it).
Let’s start with these things and then decide where to go from there.
Hello Jerry,
On first instance I could not load? or actually display any data to MapwinGIS Map… The nature of the data is 3D, which I believe is the main issue here.
So… the only way to do it was via the function like Buffer (which was 2d) or really force the load to be 2D.
So I believe that the ocx can not load any 3d data as it is (from OGR data source or data base source via OGR). This is not happening on 3d shape files…(as far as I tried), but I am not sure that their 3d integrity remains … since I’ve not been working long enough with the ocx (but I will extensively)
I would very much like to get to the bottom of this. The OCX “should” handle the 3D (2.5D) data, so if there is a breakdown somewhere, I would like to get it resolved.
Notes:
We rely on the GDAL driver for PostGIS for data retrieval and conversion. I believe that should be a robust driver, so I don’t expect any issues there.
Can you tell me how PostGIS classifies the geometry types you are trying to load? (for example, PolylineZ, MultiPolygonZ)?
The MapWindow5 program uses this OCX, so any issues with the OCX will also be present there.
The Shapefile created by the GetBuffer command should not drop the Z values - they should still be present. Would you mind posting the Shapefile to this site? That would help me to analyze the problem. You should be able to just drag/drop it onto this post.
Although I don’t use PostGIS, I use MS SQL Server quite a bit, and I should be able to set up a test
My geometries are:
MultilineZM (Imported by the Postgis2.0 shape importer)
MultipolygonZM (Also Imported with the importer)
I can not import the OGR layer as 3d. Actually … If I ask sf.NumShapes gives correct Nr of shapes, but sf.Extents are (0.0 0.0 0.0 0.0)
If I export sf.SaveAs (‘d:\0export\export2.shp’, cB); it exports an empty shape file.
If I load the OGR as 2d with 'select ST_Force2D(geom), * FROM …etc then I get the shapefile correct (in 2d), so If I export it , I get a shapefile with Polylines only.
Probably what you need is a 3d shapefile, and import it to Postgis using the importer as I did to create a small Postgres db …and make tests from there…
I’m setting up PostGIS on my computer. One of the files you uploaded (public_11_cerca.zip) does not unzip (invalid). Is that the one I will want to import into PGis? Or will it be easy enough to import the Shapefile?
Follow-up: I found the PostGIS Shapefile Importer, but it is failing to import 100cerca.shp. Any special settings or something I should know?
Ok, so I can duplicate the error. I tried both the 100cerca and the camino tables in PostGIS (imported from shapefiles). When I open them as OgrLayers in MapWinGIS, I get a ShapeType of SHP_NULLSHAPE. So next I will have to debug into the code to determine if the breakdown is in GDAL or in MapWinGIS.
I’ll let you know what I find.
My feeling is that it is not a problem with 3D, but with the MultiLineString type. Are the geometies acually multipart-linestrings, or are they all actually single-part polylines? Could they be converted to single-part polylines?
Regards.
EDIT: I also tried importing with the Option “Generate simple geometries instead of MULTI geometries” and the problem still exists.
The OCX is prepared for well-known Shape Types such as wkbLineString, and wkbLineString25D (which would contain Z-values), but it is not coded to accept wkbLineStringZM, which is what is being returned by PostGIS (and likely returned by many other OGR Data sources).
So as a test, when the code was checking for shape type wkbLineString25D, I added a check also for wkbLineStringZM, and it successfully loaded the Shapefile as a POLYGONZ shape type.
Here’s a quick look in the immediate window of the Shape(0), and Point(0) of Shape(0). You can see that we have a POLYGONZ layer that includes Z-values.
So, my current interpretation is that the OCX has not kept up with the various Shape types that can be returned from an OGR datasource. That may or may not be true.
Moving forward from here, I think we need to review the various Shape types that may be returned and make sure that we properly interpret and unpack them. It may well be that some of them cannot currently be supported, but I suspect that some of them can - we just have to code for them.
LinestringZM is a really old data structure … as far as I remember
I do not know why the importer converts elements to ZM. Originally the elements where linestring25D as you mentioned. Anyway, in the mean time it would be good thing to publish the ocx that handles this check.
On the other hand (subject form other conversation) I hope the issue of the ecw images get solved as well.
I have submitted Jira ticket MWGIS-218, which I consider the first phase implementation of compliance with ISO SQL/MM Part 3 geometry types (inasmuch as can be complied within a Shapefile).
If you are able to get the latest ‘develop’ branch and build, please do so. If you are not able to, let us know and I will see if we can make an interim build available.