在进行javascript编程时,json格式是一个比较简单且容易接受的一个数据形式,完全的键值对应,很好地与javascript对象结合。而且现在服务器端也有很多类库可以将服务器的对象生成json,包括simplejson,Newtonsoft.Json等,在与服务器端通信时方便而且快捷,不附带像xml多余的其它信息。所以在写himap时就考虑使用geojson当数据来源,而且arcmap通过FME可以轻松将很多格式矢量数据转成geojson.下面为geojson 1.0标准主要对象说明:
{ "type": "Point", "coordinates": [100.0, 0.0] }
{ “type”: “LineString”,
“coordinates”: [ [100.0, 0.0], [101.0, 1.0] ]
}
{ “type”: “Polygon”,
“coordinates”: [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
]
}
带内部洞的:
{ “type”: “Polygon”,
“coordinates”: [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],
[ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
]
}
{ “type”: “MultiPoint”,
“coordinates”: [ [100.0, 0.0], [101.0, 1.0] ]
}
{ “type”: “MultiLineString”,
“coordinates”: [
[ [100.0, 0.0], [101.0, 1.0] ],
[ [102.0, 2.0], [103.0, 3.0] ]
]
}
{ “type”: “MultiPolygon”,
“coordinates”: [
[[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],
[[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
[[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]
]
}
{ “type”: “GeometryCollection”,
“geometries”: [
{ "type": "Point",
"coordinates": [100.0, 0.0]
},
{ “type”: “LineString”,
“coordinates”: [ [101.0, 0.0], [102.0, 1.0] ]
}
]
}
{“name”:”subway_point”,”type”:”FeatureCollection”
,”features”:[
{"type":"Feature","geometry":{"type":"Point","coordinates":[116.189086914063,39.9382934570313]},”properties”:{“OBJECTID”:1}}
,{“type”:”Feature”,”geometry”:{“type”:”Point”,”coordinates”:[116.197875976563,39.9296875]},”properties”:{“OBJECTID”:2}}]
}
针对多点、多线、多面、集合对象在处理时都可以拆解为单个的点、线、面进行处理,很是方便。