Please Help Me....

Topics: SharpMap Project, SharpMap v0.9 / v1.x
Jul 23, 2008 at 9:46 AM
Edited Jul 23, 2008 at 9:47 AM
SharpMap.Data.Providers.ShapeFile ShapeFile1 = new SharpMap.Data.Providers.ShapeFile("C:\\Country.shp") ;
SharpMap.Data.FeatureDataRow FeatureDataRow1 ;
string strPolygon;

SharpMap.Geometries.Point Pnt = new SharpMap.Geometries.Point(53.4,39.2);

 for (int i = 0; i < ShapeFile1.GetFeatureCount(); i++)
     FeatureDataRow1 = ShapeFile1.GetFeature((uint)i);
     if (Pnt.Within(FeatureDataRow1.Geometry))
         strPolygon = ShapeFile1.GetFeature((uint)i).Field<string>(3);

Pnt Is In One Of The FeatureDataRow1 . But "Within()" Function Can Not Found This.I Work With Version1.1 of SharpMap.
Jul 23, 2008 at 11:32 AM
hi saminsalemi, Point inherits Geometry which supplies the Within method. Are you getting an exception? if so post the stack trace cheers jd
Jul 23, 2008 at 12:19 PM
Edited Jul 23, 2008 at 12:21 PM
Hi JohnDiss.
No.Any Exception. But In The State That I know That Pnt Is In The Polygon(FeatureDataRow1.Geometry), But "Pnt.Within(FeatureDataRow1.Geometry)" Return "Flase". But It Must Return "True".
Base Of My Question: I Need A Function That Check A Point Is In The Polygon( In A ShapeFile ) Or No???
Thank You Very Much For Your response.
Jul 23, 2008 at 12:26 PM
Spatial relationships are much more advanced in NTS than in Sharpmap, perhaps you could use NTS instead. hth jd
Jul 26, 2008 at 6:06 AM
Hi JohnDiss.How Can I Use NTS ??? Can You Send One Sample For Me? Thank You Very Very Much.
Jul 27, 2008 at 11:27 AM

Hi again saminsalemi, unfortunately i dont really have enough time to do you a demo at the moment, but i can give you a pointer- there is a class NtsGeometryConverter in the Extensions project which will allow you to convert easily between SharpMap and NTS geometry models.

So you can read the shapefile using the shapefile provider, then you can modify your procedure above, converting  the geometry from sharpmap to NTS and carrying out your test before proceeding with the original SharpMap  geometry. hth jd

Jul 28, 2008 at 9:08 AM
Hi JohnDiss.Very Very Very Much For Your Response.....