This project has moved. For the latest updates, please go here.


Topics: Algorithms
May 18, 2007 at 9:43 AM
Edited May 18, 2007 at 9:44 AM
Hi, I could not understand how GeometryTransform.TransformGeometry method works. Is it possible to get somewhere more detailed description about it? I am just trying to transform some geometry in the shapefile but without results, see the code below. Actually I need e. g. to change the location of the geometry on the map. Some ideas
Sharp.Data.Providers.GeometryProvider ds = null;
myTransform transf = new myTransform(); //iMathTransform class
Geometry geo;
ShapeFile shapeFile = new ShapeFile(@"pathtoshapefile");
FeatureDataRow feature;
geo = shapeFile.GetGeometryByID(5); //It is polygon
ds = new GeometryProvider(geo);
geo = GeometryTransform.TransformGeometry(geo, transf);
SharpMap.Layers.VectorLayer laytest = new SharpMap.Layers.VectorLayer("test");
laytest.DataSource = ds;
May 18, 2007 at 7:52 PM
Hehe I love these types of errors. You might want to look into object references, since I think you got this all wrong:
geo = GeometryTransform.TransformGeometry(geo, transf);
TransformGeometry returns a new instance of a geometry, thus the returned geometry is no longer a reference to the geometry stored in the geometryprovider. Try adding to the geometryprovider later instead:
geo = shapeFile.GetGeometryByID(5);
geo = GeometryTransform.TransformGeometry(geo, transf);
ds = new GeometryProvider(geo);

Alternatively, why not just apply a transformation to the vectorlayer instead?
May 18, 2007 at 8:35 PM
Thanks for your reply Odeqaard. I have tried to add to the geometryprovider later, no results. I have no idea how to give required transformation parameters to myTransform (no description). It would be nice to perform vectorlayer transformation but not coordinate system transformation. It should be like: extend or suspend layer, change location of the polygon. Maybe there are some where examples?