entity framework - Create a DbGeography Polygon from a collection of DbGeography Points -
can tell me how can create dbgeography object of type 'polygon' collection of dbgeography objects of type 'point'
so far i've got creates polygon i'm missing how initial step.
1. dbgeography multipoint = dbgeography.multipointfromtext("multipoint(53.095124 -0.864716, 53.021255 -1.337128, 52.808019 -1.345367, 52.86153 -1.018524)", 4326) 2. dbgeometry temp_multipoint = dbgeometry.multipointfrombinary(multipoint.asbinary(), 4326) 3. dbgeography polygon = dbgeography.polygonfrombinary(temp_multipoint.convexhull.asbinary(), 4326); (result) the problem creating initial multipoint geography object list of dbgeography(points)
create each point dbgeography object using wkt:
dbgeography point1 = dbgeography.fromtext("point(53.095124 -0.864716)", 4326); dbgeography point2 = dbgeography.fromtext("point(53.021255 -1.337128)", 4326); dbgeography point3 = dbgeography.fromtext("point(52.808019 -1.345367)", 4326); ... dbgeography polygon = dbgeography.polygonfromtext("polygon((53.095124 -0.864716, 53.021255 -1.337128, 52.808019 -1.345367, 53.095124 -0.864716))", 4326); two things note:
- the wkt format longitude latitude, not more intuitive lat, long
- for polygon, last point must match first point "close off"
hope helps - battled learn polygon stuff!
see article tips on wkt format: http://en.wikipedia.org/wiki/well-known_text
Comments
Post a Comment