OpenLayer4——GeoJSON简介
GeoJSON实际上就是一个JSON,为了满足GIS编程需要,额外定制了这样一套规则。
geojson中包含了点、线、面的数据,包含大量的坐标的数组
(不需要过分深入研究,如果参与GIS编程,短时间内就会接触大量这样的数据)
gsojson样例1
独立的feature
{"type":"Feature", "properties":{}, "geometry":{ "type":"Point", "coordinates":[105.380859375,31.57853542647338] } }
gsojson样例2
feature集合
{ "type": "FeatureCollection", "features": [{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [102.0, 0.5] }, "properties": { "prop0": "value0" } }, { "type": "Feature", "geometry": { "type": "LineString", "coordinates": [[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]] }, "properties": { "prop0": "value0", "prop1": 0.0 } } ] }
GeoJSON成员变量
完整的GeoJSON,最外层往往是Feature或者FeatureCollection,Feature包含一个或多个Geometry,Geometry下面则是具体的几何数据(坐标数组和数据类型)。
GeoJSON
type:值必须是这些值其中一个:"Point","MultiPoint","LineString", "MultiLineString", "Polygon","MultiPolygon","GeometryCollection","Feature" 或者 "FeatureCollection”。
properties:携带参数,用于辅助图形绘制,并没有内容限制。(常见的比如:图形的名称、地图的样式)。
Geometry(几何图形,点、线、面图形数据)
Type:图形类型,分为Point、MultiPoint、LineString、MultiLineString、Polygon、MultiPolygon、GeometryCollection。
Coordinates:地图坐标数组
英文介绍
The GeoJSON object may have any number of members (name/value pairs).
The GeoJSON object must have a member with the name "type". This member's
value is a string that determines the type of the GeoJSON object.
The value of the type member must be one of: "Point", "MultiPoint",
"LineString", "MultiLineString", "Polygon", "MultiPolygon",
"GeometryCollection", "Feature", or "FeatureCollection". The case of the type
member values must be as shown here.
A GeoJSON object may have an optional "crs" member, the value of which must
be a coordinate reference system object .
A GeoJSON object may have a "bbox" member, the value of which must be a
bounding box array.
A geometry is a GeoJSON object where the type member's value is one of the
following strings: "Point", "MultiPoint", "LineString", "MultiLineString",
"Polygon", "MultiPolygon", or "GeometryCollection".
A GeoJSON geometry object of any type other than "GeometryCollection" must have
a member with the name "coordinates". The value of the coordinates member is
always an array. The structure for the elements in this array is determined by
the type of geometry.