public static FeatureDataRow LocatePolygon2(SharpMap.Geometries.Point punto, SharpMap.Data.FeatureDataTable fdt) { FeatureDataRow fdr = null; if ((fdt as DataTable).Rows.Count == 1) { fdr = (FeatureDataRow)(fdt as DataTable).Rows[0]; } else { GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory f = new GeometryFactory(new PrecisionModel()); foreach (DataRow r in (fdt as DataTable).Rows) { if ((r as FeatureDataRow).Geometry.GetType() == typeof(SharpMap.Geometries.MultiPolygon)) { // Doble cast: de Geometria a MultiPolygon, y de DataRow a FeatureDataRow. SharpMap.Geometries.MultiPolygon SharpMultiPol = (SharpMap.Geometries.MultiPolygon)(r as FeatureDataRow).Geometry; GisSharpBlog.NetTopologySuite.Geometries.Geometry[] NTSGeom = GeometryConverter.ToNTSGeometry(new SharpMap.Geometries.Geometry[1] { SharpMultiPol }, f); GisSharpBlog.NetTopologySuite.Geometries.MultiPolygon NTSMultiPol = (GisSharpBlog.NetTopologySuite.Geometries.MultiPolygon)NTSGeom[0]; if (NTSMultiPol.Contains(new GisSharpBlog.NetTopologySuite.Geometries.Point(punto.X, punto.Y)) == true) { fdr = (FeatureDataRow)r; break; } } } } return(fdr); }