openlayers摸爬滚打 4.GeoJSON

GeoJSON是一种用于编码各种地理数据结构的格式。GeoJSON对象可以表示几何、特征或者特征集合。GeoJSON支持下面几何类型:点、线、面、多点、多线、多面和几何集合。GeoJSON里的特征包含一个几何对象和其他属性,特征集合表示一系列特征。

一个完整的GeoJSON数据结构总是一个JSON对象,符合JSON规范。

GeoJSON官网:https://geojson.org

官网对GeoJSON的规范介绍:https://tools.ietf.org/html/rfc7946

中文翻译后的规范介绍:https://www.oschina.net/translate/geojson-spec

在线验证地址:http://geojson.io/

 

GeoJSON将地理要素Point、MultiPoint、LineString、MultiLineString、Polygon、MultiPolygon、GeometryCollection封装为一个个要素feature,结构如下:其中geometry下的type即对应上面的地理要素类型

{
	"type": "Feature",
	"properties": {},
	"geometry": {
		"type": "Point",
		"coordinates":[121.487899486, 31.24916171]
	}
}

然后将要素放到一个要素集合里,存放在features集合中,如下:

{
	"type": "FeatureCollection",
	"features": [{
		"type": "Feature",
		"properties": {},
		"geometry": {
			"type": "Point",
			"coordinates": [
				121.487899486,
				31.24916171
			]
		}
	}]
}

这样即是一个GeoJSON对象

http://geojson.io/在线验证地址来描绘出点、线

点:

{
	"type": "FeatureCollection",
	"features": [{
		"type": "Feature",
		"properties": {},
		"geometry": {
			"type": "Point",
			"coordinates": [
				121.487899486,
				31.24916171
			]
		}
	}]
}

 

 

 多点:

{
	"type": "FeatureCollection",
	"features": [{
		"type": "Feature",
		"properties": {},
		"geometry": {
			"type": "MultiPoint",
			"coordinates": [
				[121.487899486, 31.24916171],
				[121.50, 31.30]
			]
		}
	}]
}

线:

{
	"type": "FeatureCollection",
	"features": [{
		"type": "Feature",
		"properties": {},
		"geometry": {
			"type": "LineString",
			"coordinates": [
				[121.487899486, 31.24916171],
				[121.50, 31.30]
			]
		}
	}]
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值