[fdo-users] Shapefile and spatial context

Dan Stoica dan.stoica at autodesk.com
Fri Jun 11 11:15:00 EDT 2010


Hi,

> I wonder why is not a PRJ file created for each Feature Class automatically.	

The PRJ is created automatically provided that the geometry property of your feature class has been associated with a spatial context:

	geometryProp->SetSpatialContextAssociation(_spatialContext); 

Also note the provider is not creating empty PRJ files.

Dan.

-----Original Message-----
From: fdo-users-bounces at lists.osgeo.org [mailto:fdo-users-bounces at lists.osgeo.org] On Behalf Of hanko
Sent: Friday, June 11, 2010 4:00 AM
To: fdo-users at lists.osgeo.org
Subject: [fdo-users] Shapefile and spatial context


According to wikipedia:

Shapefile projection format (.prj)

The projection information contained in the .prj file is critical in order
to understand the data contained in the .shp file correctly. 
Although it is technically optional, it is most often provided, as it is not
necessarily possible to guess the projection of any given points. 
The file is stored in well-known text (WKT) format.

Some typical information contained in the .prj file is:
    * Geographic coordinate system
	-------------
I create a new spatial context
Then I create a new chema with a few Feature Classes.
I set geom.SpatialContextAssociation = newSpatialContext.Name; 

When I apply schema for every Feature Class are created a bunch of files
with the same name as Feature Class (shp, shx, idx, dbf, cpg).
I wonder why is not a PRJ file created for each Feature Class automatically.	

private void CreateSpatialContext()
{
	string wkt = "GEOGCS [ \"Longitude / Latitude (WGS 84)\", DATUM [\"WGS
84\", SPHEROID [\"WGS 84\", 6378137, 298.257223563]], PRIMEM [
\"Greenwich\", 0.000000 ], UNIT \"Decimal Degree\", 0.01745329251994330]]";

	using (ICreateSpatialContext create =
_conn.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_CreateSpatialContext)
as ICreateSpatialContext)
	{
		using (FgfGeometryFactory geomFactory = new FgfGeometryFactory())
		{
			DirectPositionImpl lowerLeft = new DirectPositionImpl();
			lowerLeft.X = -180.0;
			lowerLeft.Y = -90.0;
			DirectPositionImpl upperRight = new DirectPositionImpl();
			upperRight.X = 180.0;
			upperRight.Y = 90.0;
			create.CoordinateSystemWkt = wkt;
			//MyStream.Write(create.CoordinateSystemWkt);
			//MyStream.Close();
			create.Description = "This Coordinate System is used for GPS.";
			create.ExtentType =
SpatialContextExtentType.SpatialContextExtentType_Static;

			IEnvelope envelope = geomFactory.CreateEnvelope(lowerLeft, upperRight);
			IGeometry geom = geomFactory.CreateGeometry(envelope);
			create.Extent = geomFactory.GetFgf(geom);
			create.Name = _spatialContext;
			create.UpdateExisting = false;
			create.XYTolerance = 0.001;
			create.ZTolerance = 0.001;
			create.Execute();
			if (geom != null)
				geom.Dispose();
		}
	}	 
}

http://osgeo-org.1803224.n2.nabble.com/file/n5166854/ship.bmp 

I create a file containing the WKT text.
TextWriter MyStream = null;
string prjFile = @"C:\Temp\SHP\Ship.prj";
MyStream = File.CreateText(prjFile);
MyStream.Write(wkt);
MyStream.Close();

http://osgeo-org.1803224.n2.nabble.com/file/n5166854/ship_coord.bmp 

Cheers Hanko
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Shapefile-and-spatial-context-tp5166854p5166854.html
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


More information about the fdo-users mailing list