measure area of irregular polygon in android

I am developing one application in which i have draw the polygon on map and map that I have used is not google,Its Mapsforge opensource offline map library.i have easily draw polygon on map by converting geopoint into pixcel point.but here i want to find are of that irregular polygon,and for that i have make lots of try but its getting me unsuccess.. I have tried with calculate area with basic Math but its not working in this case be case pixcel are change accodingly while change zoom level. Here is Math logic : Math calculation

 for(int miAreainc = 0;miAreainc  < x.length-1; miAreainc++)
                 {
                     sumX += x[miAreainc] * y[miAreainc + 1];
                     sumY += y[miAreainc] * x[miAreainc + 1];
                 }
                 int unit = ((sumX - (sumY)) / 2);
                 AppLog.showLogE(TAG,"UNIT >> " + unit);

I found that funcation stay at server side which get area from geopoint array,but here I want to make it offline. I have tried so far but not getting any clue or result .. Please help me out this.. Thanks


Note : I don't really know how stupid my answer is. So please let me know if it doesn't make sense and I'll delete it.

Since the map is not in Cartesian Coordinate System, your calculation will not yield accurate result. You need Spherical Trigonometry for Spherical Polygon which is not trivial.

There is a good discussion at Calculating area enclosed by arbitrary polygon on Earth's surface. Take a look.

But apart from all of these, I have found Projection.java in mapsforge which has a method to find the absolute pixel coordinates on the world map from GeoPoint at a specific zoom level:

Translates the given {@link GeoPoint} to absolute pixel coordinates on the world map.

Point toPoint(GeoPoint in, Point out, byte zoomLevel);

I'm not really knowledgeable, but I think it will give you the absolute coordinate of GeoPoint on a projected map so you can use Cartesian calculation.


for area calculation you Need to transform lat, lon to cartesian coordinates with Unit Meters. (Not Pixels) Look into transform Moduls

链接地址: http://www.djcxy.com/p/71598.html

上一篇: CompositeCollection / CollectionViewSource混淆

下一篇: 测量android中不规则多边形的面积