nodejs+postgresql+typeorm开发地理位置app的服务器

GeoJson

官网 用于编码地理数据。
json结构:

点Point:
{
     "type": "Point",
     "coordinates": [100.0, 0.0]
 }

线LingString:
{
   "type": "LineString",
   "coordinates": [
       [100.0, 0.0],
       [101.0, 1.0]
   ]
}

多边形Polygon(coordinates数组第一个表示外环,后面一次表示内环):
{
   "type": "Polygon",
   "coordinates": [
       [
           [100.0, 0.0],
           [101.0, 0.0],
           [101.0, 1.0],
           [100.0, 1.0],
           [100.0, 0.0]
       ],
       [
           [100.8, 0.8],
           [100.8, 0.2],
           [100.2, 0.2],
           [100.2, 0.8],
           [100.8, 0.8]
       ]
   ]
}

Multi系列:
{
   "type": "MultiPoint / MultiLineString / MultiPolygon",
   "coordinates": [ ... ]
}

GeometryCollection几何集合(geometries每个元素都是以上六个之一):
{
	"type": "GeometryCollection",
	"geometries": [
	  {
		"type": "Point",
		"coordinates": [100.0, 0.0]
	  }, 
	  {
		"type": "LineString",
		"coordinates": [
			[101.0, 0.0],
			[102.0, 1.0]
		]
	  }
	]
}

其中coordinates即坐标,格式为:[经度,纬度,海拔]或[东经,北纬,高程],即[longitude,latitude,altitude]或[easting,northing,elevation],严格按顺序使用,并且使用十进制数字,且最后一位可以省略

PostgreSql对GeoJson的支持

Postgre自带对GeoJson的支持(官网

posted @ 2025-06-07 10:18  李振欣  阅读(16)  评论(0)    收藏  举报