【问题标题】:Geofence library in JavaJava中的地理围栏库
【发布时间】:2015-06-23 16:12:46
【问题描述】:

你知道java开源地理围栏库(Determining If A Point Is Inside A Complex Polygon),比如Android的Google play services吗?

【问题讨论】:

    标签: java android-geofence


    【解决方案1】:

    使用开源库调用“utils”http://www.geotelematic.com/javadocs/org/opengts/util/package-summary.html

    boolean isPointInside(GeoPoint gp) 如果指定点在多边形内,则返回 true

    。 包含在 OpenGts Proyect 中:http://www.opengts.org/

    import org.opengts.util.GeoPoint;
    
    import org.opengts.util.GeoPolygon;
    

    使用此片段检查 Point 是否在多边形内

        GeoPolygon fence = new GeoPolygon( // Define a Fence Polygon 
                new GeoPoint(-31.414547, -64.488178),
                new GeoPoint(-31.415579, -64.496261),
                new GeoPoint(-31.411513, -64.495720),
                new GeoPoint(-31.408726, -64.489549),
                new GeoPoint(-31.411898, -64.484406)
                );
    
        GeoPoint testgp1 = new GeoPoint(-31.411753, -64.489922);// Point1 inside
        GeoPoint testgp2 = new GeoPoint(-31.413962, -64.486445);// Point2 outside
    
    
        boolean inzone = fence.isPointInside(testgp1);
        System.out.println ("Point1 is inside of polygon= "+inzone);
        inzone = fence.isPointInside(testgp2);
        System.out.println ("Point2 is inside of polygon= "+inzone);
    

    结果:

    Point1 is inside of polygon= true
    Point1 is inside of polygon= false
    

    【讨论】:

    • 我想这些库没有单独的 maven jar 包括这个“utils”包,但我会试试谢谢!
    • 没有。在我的情况下,我只在我的项目中包含“ org.opengts.util ”文件夹。如果你只需要函数'isPointInside()',这取决于'GeoPoint.java / GeoPolygon.java'。但我建议包含整个包,它具有非常有用的功能、方法和类。如您所见,如果您看一下。作者指出:“包含各种常用实用程序,使编程更容易一些。”
    • 和openmap一样的想法 我认为opengts的初始代码有很常见的想法,比如github.com/OpenMap-java/openmap/blob/master/src/openmap/com/bbn/…
    【解决方案2】:

    【讨论】:

    • 是的,但是你有 PolyUtils 类的源代码吗? ;)
    【解决方案3】:

    看看https://code.google.com/p/openmap/source/browse/src/openmap/com/bbn/openmap/geo/Intersection.java

    public static boolean isPointInPolygon(Geo x, GeoArray poly)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-07
      • 1970-01-01
      相关资源
      最近更新 更多