[fdo-users] RE: RE: RE: Defining SpatialContext - how and when?

Maksim Sestic max at geoinova.com
Mon Jul 9 11:57:55 EDT 2007


Gavin, thanks so much for the clarification, I gathered it myself that there
must be some catch with MS SQL provider 3.1 itself (see my previous post)
:-) Good thing is that spatial context I need to conform with doesn't really
lie between 0,0 and 7000000,7000000, it's physical envelope is actually way
smaller. I will try with actual projected CS envelope and precision of
0.0001 (GPS-measured one), and post the results back.

With kindest regards,
Maksim Sestic


Gavin Cramer wrote:
> 
> Ah, yes, this was with SQL Server.  Sorry about that.
> 
> I believe that you have come across a defect in SQL Server Provider 3.1.
> Actually, it could be two defects at once (a spatial indexing
> limitation, and a wrong error message).  They were fixed in 3.2.x (for
> the 2008 versions of Map and MapGuide).  There is a workaround.
> 
> One problem is that the wrong message is issued (it's off by one entry
> if you peek at the catalogue).  The correct message is:
> 
> "Geometric value is outside of spatial index extents"
> 
> This could come from two sources, one of which is the second defect:
> 
> 1. You might really have some geometry value that is outside of the
> extents.
> 
> 2. You might have hit a problem in the FDO provider with spatial
> indexing using large extents and small XY tolerance.  The error message
> would be either what you have seen, or a generic bad parameter
> exception.  There is a workaround.
> 
> Looking at your extents and tolerance, you might encounter issue #2
> eventually, even if it is not the cause of your current problem.  The
> basically, the spatial index internally has a 32-bit precision, which is
> plenty for a real-world data in GIS with a reasonably well-chosen
> extent.  However, the internal check was incorrect, and some
> calculations can go wrong if you specify a too-small XY tolerance.  The
> spatial index's precision is the main use for the spatial context's XY
> tolerance in SQL Server Provider 3.1.
> 
> The calculation of the smallest usable tolerance is simple:  "largest
> extent" / (2^31 - 1).
> 
> Yes, that's 31, not 32, in that calculation.  That's just being
> defensive to avoid boundary cases.  Anyway, your extent is 7000000, so
> your smallest tolerance should be about 0.00326.
> 
> Gavin
> 
> 
> 
> 
> -----Original Message-----
> From: fdo-users-bounces at lists.osgeo.org
> [mailto:fdo-users-bounces at lists.osgeo.org] On Behalf Of Maksim Sestic
> Sent: Monday, July 09, 2007 5:50 AM
> To: fdo-users at lists.osgeo.org
> Subject: [fdo-users] RE: RE: Defining SpatialContext - how and when?
> 
> 
> Huh, funny thing but "Autodesk.SqlServer.3.1" provider connection
> capabilities on SpatialContext report following:
> 
> - SupportsCSysWKTFromCSysName: False
> - SupportsMultipleSpatialContexts: True
> 
> I guess I still need to set spatial context WKT by hand and this setting
> shouldn't affect geometries that will get inserted during next stage.
> 
> Anyway, I tried three different approaches and all of them failed,
> raising
> "Error
> creating spatial context (null) (SRID=486518961), the WKT provided does
> not
> match the catalog." exception:
> 
> 1) create DataStore, then insert new SpatialContext (with WKT string
> defined
> by hand) and associate schema class geometric properties with newly
> created
> CS (using SpatialContextAssociation).
> 
> 2) create DataStore, then insert new SpatialContext (without WKT string)
> and
> associate schema class geometric properties with newly created CS (using
> SpatialContextAssociation).
> 
> 3) create DataStore, then delete "Default" spatial context and create a
> new
> "Default" one with different precision and envelope (but without WKT
> string,
> as in it's original settings). Geometric properties, when instantiated
> within schema class, are set to "Default" CS by default so I don't need
> to
> manually set them.
> 
> The other solution is to convert any MGI coordinate to WGS84 and let
> them
> into the datastore using "Default" CS, but this is actually not a good
> one
> since certain coordinate conversions are "one way only" when talking
> about
> precision. My datastore is supposed to keep GPS-measured coordinates
> precise
> to a few millimeters, while coordinate conversion roundtrip (MGI ->
> WGS84 ->
> MGI) involves overall imprecision measured in meters :-) 
> 
> Regards,
> Maksim Sestic
> 
> 
> 
> Gavin Cramer wrote:
>> 
>> Ah, yes, the WKT...
>> 
>> WKT only needs to be manually set (using
>> FdoICreateSpatialContext::SetCoordinateSystemWkt() for FDO providers
> that
>> cannot generate WKT.  This is the case for most providers (because
> their
>> underlying datastores don't have native coordinate system support).
>> 
>> For those that do natively support coordinate systems (like Oracle),
> the
>> provider may also verify that the coordinate system name and WKT are
> in
>> the datastore's catalogue.  It's generally just a blind string
> comparison,
>> so minor variations may cause a failure in WKT.  To avoid this, just
> omit
>> setting the WKT attribute.
>> 
>> There is an FDO capability to let you know whether WKT generation is
>> supported:  FdoIConnectionCapabilities::
> SupportsCSysWKTFromCSysName().
>> 
>> By the way, while your code for creating a LineString will work, the
>> FdoIDirectPosition type is not yet a pooled object, and will result in
> a
>> lot of heap activity.  I recommend looking at the other constructors
> that
>> are more efficient if you plan to use a lot of features.  For example,
>> there is one that takes an array of ordinates.  There are accessors
> that
>> tend to be much faster as well.  For example, GetItemByMembers() is
> the
>> fastest one that does all the ordinate reading for you, and
> GetOrdinates()
>> is the fastest if you want a raw ordinate array.
>> 
>> Gavin
>> 
>> 
>> 
>> 
>> -----Original Message-----
>> From:	fdo-users-bounces at lists.osgeo.org on behalf of Maksim Sestic
>> Sent:	Sat 07-Jul-07 10:28 AM
>> To:	fdo-users at lists.osgeo.org
>> Cc:	
>> Subject:	[fdo-users] RE: Defining SpatialContext - how and when?
>> 
>> 
>> Dear Gavin,
>> 
>> Thanks for the tip. It's still bugging me. Here's what I'm doing:
>> 
>> 1) create new DataStore named "GIS"
>> 
>> 2) create SpatialContext named "MGI" using following parameters:
>> - Name: MGI
>> - Description: MGI
>> - Coordinate System: MGI / Balkans zone 6
>> - Coordinate System WKT: PROJCS["MGI / Balkans zone 
>>
> 6",GEOGCS["MGI",DATUM["Militar_Geographische_Institute",SPHEROID["Bessel
> 
>>
> 1841",6377397.155,299.1528128]],PRIMEM["Greenwich",0.000000],UNIT["Decim
> al 
>>
> Degree",0.01745329251994330]],PROJECTION["Transverse_Mercator"],PARAMETE
> R["Centr
>>
> al_Meridian",18],PARAMETER["Scale_Factor",0.9999],PARAMETER["False_Easti
> ng",6500
>>
> 000.000000],PARAMETER["False_Northing",0.000000],UNIT["Meter",1.00000000
> 0000]]
>> - XY Tolerance: 0.0001
>> - Z Tolerance: 0.0001
>> - Extents Type: SpatialContextExtentType_Static
>> - Extents range from 0,0 to 7000000,7000000
>> 
>> 3) create schema "TESTSCHEMA" containing one class "TESTCLASS" with
>> GeometryValue defined as:
>> geomProperty.GeometryTypes = 7
>> geomProperty.SpatialContextAssociation = "MGI"
>> 
>> -------------
>> 
>> Still, when I try to issue an Insert on some geometry ti throws "Error
>> creating spatial context (null) (SRID=486518961), the WKT provided
> does
>> not
>> match the catalog." again.
>> 
>> Here's the geometry definition (sitting within specified spatial
> context
>> extents):
>> 
>> Dim insertCommand As IInsert =
>>
> CType(m_Transaction.Connection.CreateCommand(CommandType.CommandType_Ins
> ert),
>> IInsert)
>> insertCommand.SetFeatureClassName("TESTSCHEMA:TESTCLASS")
>> 
>> Dim factory As AgfGeometryFactory = New AgfGeometryFactory()
>> Dim pcollection As DirectPositionCollection = New
>> DirectPositionCollection()
>> pcollection.Add(factory.CreatePositionXY(6500001, 4950001))
>> pcollection.Add(factory.CreatePositionXY(6534554.445, 4958445.342))
>> 
>> Dim line As ILineString = factory.CreateLineString(pcollection)
>> Dim geometryValue As GeometryValue = New
>> GeometryValue(factory.GetAgf(line))
>> insertCommand.PropertyValues.Add(New PropertyValue("geometry",
>> geometryValue))
>> insertCommand.Execute()
>> 
>> ---------------------------
>> 
>> Regards,
>> Maksim Sestic
>> 
>> 
>> 
>> 
>> Gavin Cramer wrote:
>>> 
>>> Hello, Maksim.  The "active" spatial context is a bit of a stale
> idea,
>>> and might become deprecated.  Any provider that currently cares about
> it
>>> actually sets it internally, based on the relevant geometric
> property's
>>> spatial context association.
>>> 
>>> The association can be set when creating a schema definition via
>>> FdoGeometricPropertyDefinition:: SetSpatialContextAssociation().
>>> 
>>> Gavin
>>> 
>>> 
>>> -----Original Message-----
>>> From: fdo-users-bounces at lists.osgeo.org
>>> [mailto:fdo-users-bounces at lists.osgeo.org] On Behalf Of Maksim Sestic
>>> Sent: Saturday, July 07, 2007 8:50 AM
>>> To: fdo-users at lists.osgeo.org
>>> Subject: [fdo-users] Defining SpatialContext - how and when?
>>> 
>>> 
>>> Autodesk Map 3D 2007 / MS SQL Server 2005
>>> 
>>> I have problems inserting a new GeometryValue due to the "Default"
>>> SpatialContext settings. "Default" SpatialContext has an envelope
>>> (extents)
>>> ranging from -2000000,-2000000 to 2000000,2000000, while my geometry
>>> lies
>>> way beyond default settings. Due to that fact, I keep receiving
>>> following
>>> error: "Error creating spatial context (null) (SRID=486518961), the
> WKT
>>> provided does not match the catalog."
>>> 
>>> I tried to update Extents value on "Default" spatial context using
>>> CreateSpatialContext command but it's not working (well, at least
>>> nothing
>>> changes in dbo.f_spatialcontextgroup table). Then I resorted to
> creating
>>> a
>>> new SC.
>>> 
>>> Now, I managed to create a new SpatialContext (named "MGI") with
>>> associated
>>> WKB string, proper extents settings, etc. Alas, I can not activate it
>>> :-)
>>> ActivateSpatialContext command does not affect present spatial
> contexts
>>> within DataStore - ISpatialContextReader always returns IsActive =
> False
>>> for
>>> every SC present.
>>> 
>>> I think I'm doing something wrong here, just can't figure out exactly
>>> what... :-) At what moment do I need to create custom SpatialContext
>>> (before
>>> or after creating feature schema?), and how do I apply newly
> established
>>> SC
>>> on present schema? How do I "force" my newly inserted geometric
> values
>>> "conformant" to present SC? 
>>> 
>>> Regards,
>>> Maksim Sestic
>>> 
>>> 
>>> -- 
>>> View this message in context:
>>>
> http://www.nabble.com/Defining-SpatialContext---how-and-when--tf4040281s
>>> 18162.html#a11478212
>>> Sent from the fdo-users mailing list archive at Nabble.com.
>>> 
>>> _______________________________________________
>>> fdo-users mailing list
>>> fdo-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/fdo-users
>>> 
>>> _______________________________________________
>>> fdo-users mailing list
>>> fdo-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/fdo-users
>>> 
>>> 
>> 
>> -- 
>> View this message in context:
>>
> http://www.nabble.com/Defining-SpatialContext---how-and-when--tf4040281s
> 18162.html#a11478979
>> Sent from the fdo-users mailing list archive at Nabble.com.
>> 
>> _______________________________________________
>> fdo-users mailing list
>> fdo-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/fdo-users
>> 
>> 
>> 
>> _______________________________________________
>> fdo-users mailing list
>> fdo-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/fdo-users
>> 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Defining-SpatialContext---how-and-when--tf4040281s
> 18162.html#a11498844
> Sent from the fdo-users mailing list archive at Nabble.com.
> 
> _______________________________________________
> fdo-users mailing list
> fdo-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/fdo-users
> 
> _______________________________________________
> fdo-users mailing list
> fdo-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/fdo-users
> 
> 

-- 
View this message in context: http://www.nabble.com/Defining-SpatialContext---how-and-when--tf4040281s18162.html#a11504517
Sent from the fdo-users mailing list archive at Nabble.com.



More information about the fdo-users mailing list