geocraft 0.3.4
Python library for Geo & WebGIS.
Requires Python: <4.0,>=3.9

# geocraft

**Note**: `geocraft` is still under development and backward compatibility is not guaranteed before reaching v1.0.0.

## Requirements

```plain
python >= 3.9
```

## Installation

```bash
pip install geocraft
```

## Use as Library

### CoordConverter

`CoordConverter` is used for convert a coordinate pair (lng, lat) between different coordinate systems.

```python
from geocraft import CoordConverter

converter = CoordConverter(src="bd09", target="gcj02")
print(converter.convert(116.404, 39.915))
```

<details>
  <summary>Output</summary>

```plain
(116.39762729119315, 39.90865673957631)
```

</details>

Supported conversions:

- Conversions between different coordinate systems (Non-Mercator):

  - `wgs84` <-> `gcj02`
  - `gcj02` <-> `bd09`
  - `bd09` <-> `wgs84`

- Conversions between same coordinate systems (Non-Mercator <-> Mercator):
  - `wgs84` <-> `wgs84mc`
  - `gcj02` <-> `gcj02mc`
  - `bd09` <-> `bd09mc`

### BaidumapParser (unstable)

```python
from geocraft.unstable import BaidumapParser

parser = BaidumapParser()
print(parser.parse("06d2dffda107b0ef89f15db6"))
```

<details>
  <summary>Output</summary>

```plain
[[116.38542843398525, 39.92151738991259], [116.38538685420565, 39.921513413054086], [116.38535487041676, 39.921506231072506], [116.38532848458672, 39.92149504619131], [116.38531569206987, 39.92148545371144], [116.38529330564644, 39.921465467023225], [116.3852845141087, 39.92143587320667], [116.3852861248264, 39.921355875809574], [116.38533422771435, 39.92047908730609], [116.38539353675836, 39.91952229589755], [116.3854064330775, 39.91880711952102], [116.38559245036473, 39.915271167217114], [116.38569988139689, 39.91329039114644], [116.38575119506572, 39.91231760344198], [116.3858152735157, 39.91155280033522], [116.38581767546371, 39.91153119993237], [116.38582887234888, 39.91151759451542], [116.38584806465622, 39.91151118455345], [116.38612714036417, 39.91152283675588], [116.38798281750744, 39.91163011768973], [116.3899631584974, 39.91170536994815], [116.3899748558365, 39.91170576536653], [116.38998635357804, 39.91170366097775], [116.3899971518169, 39.911699156972], [116.39000675063429, 39.911692453532325], [116.39001475007545, 39.91168385080151], [116.39002065019064, 39.91167374895317], [116.39002425095272, 39.9116626480428], [116.39018690094603, 39.90961567506205], [116.39021979246891, 39.90890369357733], [116.39022369437045, 39.90888399295733], [116.39022869487034, 39.908872791552476], [116.39023579476736, 39.90886278930384], [116.39024469408552, 39.90885428631203], [116.39025519281391, 39.9088476826379], [116.39026659105923, 39.90884327853313], [116.39027878884309, 39.90884107403712], [116.39029108626922, 39.90884136940016], [116.39116042465139, 39.90886575611594], [116.3922820783269, 39.90888539623907], [116.39230067572389, 39.90889119045109], [116.39231287300878, 39.908902386329196], [116.39232226990865, 39.90891838282385], [116.39232626731287, 39.90893448091355], [116.39216949439682, 39.91173680083455], [116.39217469116724, 39.911756098375875], [116.39218468818736, 39.91177009470021], [116.39219908549137, 39.911778889931476], [116.3922153829792, 39.91178508471429], [116.39249665538212, 39.911795400779155], [116.39457608742869, 39.91184828449316], [116.39546722959567, 39.911871721001525], [116.39617829201882, 39.91190361582307], [116.39620469380358, 39.91191241199949], [116.39621989333169, 39.91192840928326], [116.39622788959593, 39.91196200663886], [116.39618938023432, 39.9127171750007], [116.39615888597162, 39.91336834744963], [116.3961363961661, 39.91399232022329], [116.39608184298437, 39.915040276874095], [116.39604492664373, 39.91583704344106], [116.39597912889114, 39.91718418766118], [116.39589089408508, 39.918769724073975], [116.39584597617417, 39.919563292602085], [116.39579622270976, 39.920600050383584], [116.39577532529212, 39.921264021793554], [116.39575766134108, 39.9216968038172], [116.39575924431932, 39.92181599788087], [116.39575763932943, 39.9218495965228], [116.39574483479748, 39.92187279738877], [116.39572323096533, 39.92188560012459], [116.39434796509437, 39.92182585974528], [116.39345917536005, 39.92179967153906], [116.39244243997949, 39.92176895519337], [116.39072107959862, 39.92170693209769], [116.38992124657688, 39.92167523964209], [116.38853761585227, 39.92163742692192], [116.38741639483735, 39.92158835352149], [116.3864247869287, 39.921548854581346], [116.3856347368753, 39.92152447644972], [116.38542843398525, 39.92151738991259]]
```

