Geographic JSON (GeoJSON)
2. Geographic JSON (GeoJSON)
类别 | 说明 | 翻译 |
---|---|---|
Authors | Howard Butler (Hobu Inc.), Martin Daly (Cadcorp), Allan Doyle (MIT), Sean Gillies (UNC-Chapel Hill), Tim Schaub (OpenGeo), Christopher Schmidt (MetaCarta) | 作者 |
Revision | 1.0 | 版本 |
Date | 16 June 2008 | 日期 |
Abstract | GeoJSON is a geospatial data interchange format based on JavaScript Object Notation (JSON). | 描述:GeoJSON是一种基于JavaScript对象符号(JSON)的地理空间数据交换格式。 |
Copyright | Copyright © 2008 by the Authors. This work is licensed under a Creative Commons Attribution 3.0 United States License. | 版权所有©2008本作品在知识共享署名3.0美国许可下许可。 |
Status | Obsolete. Replaced by RFC 7946. | ---- |
2.1 简介
2.1.1. Introduction 介绍
GeoJSON is a format for encoding a variety of geographic data structures. A GeoJSON object may represent a geometry, a feature, or a collection of features. GeoJSON supports the following geometry types: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection. Features in GeoJSON contain a geometry object and additional properties, and a feature collection represents a list of features.
GeoJSON是一种用于编码各种地理数据结构的格式。GeoJSON对象可以表示一个几何图形、一个特征或一组特征。GeoJSON支持以下几何类型:点,线串,多边形,多点,多线串,多多边形,几何集合。GeoJSON中的特性包含一个几何对象和其他属性,一个特性集合表示一个特性列表。
A complete GeoJSON data structure is always an object (in JSON terms). In GeoJSON, an object consists of a collection of name/value pairs – also called members. For each member, the name is always a string. Member values are either a string, number, object, array or one of the literals: true, false, and null. An array consists of elements where each element is a value as described above.
一个完整的GeoJSON数据结构总是一个对象(用JSON术语来说)。在GeoJSON中,对象由名称/值对(也称为成员)的集合组成。对于每个成员,名称总是一个字符串。成员值可以是字符串、数字、对象、数组或其中一个字面值:true、false和null。数组由上面描述的元素组成,其中每个元素都是一个值。
2.1.2. Examples 样例
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "小菜",
"age": 18,
"desc": "小菜很帅"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
111.97265625,
32.287132632616384
],
[
109.4677734375,
28.69058765425071
],
[
116.27929687499999,
29.075375179558346
],
[
114.873046875,
32.13840869677249
],
[
111.97265625,
32.287132632616384
]
]
]
}
}
]
}
2.1.3. Definitions 定义
-
JavaScript Object Notation (JSON), and the terms object, name, value, array, and number, are defined in IETF RFC 4627.
-
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in IETF RFC 2119.
-
IETF RFC 4627中定义了JavaScript对象表记法(JSON)以及对象、名称、值、数组和数字等术语。
-
本文档中的关键字将按照“MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL”进行介绍
2.2 GeoJSON Objects GeoJSON对象
GeoJSON always consists of a single object. This object (referred to as the GeoJSON object below) represents a geometry, feature, or collection of features.
GeoJSON总是由单个对象组成。这个对象(下面称为GeoJSON对象)表示一个几何图形、特征或特征集合。
- 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 (see 2.3. Coordinate Reference System Objects).
- A GeoJSON object may have a “bbox” member, the value of which must be a bounding box array (see 2.4. Bounding Boxes).
- GeoJSON对象可以有任意数量的成员(名称/值对)。
- GeoJSON对象必须有一个名为“type”的成员。该成员的值是一个字符串,它决定GeoJSON对象的类型。
- 类型成员的值必须是: “Point”, “MultiPoint”, “LineString”, “MultiLineString”, “Polygon”, “MultiPolygon”,“GeometryCollection”, “Feature”, or “FeatureCollection”.类型成员值的情况必须如下所示。
- 一个GeoJSON对象可以有一个可选的“crs”成员,该成员的值必须是一个坐标参考系统对象(见2.3.坐标参考系统对象)。
- 一个GeoJSON对象可能有一个“bbox”成员,它的值必须是一个边界盒数组(见2.4.包络盒)。
2.2.1 Geometry Objects
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”.
几何体是一个GeoJSON对象,其中类型成员的值是以下字符串之一:“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.
除了“GeometryCollection”,任何类型的GeoJSON几何对象都必须有一个名为“coordinates”的成员。coordinates成员的值总是一个数组。该数组中元素的结构由几何图形的类型决定。
2.2.1.1 Positions 位置
A position is the fundamental geometry construct. The “coordinates” member of a geometry object is composed of one position (in the case of a Point geometry), an array of positions (LineString or MultiPoint geometries), an array of arrays of positions (Polygons, MultiLineStrings), or a multidimensional array of positions (MultiPolygon).
位置是基本的几何结构。一个几何对象的“坐标”成员由一个位置(在点几何的情况下)、一个位置数组(LineString或MultiPoint几何)、一个位置数组数组(polygon、multilinestring)或一个多维位置数组数组(MultiPolygon)组成。
A position is represented by an array of numbers. There must be at least two elements, and may be more. The order of elements must follow x, y, z order (easting, northing, altitude for coordinates in a projected coordinate reference system, or longitude, latitude, altitude for coordinates in a geographic coordinate reference system). Any number of additional elements are allowed – interpretation and meaning of additional elements is beyond the scope of this specification.
位置由一组数字表示。必须至少有两个元素,可能更多。元素的顺序必须遵循x, y, z顺序(东经,北纬,投影坐标系中的坐标高度,经度,纬度,地理坐标系中的坐标高度)。允许任何数量的附加元素—附加元素的解释和意义超出了本规范的范围。
- Point
For type “Point”, the “coordinates” member must be a single position.
对于类型“Point”,“coordinates”成员必须是单个位置。
- MultiPoint
For type “MultiPoint”, the “coordinates” member must be an array of positions.
对于类型“MultiPoint”,“coordinates”成员必须是一个位置数组。
- LineString
For type “LineString”, the “coordinates” member must be an array of two or more positions.
A LinearRing is closed LineString with 4 or more positions. The first and last positions are equivalent (they represent equivalent points). Though a LinearRing is not explicitly represented as a GeoJSON geometry type, it is referred to in the Polygon geometry type definition.
对于“LineString”类型,“coordinates”成员必须是两个或多个位置的数组。
线性环是指具有4个或更多位置的闭合LineString。第一个和最后一个位置是相等的(它们代表相等的点)。虽然线性环没有显式地表示为GeoJSON几何类型,但它在Polygon几何类型定义中被引用。
- MultiLineString
For type “MultiLineString”, the “coordinates” member must be an array of LineString coordinate arrays.
对于“MultiLineString”类型,“coordinates”成员必须是LineString坐标数组的数组。
- Polygon
For type “Polygon”, the “coordinates” member must be an array of LinearRing coordinate arrays. For Polygons with multiple rings, the first must be the exterior ring and any others must be interior rings or holes.
对于“Polygon”类型,“coordinates”成员必须是LinearRing坐标数组的数组。对于有多个环的多边形,第一个必须是外环,其他必须是内环或孔。
- MultiPolygon
For type “MultiPolygon”, the “coordinates” member must be an array of Polygon coordinate arrays.
对于“MultiPolygon”类型,“coordinates”成员必须是一个Polygon坐标数组的数组。
- Geometry Collection
A GeoJSON object with type “GeometryCollection” is a geometry object which represents a collection of geometry objects.
A geometry collection must have a member with the name “geometries”. The value corresponding to “geometries” is an array. Each element in this array is a GeoJSON geometry object.
一个具有“GeometryCollection”类型的GeoJSON对象是一个几何对象,它表示几何对象的集合。
几何体集合必须有一个名为“geometries”的成员。“geometries”对应的值是一个数组。这个数组中的每个元素都是一个GeoJSON几何对象。
2.3. Coordinate Reference System Objects
The coordinate reference system (CRS) of a GeoJSON object is determined by its “crs” member (referred to as the CRS object below). If an object has no crs member, then its parent or grandparent object’s crs member may be acquired. If no crs member can be so acquired, the default CRS shall apply to the GeoJSON object.
GeoJSON对象的坐标参考系(CRS)由其“CRS”成员(以下简称CRS对象)确定。如果一个对象没有crs成员,那么它的父对象或祖父对象的crs成员可以被获取。如果没有crs成员可以这样获取,默认的crs将应用于GeoJSON对象。
-
The default CRS is a geographic coordinate reference system, using the WGS84 datum, and with longitude and latitude units of decimal degrees.
-
The value of a member named “crs” must be a JSON object (referred to as the CRS object below) or JSON null. If the value of CRS is null, no CRS can be assumed.
-
The crs member should be on the top-level GeoJSON object in a hierarchy (in feature collection, feature, geometry order) and should not be repeated or overridden on children or grandchildren of the object.
-
A non-null CRS object has two mandatory members: “type” and “properties”.
-
The value of the type member must be a string, indicating the type of CRS object.
-
The value of the properties member must be an object.
-
CRS shall not change coordinate ordering.
-
默认的CRS是一个地理坐标参考系统,使用WGS84基准,经度和纬度单位为十进制度。
-
一个名为“crs”的成员的值必须是一个JSON对象(以下称为crs对象)或JSON null。如果CRS的值为空,则不能假设有CRS。
-
crs成员应该位于层次结构中的*GeoJSON对象上(按特性集合、特性、几何顺序),不应该在对象的子辈或孙辈上重复或覆盖。
-
非空CRS对象有两个强制成员:“type”和“properties”。
-
type成员的值必须是字符串,表示CRS对象的类型。
-
属性成员的值必须是一个对象。
-
CRS不得改变坐标顺序。
2.4. Bounding Boxes 包络盒
To include information on the coordinate range for geometries, features, or feature collections, a GeoJSON object may have a member named “bbox”. The value of the bbox member must be a 2*n array where n is the number of dimensions represented in the contained geometries, with the lowest values for all axes followed by the highest values. The axes order of a bbox follows the axes order of geometries. In addition, the coordinate reference system for the bbox is assumed to match the coordinate reference system of the GeoJSON object of which it is a member.
要包含关于几何、特性或特性集合的坐标范围的信息,GeoJSON对象可以有一个名为“bbox”的成员。bbox成员的值必须是一个2*n的数组,其中n是所包含几何图形中表示的维数,所有轴的最小值后面是最大值。盒子的坐标轴顺序遵循几何的坐标轴顺序。此外,假设bbox的坐标参考系统与它所属的GeoJSON对象的坐标参考系统相匹配。
2.5. Feature Objects 要素对象
A GeoJSON object with the type “Feature” is a feature object.
一个类型为“Feature”的GeoJSON对象是一个Feature对象。
- A feature object must have a member with the name “geometry”. The value of the geometry member is a geometry object as defined above or a JSON null value.
- A feature object must have a member with the name “properties”. The value of the properties member is an object (any JSON object or a JSON null value).
- If a feature has a commonly used identifier, that identifier should be included as a member of the feature object with the name “id”.
- 一个特征对象必须有一个名为“geometry”的成员。几何体成员的值是上面定义的几何体对象或JSON空值。
- 一个特性对象必须有一个名为“properties”的成员。属性成员的值是一个对象(任何JSON对象或JSON空值)。
- 如果一个特性有一个常用的标识符,那么这个标识符应该作为一个名为“id”的特性对象的成员包括进来。
2.6. Feature Collection Objects 要素集合对象
A GeoJSON object with the type “FeatureCollection” is a feature collection object.
An object of type “FeatureCollection” must have a member with the name “features”. The value corresponding to “features” is an array. Each element in the array is a feature object as defined above.
一个类型为“FeatureCollection”的GeoJSON对象是一个特性集合对象。
“FeatureCollection”类型的对象必须有一个名为“features”的成员。“features”对应的值是一个数组。数组中的每个元素都是上面定义的特性对象。
ponding to “features” is an array. Each element in the array is a feature object as defined above.
一个类型为“FeatureCollection”的GeoJSON对象是一个特性集合对象。
“FeatureCollection”类型的对象必须有一个名为“features”的成员。“features”对应的值是一个数组。数组中的每个元素都是上面定义的特性对象。
上一篇: 高性能秒级定时器SDK编程参考手册