[gdal-dev] Getting SRID from MS SQL Server Spatial Table

Bob Cave bobc at bluemarblegeo.com
Thu Nov 14 11:44:26 PST 2013


Hi Tamas,

It looks like I misunderstood what you were saying.  Thank you for the
clarification.

Cheers,

Bob


Tamas Szekeres wrote
> Bob,
> 
> I did not mention to use exactly the same select, just a similar effect
> when reading the geometries.
> In
> ogrmssqlspatiallayer.cpp<http://trac.osgeo.org/gdal/browser/trunk/gdal/ogr/ogrsf_frmts/mssqlspatial/ogrmssqlspatiallayer.cpp>see
> the function
> OGRMSSQLSpatialLayer::GetNextRawFeature()
> 
> nSRSId = oParser.GetSRSId();
> 
> and then:
> 
> if ( GetSpatialRef() )
>    poGeom->assignSpatialReference( poSRS );
> 
> 
> Best regards,
> 
> Tamas
> 
> 
> 
> 2013/11/14 Bob Cave <

> bobc@

> >
> 
>> Hi Tamas,
>>
>> I looked through the source code for the MS SQL Server Spatial driver,
>> version 1.10.1 and in the latest trunk download, and was unable to find
>> that
>> query.  Is that something that you have added but not checked in yet?
>>
>> In any case, I will give try that query myself.  Thanks.
>>
>> Cheers,
>>
>> Bob
>>
>>
>> Tamas Szekeres wrote
>> > The driver is doing something like:
>> >
>> > select top 1 ogr_geometry.STSrid from [mytable]
>> >
>> > Best regards,
>> >
>> > Tamas
>> >
>> >
>> >
>> > 2013/11/13 Bob Cave <
>>
>> > bobc@
>>
>> > >
>> >
>> >> Tamas,
>> >>
>> >> Thank you for the quick reply.
>> >>
>> >> My code is reading a table, so I am trying to identify the SRID that
>> was
>> >> used when the table was created and the geometries were added to the
>> >> table.
>> >> How do I query the SRID from the geometry in the table?  The MS SQL
>> >> Server
>> >> driver does this when it is reading the geometry_columns table, but
>> when
>> >> the
>> >> driver is not using the geometry_columns table, it does not attempt to
>> >> identify the SRID. I am trying to determine how I can do this myself.
>> >>
>> >> Thanks,
>> >>
>> >> Bob
>> >>
>> >>
>> >> Tamas Szekeres wrote
>> >> > Bob,
>> >> >
>> >> > You should specify the SRID as the attribute in the geometries in
>> the
>> >> > database table, which should also set the spatial reference of the
>> >> layer.
>> >> >
>> >> > Best regards,
>> >> >
>> >> > Tamas
>> >> >
>> >> >
>> >> >
>> >> > 2013/11/13 Bob Cave <
>> >>
>> >> > bobc@
>> >>
>> >> > >
>> >> >
>> >> >> Hello,
>> >> >>
>> >> >> I am using the MS SQL Server driver (1.10.1) with
>> >> >> MSSQLSPATIAL_USE_GEOMETRY_COLUMNS=NO.  When I attempt to read a
>> table,
>> >> I
>> >> >> find that the driver does not identify the spatial reference the
>> table
>> >> is
>> >> >> using.  Is there a way to get the driver to query for the SRID?
>> >> >>
>> >> >> When I use MSSQLSPATIAL_USE_GEOMETRY_COLUMNS=YES, then the SRID can
>> be
>> >> >> identified.  This is fine for my test database, but I need to be
>> able
>> >> to
>> >> >> support databases that don't have a geometry_columns table.
>> >> >>
>> >> >> Thanks,
>> >> >>
>> >> >> Bob
>> >> >>
>> >> >>
>> >> >>
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://osgeo-org.1560.x6.nabble.com/Getting-SRID-from-MS-SQL-Server-Spatial-Table-tp5089019.html
>> >> >> Sent from the GDAL - Dev mailing list archive at Nabble.com.
>> >> >> _______________________________________________
>> >> >> gdal-dev mailing list
>> >> >>
>> >>
>> >> > gdal-dev at .osgeo
>> >>
>> >> >> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>> >> >>
>> >> >
>> >> > _______________________________________________
>> >> > gdal-dev mailing list
>> >>
>> >> > gdal-dev at .osgeo
>> >>
>> >> > http://lists.osgeo.org/mailman/listinfo/gdal-dev
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://osgeo-org.1560.x6.nabble.com/Getting-SRID-from-MS-SQL-Server-Spatial-Table-tp5089019p5089033.html
>> >> Sent from the GDAL - Dev mailing list archive at Nabble.com.
>> >> _______________________________________________
>> >> gdal-dev mailing list
>> >>
>>
>> > gdal-dev at .osgeo
>>
>> >> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>> >>
>> >
>> > _______________________________________________
>> > gdal-dev mailing list
>>
>> > gdal-dev at .osgeo
>>
>> > http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://osgeo-org.1560.x6.nabble.com/Getting-SRID-from-MS-SQL-Server-Spatial-Table-tp5089019p5089183.html
>> Sent from the GDAL - Dev mailing list archive at Nabble.com.
>> _______________________________________________
>> gdal-dev mailing list
>> 

> gdal-dev at .osgeo

>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
> 
> _______________________________________________
> gdal-dev mailing list

> gdal-dev at .osgeo

> http://lists.osgeo.org/mailman/listinfo/gdal-dev





--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Getting-SRID-from-MS-SQL-Server-Spatial-Table-tp5089019p5089210.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.


More information about the gdal-dev mailing list