</details>

## Use as Command-Line Tools

For commands below, use `--help` to check all available options.

### geocraft-coord-convert

```bash
$ geocraft-coord-convert -i "bd09" -o "gcj02" -c "116.404, 39.915"
```

<details>
  <summary>Output</summary>

```plain
(116.39762729119315, 39.90865673957631)
```

</details>

### geocraft-baidumap-parse (unstable)

```bash
$ geocraft-baidumap-parse -i "06d2dffda107b0ef89f15db6"
```

<details>
  <summary>Output</summary>

```plain
[[116.38542843398525, 39.92151738991259], [116.38538685420565, 39.921513413054086], [116.38535487041676, 39.921506231072506], [116.38532848458672, 39.92149504619131], [116.38531569206987, 39.92148545371144], [116.38529330564644, 39.921465467023225], [116.3852845141087, 39.92143587320667], [116.3852861248264, 39.921355875809574], [116.38533422771435, 39.92047908730609], [116.38539353675836, 39.91952229589755], [116.3854064330775, 39.91880711952102], [116.38559245036473, 39.915271167217114], [116.38569988139689, 39.91329039114644], [116.38575119506572, 39.91231760344198], [116.3858152735157, 39.91155280033522], [116.38581767546371, 39.91153119993237], [116.38582887234888, 39.91151759451542], [116.38584806465622, 39.91151118455345], [116.38612714036417, 39.91152283675588], [116.38798281750744, 39.91163011768973], [116.3899631584974, 39.91170536994815], [116.3899748558365, 39.91170576536653], [116.38998635357804, 39.91170366097775], [116.3899971518169, 39.911699156972], [116.39000675063429, 39.911692453532325], [116.39001475007545, 39.91168385080151], [116.39002065019064, 39.91167374895317], [116.39002425095272, 39.9116626480428], [116.39018690094603, 39.90961567506205], [116.39021979246891, 39.90890369357733], [116.39022369437045, 39.90888399295733], [116.39022869487034, 39.908872791552476], [116.39023579476736, 39.90886278930384], [116.39024469408552, 39.90885428631203], [116.39025519281391, 39.9088476826379], [116.39026659105923, 39.90884327853313], [116.39027878884309, 39.90884107403712], [116.39029108626922, 39.90884136940016], [116.39116042465139, 39.90886575611594], [116.3922820783269, 39.90888539623907], [116.39230067572389, 39.90889119045109], [116.39231287300878, 39.908902386329196], [116.39232226990865, 39.90891838282385], [116.39232626731287, 39.90893448091355], [116.39216949439682, 39.91173680083455], [116.39217469116724, 39.911756098375875], [116.39218468818736, 39.91177009470021], [116.39219908549137, 39.911778889931476], [116.3922153829792, 39.91178508471429], [116.39249665538212, 39.911795400779155], [116.39457608742869, 39.91184828449316], [116.39546722959567, 39.911871721001525], [116.39617829201882, 39.91190361582307], [116.39620469380358, 39.91191241199949], [116.39621989333169, 39.91192840928326], [116.39622788959593, 39.91196200663886], [116.39618938023432, 39.9127171750007], [116.39615888597162, 39.91336834744963], [116.3961363961661, 39.91399232022329], [116.39608184298437, 39.915040276874095], [116.39604492664373, 39.91583704344106], [116.39597912889114, 39.91718418766118], [116.39589089408508, 39.918769724073975], [116.39584597617417, 39.919563292602085], [116.39579622270976, 39.920600050383584], [116.39577532529212, 39.921264021793554], [116.39575766134108, 39.9216968038172], [116.39575924431932, 39.92181599788087], [116.39575763932943, 39.9218495965228], [116.39574483479748, 39.92187279738877], [116.39572323096533, 39.92188560012459], [116.39434796509437, 39.92182585974528], [116.39345917536005, 39.92179967153906], [116.39244243997949, 39.92176895519337], [116.39072107959862, 39.92170693209769], [116.38992124657688, 39.92167523964209], [116.38853761585227, 39.92163742692192], [116.38741639483735, 39.92158835352149], [116.3864247869287, 39.921548854581346], [116.3856347368753, 39.92152447644972], [116.38542843398525, 39.92151738991259]]
```

</details>