[gdal-dev] Problem with export from GIS file to MSSQL with 3D data points

Nicolas Garel ngarel at micromine.com
Mon Jun 13 00:14:36 EDT 2011


Hi,

The export from a file (tested on .gml and .shp) to a table in MSSQL Spatial database does not work properly when the data points use 3 dimensions.

For instance, I have a file (test02.gml) with 2 LineString:

  <gml:featureMember>
    <ogr:test02 fid="F0">
      <ogr:geometryProperty><gml:LineString><gml:coordinates>114.82008919027152,-30.533088637478372,200 114.84597389066435,-30.695620477154364,200 115.11987013900723,-30.685988960729119,200 115.10361695503964,-30.554759549435168,200 115.05726528224315,-30.558973337871215,200 114.82008919027152,-30.533088637478372,200</gml:coordinates></gml:LineString></ogr:geometryProperty>
    </ogr:test02>
  </gml:featureMember>
  <gml:featureMember>
    <ogr:test02 fid="F1">
      <ogr:geometryProperty><gml:LineString><gml:coordinates>114.87649177159327,-30.506319349105187,195 114.96677069805884,-30.538409014910489,205</gml:coordinates></gml:LineString></ogr:geometryProperty>
    </ogr:test02>
  </gml:featureMember>
</ogr:FeatureCollection>

As shown above the first LineString has a constant elevation (Z component) of 200 and the second LineString as an elevation of 195 and 205. When using ogr2ogr to export the data to a MSSQL Spatial database, the Z components are written in the wrong place in the geometry column.
I used the following command line to export to MSSQL:

ogr2ogr -overwrite -f MSSQLSpatial "MSSQL:server=<my server>;database=Spatial;trusted_connection=yes" "C:\Work\test02.gml"

Then I use ogrinfo to dump the content of the table:

ogrinfo -al "MSSQL:server=mm00786\mm00786;database=Spatial;tables=dbo.test02;trusted_connection=yes"

Layer name: test02
Geometry: Unknown (any)
Feature Count: 2
Extent: (-30.695620, -30.554760) - (200.000000, 200.000000)
Layer SRS WKT:
(unknown)
FID Column = ogr_fid
Geometry Column = ogr_geometry
OGRFeature(test02):1
  LINESTRING (114.82008919027152 -30.533088637478368 114.84597389066435,-30.695620477154364 115.11987013900723 -30.685988960729119,115.10361695503964 -30.554759549435168 115.05726528224316,-30.558973337871212 114.82008919027152 -30.533088637478368,200 200 200,200 200 200)

OGRFeature(test02):2
  LINESTRING (114.87649177159328 -30.506319349105187 114.96677069805884,-30.538409014910489 195.0 205)

All the Z components are written at the end of LINESTRING and the comma delimiter is then set at the wrong spot.

Thus importing the results back to GML are obviously wrong. This scenario also happens for Polygons feature type and other input files.

I'm using GDAL 1.8.0.

Thanks.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110613/4cd5642b/attachment.html


More information about the gdal-dev mailing list