# chncrs

> coordinate transforming of various chinese encrypted coordinate systems such as BAIDU, GCJ02 etc.

Latest version **0.1.6** (published 2016-03-18) · WTFPL license · 0 weekly downloads

## Install

```sh
npm install chncrs
pnpm add chncrs
yarn add chncrs
bun add chncrs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2016-03-18 |
| First published | 2016-02-17 |
| Weekly downloads | 0 |
| License | WTFPL |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Maintainers | fuzhenn |

## Links

- npm: https://www.npmjs.com/package/chncrs
- Repository: https://github.com/FuZhenn/chinese_coordinate_conversion
- Homepage: https://github.com/FuZhenn/chinese_coordinate_conversion#readme
- Issues: https://github.com/FuZhenn/chinese_coordinate_conversion/issues
- npm.io page: https://npm.io/package/chncrs

## Recent versions

- 0.1.6 (latest) — 2016-03-18
- 0.1.5 — 2016-03-14
- 0.1.4 — 2016-02-27
- 0.1.3 — 2016-02-18
- 0.1.2 — 2016-02-17
- 0.1.1 — 2016-02-17

## README

# Chinese Coordinate Transform
Coordinate or [GeoJSON](http://www.geojson.org) trasnforming from WGS84 to various encrypted Chinese coordinate systems such as BD09LL, GCJ02 and vice versa.

## Supported coordinate reference systems (CRS)

* [GCJ02](https://en.wikipedia.org/wiki/Restrictions_on_geographic_data_in_China) : Chinese encrypted coordinate system 
* BD09LL : CRS used by http://map.baidu.com
* WGS84 : well-known CRS, aka EPSG:4326

## Definition
```javascript
convertor.transform(source, fromCRS, toCRS);
```

* **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

```Bash
    npm install chncrs
```

### Browser

```html
    <script src="chncrs.js"></script>
    <script type="text/javascript">
        var c = maptalks.CRSTransform.transform([114.68837663801743, 33.63312016454496], 'GCJ02', 'BD09LL');
    </script>
```

## Example

```javascript
    var convertor = require('chncrs');
    //convert coordinates from gcj02 to bd09ll
    var c = convertor.transform([114.68837663801743, 33.63312016454496], 'GCJ02', 'BD09LL');
    
    //convert a geoJSON object from gcj02 to bd09ll
    //can also be other geometry type, a Feature, even a FeatureCollection
    var geo = { "type": "Point", "coordinates": [100.0, 0.0] };
    var geo2 = convertor.transform(geo, 'GCJ02', 'BD09LL');

    
    //a geoJSON array
    var geos = [{ "type": "Point", "coordinates": [100.0, 0.0] } ,
                { "type": "Point", "coordinates": [101.0, 1.0] }];
    var geos2 = convertor.transform(geo, 'GCJ02', 'BD09LL');
    
    //a Feature
    var feature = { "type": "Feature",
              "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
              "properties": {"prop0": "value0"}
            };
    var feature2 = convertor.transform(geo, 'GCJ02', 'BD09LL');

    //a FeatureCollection
    var featureCollection = {
                "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]
                          ]
                      }
                 ]
              };
    var featureCollection2 = convertor.transform(geo, 'GCJ02', 'BD09LL');
```

---
_Source: https://npm.io/package/chncrs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
