<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Windows-1252">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.0.6619.12">
<TITLE>RE: [fdo-users] RE: Defining SpatialContext - how and when?</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>Ah, yes, the WKT...<BR>
<BR>
WKT only needs to be manually set (using FdoICreateSpatialContext::SetCoordinateSystemWkt() for FDO providers that cannot generate WKT.&nbsp; This is the case for most providers (because their underlying datastores don't have native coordinate system support).<BR>
<BR>
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.&nbsp; It's generally just a blind string comparison, so minor variations may cause a failure in WKT.&nbsp; To avoid this, just omit setting the WKT attribute.<BR>
<BR>
There is an FDO capability to let you know whether WKT generation is supported:&nbsp; FdoIConnectionCapabilities:: SupportsCSysWKTFromCSysName().<BR>
<BR>
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.&nbsp; I recommend looking at the other constructors that are more efficient if you plan to use a lot of features.&nbsp; For example, there is one that takes an array of ordinates.&nbsp; There are accessors that tend to be much faster as well.&nbsp; 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.<BR>
<BR>
Gavin<BR>
<BR>
<BR>
<BR>
<BR>
-----Original Message-----<BR>
From:&nbsp;&nbsp; fdo-users-bounces@lists.osgeo.org on behalf of Maksim Sestic<BR>
Sent:&nbsp;&nbsp; Sat 07-Jul-07 10:28 AM<BR>
To:&nbsp;&nbsp;&nbsp;&nbsp; fdo-users@lists.osgeo.org<BR>
Cc:&nbsp;&nbsp;&nbsp;&nbsp;<BR>
Subject:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [fdo-users] RE: Defining SpatialContext - how and when?<BR>
<BR>
<BR>
Dear Gavin,<BR>
<BR>
Thanks for the tip. It's still bugging me. Here's what I'm doing:<BR>
<BR>
1) create new DataStore named &quot;GIS&quot;<BR>
<BR>
2) create SpatialContext named &quot;MGI&quot; using following parameters:<BR>
- Name: MGI<BR>
- Description: MGI<BR>
- Coordinate System: MGI / Balkans zone 6<BR>
- Coordinate System WKT: PROJCS[&quot;MGI / Balkans zone<BR>
6&quot;,GEOGCS[&quot;MGI&quot;,DATUM[&quot;Militar_Geographische_Institute&quot;,SPHEROID[&quot;Bessel<BR>
1841&quot;,6377397.155,299.1528128]],PRIMEM[&quot;Greenwich&quot;,0.000000],UNIT[&quot;Decimal<BR>
Degree&quot;,0.01745329251994330]],PROJECTION[&quot;Transverse_Mercator&quot;],PARAMETER[&quot;Centr<BR>
al_Meridian&quot;,18],PARAMETER[&quot;Scale_Factor&quot;,0.9999],PARAMETER[&quot;False_Easting&quot;,6500<BR>
000.000000],PARAMETER[&quot;False_Northing&quot;,0.000000],UNIT[&quot;Meter&quot;,1.000000000000]]<BR>
- XY Tolerance: 0.0001<BR>
- Z Tolerance: 0.0001<BR>
- Extents Type: SpatialContextExtentType_Static<BR>
- Extents range from 0,0 to 7000000,7000000<BR>
<BR>
3) create schema &quot;TESTSCHEMA&quot; containing one class &quot;TESTCLASS&quot; with<BR>
GeometryValue defined as:<BR>
geomProperty.GeometryTypes = 7<BR>
geomProperty.SpatialContextAssociation = &quot;MGI&quot;<BR>
<BR>
-------------<BR>
<BR>
Still, when I try to issue an Insert on some geometry ti throws &quot;Error<BR>
creating spatial context (null) (SRID=486518961), the WKT provided does not<BR>
match the catalog.&quot; again.<BR>
<BR>
Here's the geometry definition (sitting within specified spatial context<BR>
extents):<BR>
<BR>
Dim insertCommand As IInsert =<BR>
CType(m_Transaction.Connection.CreateCommand(CommandType.CommandType_Insert),<BR>
IInsert)<BR>
insertCommand.SetFeatureClassName(&quot;TESTSCHEMA:TESTCLASS&quot;)<BR>
<BR>
Dim factory As AgfGeometryFactory = New AgfGeometryFactory()<BR>
Dim pcollection As DirectPositionCollection = New DirectPositionCollection()<BR>
pcollection.Add(factory.CreatePositionXY(6500001, 4950001))<BR>
pcollection.Add(factory.CreatePositionXY(6534554.445, 4958445.342))<BR>
<BR>
Dim line As ILineString = factory.CreateLineString(pcollection)<BR>
Dim geometryValue As GeometryValue = New GeometryValue(factory.GetAgf(line))<BR>
insertCommand.PropertyValues.Add(New PropertyValue(&quot;geometry&quot;,<BR>
geometryValue))<BR>
insertCommand.Execute()<BR>
<BR>
---------------------------<BR>
<BR>
Regards,<BR>
Maksim Sestic<BR>
<BR>
<BR>
<BR>
<BR>
Gavin Cramer wrote:<BR>
&gt;<BR>
&gt; Hello, Maksim.&nbsp; The &quot;active&quot; spatial context is a bit of a stale idea,<BR>
&gt; and might become deprecated.&nbsp; Any provider that currently cares about it<BR>
&gt; actually sets it internally, based on the relevant geometric property's<BR>
&gt; spatial context association.<BR>
&gt;<BR>
&gt; The association can be set when creating a schema definition via<BR>
&gt; FdoGeometricPropertyDefinition:: SetSpatialContextAssociation().<BR>
&gt;<BR>
&gt; Gavin<BR>
&gt;<BR>
&gt;<BR>
&gt; -----Original Message-----<BR>
&gt; From: fdo-users-bounces@lists.osgeo.org<BR>
&gt; [<A HREF="mailto:fdo-users-bounces@lists.osgeo.org">mailto:fdo-users-bounces@lists.osgeo.org</A>] On Behalf Of Maksim Sestic<BR>
&gt; Sent: Saturday, July 07, 2007 8:50 AM<BR>
&gt; To: fdo-users@lists.osgeo.org<BR>
&gt; Subject: [fdo-users] Defining SpatialContext - how and when?<BR>
&gt;<BR>
&gt;<BR>
&gt; Autodesk Map 3D 2007 / MS SQL Server 2005<BR>
&gt;<BR>
&gt; I have problems inserting a new GeometryValue due to the &quot;Default&quot;<BR>
&gt; SpatialContext settings. &quot;Default&quot; SpatialContext has an envelope<BR>
&gt; (extents)<BR>
&gt; ranging from -2000000,-2000000 to 2000000,2000000, while my geometry<BR>
&gt; lies<BR>
&gt; way beyond default settings. Due to that fact, I keep receiving<BR>
&gt; following<BR>
&gt; error: &quot;Error creating spatial context (null) (SRID=486518961), the WKT<BR>
&gt; provided does not match the catalog.&quot;<BR>
&gt;<BR>
&gt; I tried to update Extents value on &quot;Default&quot; spatial context using<BR>
&gt; CreateSpatialContext command but it's not working (well, at least<BR>
&gt; nothing<BR>
&gt; changes in dbo.f_spatialcontextgroup table). Then I resorted to creating<BR>
&gt; a<BR>
&gt; new SC.<BR>
&gt;<BR>
&gt; Now, I managed to create a new SpatialContext (named &quot;MGI&quot;) with<BR>
&gt; associated<BR>
&gt; WKB string, proper extents settings, etc. Alas, I can not activate it<BR>
&gt; :-)<BR>
&gt; ActivateSpatialContext command does not affect present spatial contexts<BR>
&gt; within DataStore - ISpatialContextReader always returns IsActive = False<BR>
&gt; for<BR>
&gt; every SC present.<BR>
&gt;<BR>
&gt; I think I'm doing something wrong here, just can't figure out exactly<BR>
&gt; what... :-) At what moment do I need to create custom SpatialContext<BR>
&gt; (before<BR>
&gt; or after creating feature schema?), and how do I apply newly established<BR>
&gt; SC<BR>
&gt; on present schema? How do I &quot;force&quot; my newly inserted geometric values<BR>
&gt; &quot;conformant&quot; to present SC?<BR>
&gt;<BR>
&gt; Regards,<BR>
&gt; Maksim Sestic<BR>
&gt;<BR>
&gt;<BR>
&gt; --<BR>
&gt; View this message in context:<BR>
&gt; <A HREF="http://www.nabble.com/Defining-SpatialContext---how-and-when--tf4040281s">http://www.nabble.com/Defining-SpatialContext---how-and-when--tf4040281s</A><BR>
&gt; 18162.html#a11478212<BR>
&gt; Sent from the fdo-users mailing list archive at Nabble.com.<BR>
&gt;<BR>
&gt; _______________________________________________<BR>
&gt; fdo-users mailing list<BR>
&gt; fdo-users@lists.osgeo.org<BR>
&gt; <A HREF="http://lists.osgeo.org/mailman/listinfo/fdo-users">http://lists.osgeo.org/mailman/listinfo/fdo-users</A><BR>
&gt;<BR>
&gt; _______________________________________________<BR>
&gt; fdo-users mailing list<BR>
&gt; fdo-users@lists.osgeo.org<BR>
&gt; <A HREF="http://lists.osgeo.org/mailman/listinfo/fdo-users">http://lists.osgeo.org/mailman/listinfo/fdo-users</A><BR>
&gt;<BR>
&gt;<BR>
<BR>
--<BR>
View this message in context: <A HREF="http://www.nabble.com/Defining-SpatialContext---how-and-when--tf4040281s18162.html#a11478979">http://www.nabble.com/Defining-SpatialContext---how-and-when--tf4040281s18162.html#a11478979</A><BR>
Sent from the fdo-users mailing list archive at Nabble.com.<BR>
<BR>
_______________________________________________<BR>
fdo-users mailing list<BR>
fdo-users@lists.osgeo.org<BR>
<A HREF="http://lists.osgeo.org/mailman/listinfo/fdo-users">http://lists.osgeo.org/mailman/listinfo/fdo-users</A><BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>