[fdo-users] Set "Default" spatial context (MySQL)

Hidekazu Shimaji hshimaji at ybb.ne.jp
Sat Feb 24 08:53:40 EST 2007


It works.
Thanks a lot.

Hidekazu

--- Jack Lee <jack.lee at autodesk.com> wrote:

> Hi,
>  
> Destroy the default spatial context first and then re-created it.
>  
> 
> 	-----Original Message----- 
> 	From: fdo-users-bounces at lists.osgeo.org on behalf of Hidekazu Shimaji 
> 	Sent: Sat 2/24/2007 3:52 AM 
> 	To: FDO Users ML 
> 	Cc: 
> 	Subject: [fdo-users] Set "Default" spatial context (MySQL)
> 	
> 	
> 
> 	Hello, 
> 
> 	I want to know how to set a spatial context named "Default" to a MySQL data store. 
> 	When I set a "Default" spatial context to a data store, which had been just created by
> using 
> 	a CreateDataStore command, a folloing error occured: 
> 
> 	OSGeo.FDO.Common.Exception: Cannot create Spatial Context 'Default', it already exists
> 
> 
> 	I executed a GetSpatialContexts command, and I recognised that the "Default" spatial
> context 
> 	exactly existed, but its CoordinateSystemWkt property had nothing. 
> 
> 	I'd like to change the CoordinateSystemWkt value because all feature classes use the 
> 	"Default" spatial context.  How can I do it?  Please help me. 
> 
> 	using 
> 	FDO3.2 (MapGuide Open Source 1.1.0) 
> 	MySQL 5.0.27 
> 	WindowsXP SP2 
> 	Visual Web developer 2005 SP1 (C#) 
> 
> 	my code is folloing: 
> 
> 	---code start 
> 	//WKT 
> 	const string PROJECTED_WKT = 
> 	    "PROJCS[\"MY_CS\",\n" + 
> 	    "  GEOGCS [\"NAD 83 (Continental US)\",\n" + 
> 	    "    DATUM [\"NAD 83 (Continental US)\",\n" + 
> 	    "      SPHEROID [\"GRS 80\",6378137,298.257222101]],\n" + 
> 	    "    PRIMEM [\"Greenwich\", 0.000000],\n" + 
> 	    "    UNIT[\"Decimal Degree\",0.01745329251994330]],\n" + 
> 	    "  PROJECTION [\"Transverse Mercator\"],\n" + 
> 	    "  PARAMETER [\"Scale_Factor\",0.999600],\n" + 
> 	    "  PARAMETER [\"Central_Meridian\",\\-75.000000],\n" + 
> 	    "  PARAMETER [\"False_Easting\",500000.000000],\n" + 
> 	    "  PARAMETER [\"False_Northing\",{1}],\n" + 
> 	    "  UNIT [\"Meter\",1.000000000000]]"; 
> 	//DataStore name (just created by using a CreateDataStore command) 
> 	const string DATA_STORE = "NewDataStore"; 
> 	//craete a CreateConnection command 
> 	IConnection connection = FeatureAccessManager. 
> 	   GetConnectionManager().CreateConnection("OSGeo.MySQL.3.2"); 
> 	//set properties 
> 	IConnectionPropertyDictionary connectionDictionary = 
> 	   connection.ConnectionInfo.ConnectionProperties; 
> 	connectionDictionary.SetProperty("Service", "localhost"); 
> 	connectionDictionary.SetProperty("Username", "root"); 
> 	connectionDictionary.SetProperty("Password", "password"); 
> 	connectionDictionary.SetProperty("DataStore", DATA_STORE); 
> 
> 	//open connection 
> 	if (connection.Open() == 
> 	   OSGeo.FDO.Connections.ConnectionState.ConnectionState_Open) 
> 	{ 
> 	    //craete a CreateSpatialContext command 
> 	    ICreateSpatialContext createSpatialContext = 
> 	        (ICreateSpatialContext)connection.CreateCommand( 
> 	        OSGeo.FDO.Commands.CommandType. 
> 	        CommandType_CreateSpatialContext); 
> 	    //name 
> 	    createSpatialContext.Name ="Default"; 
> 	    //description 
> 	    createSpatialContext.Description = 
> 	        "Projected Coordinate System Test"; 
> 	    //wkt text 
> 	    createSpatialContext.CoordinateSystem = "WKT"; 
> 	    createSpatialContext.CoordinateSystemWkt = PROJECTED_WKT; 
> 	    //tolerance 
> 	    createSpatialContext.XYTolerance = 0.001; 
> 	    //range of drawing 
> 	    FgfGeometryFactory factory = new FgfGeometryFactory(); 
> 	    IEnvelope envelop = 
> 	        factory.CreateEnvelopeXY(0, 0, 1000, 1000); 
> 	    IPolygon polygon = (IPolygon)factory.CreateGeometry(envelop); 
> 	    createSpatialContext.Extent = factory.GetFgf(polygon); 
> 	    //execute the command 
> 	    createSpatialContext.Execute(); 
> 
> 	    Response.Write("default spatial context has been set." + "<br>"); 
> 
> 	    //close connection 
> 	    connection.Close(); 
> 	} 
> 	---code end 
> 
> 	Thank you in advance. 
> 	Hidekazu 
> 
> 	_______________________________________________ 
> 	fdo-users mailing list 
> 	fdo-users at lists.osgeo.org 
> 	http://lists.osgeo.org/mailman/listinfo/fdo-users 
> 
> 



More information about the fdo-users mailing list