javascript中的地理空间查询

wol*_*ktm 23 javascript union geospatial

我正在寻找一个允许我进行地理空间查询的javascript库.我知道OpenLayers和GoogleMaps,但这两个不支持联合交叉等等.

+----+
|    |
|  +-+--+
+--+-+  |
   |    |
   +----+
Run Code Online (Sandbox Code Playgroud)

    +----+
    |    |
    |    +--+
    +--+    |
       |    |
       +----+
Run Code Online (Sandbox Code Playgroud)

ivy*_*ivy 6

更新2014-04-29:查看草坪,看起来很有前途

JSTS可以在浏览器中执行几何对象的联合.JSTS与openlayers库集成,它扩展了openlayers几何类(例如OpenLayers.Geometry.Polygon),因此它们能够进行几何操作.例:

>> var poly1 = OpenLayers.Geometry.Polygon.createRegularPolygon(
                                   new OpenLayers.Geometry.Point(0.0,0.0), 2, 5);
>> var poly2 = OpenLayers.Geometry.Polygon.createRegularPolygon(
                                   new OpenLayers.Geometry.Point(1.0,1.0), 2, 4);
>> var poly_u = poly1.union(poly2);
>> var poly_d = poly1.difference(poly2);
>> print(poly_u);
POLYGON((1.5667154718422638 -0.4142135623730949,1.1755705045849463 -1.618033988749895,
  -1.1755705045849465 -1.6180339887498947,-1.902113032590307 0.618033988749895,
  -0.41421356237309503 1.6990562312593451,-0.4142135623730949 2.414213562373095,
   2.414213562373095 2.414213562373095,2.414213562373095 -0.4142135623730949,
   1.5667154718422638 -0.4142135623730949))
Run Code Online (Sandbox Code Playgroud)

如果你想在JS中进行服务器端几何操作,那么Geoscript JS很不错.