Chinese Coordinate Transform
Coordinate or GeoJSON trasnforming from WGS84 to various encrypted Chinese coordinate systems such as BD09LL, GCJ02 and vice versa.
Supported coordinate reference systems (CRS)
- GCJ02 : Chinese encrypted coordinate system
- BD09LL : CRS used by http://map.baidu.com
- WGS84 : well-known CRS, aka EPSG:4326
Definition
convertor;
- source : a coordinate, array of coordinates, a GeoJSON or a array of GeoJSON to transform, possible values:
- a coordinate: [x, y]
- coordinate arrays: [[x1,y1], [x2, y2]] or more dimensions: [[[x1,y1], [x2, y2], [x3, y3]]]
- a geoJSON object: { "type": "Point", "coordinates": [100.0, 0.0] }
- a array of geoJSON objects: [{ "type": "Point", "coordinates": [100.0, 0.0] } , { "type": "Point", "coordinates": [101.0, 1.0] }]
- fromCRS : CRS transform from, possble values:
- 'gcj02'
- 'bd09ll'
- 'wgs84' | 'EPSG:4326'
- toCRS : CRS transform to, same possible values with fromCRS
How to use
Node
npm install chncrs
Browser
Example
var convertor = ; //convert coordinates from gcj02 to bd09ll var c = convertor; //convert a geoJSON object from gcj02 to bd09ll //can also be other geometry type, a Feature, even a FeatureCollection var geo = "type": "Point" "coordinates": 1000 00 ; var geo2 = convertor; //a geoJSON array var geos = "type": "Point" "coordinates": 1000 00 "type": "Point" "coordinates": 1010 10 ; var geos2 = convertor; //a Feature var feature = "type": "Feature" "geometry": "type": "Point" "coordinates": 1020 05 "properties": "prop0": "value0" ; var feature2 = convertor; //a FeatureCollection var featureCollection = "type": "FeatureCollection" "features": "type": "Feature" "geometry": "type": "Point" "coordinates": 1020 05 "properties": "prop0": "value0" "type": "Feature" "geometry": "type": "LineString" "coordinates": 1020 00 1030 10 1040 00 1050 10 ; var featureCollection2 = convertor;