c# - How to get Geometry points using Geo API (Sharpmap) -


i have epsg:4326 wgs 84 shapefile , i've converted sql spatial data i'm able render map using sharpmap 1.1(previously using sharpmap 0.9).

what i'm trying achieve when click on generated polygon, clicked polygon must filled color (for identification purpose) i'm able point click how use point , query point inside polygon can color point might result in coloring polygon.

the problem don't know how in sharpmap version 1.1.

previously when using sharpmap 0.9 used below line points color whole of polygon.

pointarray.collection.add(sharpmap.geometries.linearring.geomfromwkb((byte[])row["the_geom"]));

my data sql spatial db hence row["the_geom"].

so far i've done this.(which highlights point , need add points geo api collection)

  collection<geoapi.geometries.igeometry> geomcoll = new collection<geoapi.geometries.igeometry>();         geoapi.geometryserviceprovider.instance = new nettopologysuite.ntsgeometryservices();         geoapi.geometries.igeometryfactory gf = geoapi.geometryserviceprovider.instance.creategeometryfactory();           sharpmap.layers.vectorlayer mysuggestedlayer = new sharpmap.layers.vectorlayer("higlight");         fillcolor = shapefillcolor;          var factory = geoapi.geometryserviceprovider.instance.creategeometryfactory(_srid);         var pointarraysubject = factory.creategeometrycollection(null);         var mysubjectlayer = new sharpmap.layers.vectorlayer("subjecticon");          datarow row = accounts.newrow();         (int = 0; < accounts.rows.count; i++)         {             row = accounts.rows[i];             geoapi.geometries.coordinate pinpnt = new geoapi.geometries.coordinate();               double x = double.parse(row["xcoord_geo"].tostring());              double y = double.parse(row["ycoord_geo"].tostring());               pinpnt.x = x;             pinpnt.y = y;             //pointarray.collection.add(sharpmap.geometries.linearring.geomfromwkb((byte[])row["the_geom"]));             geomcoll.add(gf.createpoint(pinpnt));          mysuggestedlayer.datasource = new sharpmap.data.providers.geometryfeatureprovider(geomcoll);         mysuggestedlayer.style.fill = new system.drawing.solidbrush(fillcolor);                mysuggestedlayer.style.enableoutline = true;         mysuggestedlayer.srid = _srid;          _map.layers.add(mysuggestedlayer);          return _map; 

any idea/help make day.

i figured out myself fobermaier of sharpmap discussion here , i'm posting might someone.

the problem geometry transformation of layer

it seems transformation in wrong format

 geoapi.geometries.coordinate pinpnt = new geoapi.geometries.coordinate();  nettopologysuite.io.wkbreader reader = new nettopologysuite.io.wkbreader();  var wkb = (byte[])row["the_geom"];  geometry geom = (geometry)reader.read(wkb);  var p = new geometryfeatureprovider(geom);  mylayer.datasource = p;  mylayer.style.fill = new system.drawing.solidbrush(fillcolor); projnet.coordinatesystems.transformations.coordinatetransformationfactory ctfact = new projnet.coordinatesystems.transformations.coordinatetransformationfactory(); mylayer.coordinatetransformation = ctfact.createfromcoordinatesystems(projnet.coordinatesystems.geographiccoordinatesystem.wgs84, projnet.coordinatesystems.projectedcoordinatesystem.webmercator); mylayer.reversecoordinatetransformation = ctfact.createfromcoordinatesystems(projnet.coordinatesystems.projectedcoordinatesystem.webmercator, projnet.coordinatesystems.geographiccoordinatesystem.wgs84); _map.layers.add(mylayer); 

in above

row["the_geom"]

has layer needs highlighted. using projnet i've transformed geometry web mercator , worked.


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -