Skip to content

Commit

Permalink
docs: user usage
Browse files Browse the repository at this point in the history
  • Loading branch information
lvisei committed Aug 25, 2023
1 parent fb829d7 commit dd9a1b6
Show file tree
Hide file tree
Showing 12 changed files with 476 additions and 22 deletions.
File renamed without changes.
2 changes: 0 additions & 2 deletions README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,4 @@ To become a contributor, please follow our [contributing guide](https://github.c

## License

## 许可证

[Apache-2.0](./LICENSE)
143 changes: 143 additions & 0 deletions bindings/pyl7vp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<img src="https://gw.alipayobjects.com/zos/antfincdn/R8sN%24GNdh6/language.svg" width="18"> English | [简体中文](./README.zh-CN.md)

# PyL7VP

🌍 Python3 binding for [`@AntV/L7VP`](https://li.antv.antgroup.com) geospatial visual analysis tool.

[![Latest Stable Version](https://img.shields.io/pypi/v/pyl7vp.svg)](https://pypi.python.org/pypi/pyl7vp) [![Test Status](https://github.com/antvis/L7VP/workflows/pyl7vp-test/badge.svg)](https://github.com/antvis/L7VP/actions?query=workflow:pyl7vp-test) [![Pypi Download](https://img.shields.io/pypi/dm/pyl7vp)](https://pypi.python.org/pypi/pyl7vp)

<div align="center">
<img src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*EAcUQb_UzAEAAAAAAAAAAAAADmJ7AQ/original.png" width="800">
</div>

## Installation

```bash
$ pip install pyl7vp
```

## Usage

### Jupyter Notebook and JupyterLab

```py
from pyl7vp import L7VP

l7vp_map = L7VP(height = 600)

# Add dataset to map
l7vp_map.add_dataset({"id": "my_dataset", "type": 'local', "data": []})

# Set config
l7vp_map.set_config({
"map": {
"type": "Gaode",
"config": {
"zoom": 3,
"center": [120.153576, 30.287459],
"style": 'dark',
},
},
})

# print datasets and config
l7vp_map.datasets
l7vp_map.config

# Display map
l7vp_map.show()
```

### Save to HTML File

```py
from pyl7vp import L7VP

l7vp_map = L7VP(height = 600)

l7vp_map.set_config({
"map": {
"type": "Gaode",
"config": {
"zoom": 3,
"center": [120.153576, 30.287459],
"style": 'dark',
},
},
})

# save to html file
l7vp_map.save_to_html("map.html")
```

## Examples

- Online in [Google Colab](https://colab.research.google.com/drive/1KCTfPRv-NksUF3sVGLjSrYo7RgHmfeHH?usp=sharing).

## API

#### L7VP

_L7VP(height: int = 600, datasets: list = [], config: dict = {})_: return an instance.

- _add_dataset(dataset: dict)_: add an dataset to map.

- _set_config(config: dict)_: set the config into instance.

- _show(read_only: bool = False)_: show map on Jupyter Notebook or JupyterLab preview.

- _save_to_html(file_name: str = "map.html", read_only: bool = False,)_: save to html file.

## Local Development

### Install Jupyter

```shell
# Using pip
pip install jupyter

# or Using conda
# conda install jupyter
```

### Clone code

```shell
git clone https://github.com/antvis/L7VP.git
```

### Setup jupyter

#### Install python module

```sh
cd bindings/pyl7vp

# dev install from folder containing setup.py
pip install -e .
```

#### Start jupyter notebook

```shell
cd notebooks
jupyter notebook
```

### Release a new version

Update `version` in `bindings/pyl7vp/pyl7vp/meta.py`

```py
__version__ = "0.0.1"
```

Build and publish

```bash
python setup.py upload
```

## License

[Apache-2.0](./LICENSE)
143 changes: 143 additions & 0 deletions bindings/pyl7vp/README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<img src="https://gw.alipayobjects.com/zos/antfincdn/R8sN%24GNdh6/language.svg" width="18"> [English](./README.md) | 简体中文

# PyL7VP

🌍 PyL7VP 是 [`@AntV/L7VP`](https://li.antv.antgroup.com) 在 Python3 上的封装。

[![Latest Stable Version](https://img.shields.io/pypi/v/pyl7vp.svg)](https://pypi.python.org/pypi/pyl7vp) [![Test Status](https://github.com/antvis/L7VP/workflows/pyl7vp-test/badge.svg)](https://github.com/antvis/L7VP/actions?query=workflow:pyl7vp-test) [![Pypi Download](https://img.shields.io/pypi/dm/pyl7vp)](https://pypi.python.org/pypi/pyl7vp)

<div align="center">
<img src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*EAcUQb_UzAEAAAAAAAAAAAAADmJ7AQ/original.png" width="800">
</div>

## 安装

```bash
$ pip install pyl7vp
```

## 使用

#### 在 Notebook 或 JupyterLab

```py
from pyl7vp import L7VP

l7vp_map = L7VP(height = 600)

# Add dataset to map
l7vp_map.add_dataset({"id": "my_dataset", "type": 'local', "data": []})

# Set config
l7vp_map.set_config({
"map": {
"type": "Gaode",
"config": {
"zoom": 3,
"center": [120.153576, 30.287459],
"style": 'dark',
},
},
})

# print datasets and config
l7vp_map.datasets
l7vp_map.config

# Display map
l7vp_map.show()
```

#### 保存为 HTML 文件

```py
from pyl7vp import L7VP

l7vp_map = L7VP(height = 600)

l7vp_map.set_config({
"map": {
"type": "Gaode",
"config": {
"zoom": 3,
"center": [120.153576, 30.287459],
"style": 'dark',
},
},
})

# save to html file
l7vp_map.save_to_html("map.html")
```

## 案例

- Online in [Google Colab](https://colab.research.google.com/drive/1KCTfPRv-NksUF3sVGLjSrYo7RgHmfeHH?usp=sharing).

## API

#### L7VP

_L7VP(height: int = 600, datasets: list = [], config: dict = {})_: 返回对应的类实例.

- _add_dataset(dataset: dict)_: 将数据集添加到地图上.

- _set_config(config: dict)_: 设置地图相关配置.

- _show(read_only: bool = False)_: 将地图渲染到 Jupyter Notebook or JupyterLab 上预览.

- _save_to_html(file_name: str = "map.html", read_only: bool = False,)_: 保存为 HTML 文件.

## 本地研发

### 安装 Jupyter

```shell
# Using pip
pip install jupyter

# or Using conda
# conda install jupyter
```

### 克隆代码到本地

```shell
git clone https://github.com/antvis/L7VP.git
```

### 启动 jupyter

#### 安装 python 模块

```sh
cd bindings/pyl7vp

# dev install from folder containing setup.py
pip install -e .
```

#### 启动 jupyter notebook

```shell
cd notebooks
jupyter notebook
```

### 发布新版本

更新版本号在 `bindings/pyl7vp/pyl7vp/meta.py` 文件

```py
__version__ = "0.0.1"
```

构建和发布版本

```bash
python setup.py upload
```

## 协议

[Apache-2.0](./LICENSE)
3 changes: 0 additions & 3 deletions bindings/pyl7vp/docs/examples/setup_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,8 @@
"data": data,
}


l7vp_map = L7VP(height=600, datasets=[dataset], config={})


l7vp_map.add_dataset(dataset)

l7vp_map.set_config({
Expand Down Expand Up @@ -166,6 +164,5 @@
}]
})


# print(l7vp_map.config)

Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,8 @@
"source": [
"earthquake_map.add_dataset({\n",
" \"id\": \"earthquake\",\n",
" \"metadata\": {\n",
" \"name\": \"earthquake\",\n",
" },\n",
" \"type\": 'local',\n",
" \"data\": data,\n",
" \"columns\": []\n",
" \"data\": data\n",
"})"
]
},
Expand Down
7 changes: 2 additions & 5 deletions bindings/pyl7vp/pyl7vp/l7vp.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ def _validate_datasets(datasets: list):
for dataset in datasets:
_validate_dataset(dataset)

_datasets = list(filter(lambda x: x["id"] != dataset["id"], datasets))

return _datasets
return datasets


def _validate_config(config: dict):
Expand Down Expand Up @@ -170,11 +168,10 @@ def show(
self,
read_only: bool = False,
env: Optional[Environment] = None,
html_template: str = "notebook.html",
**kwargs
) -> HTML:
# get html string
html = self._get_html_str(read_only, env, html_template, **kwargs)
html = self._get_html_str(read_only, env, "notebook.html", **kwargs)
return HTML(html)

'''
Expand Down
8 changes: 4 additions & 4 deletions bindings/pyl7vp/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def read(*names, **kwargs):


__title__ = "pyl7vp"
__description__ = "Python3 binding for @AntV/L7VP geospatial intelligent visual analysis."
__description__ = "Python3 binding for @AntV/L7VP geospatial visual analysis tool."
__long_description__ = read('README.md')
__url__ = "https://github.com/antvis/L7VP/bindings/pyl7vp"
__author_email__ = "[email protected]"
__license__ = "MIT"
__license__ = "Apache-2.0"

__requires__ = ["jinja2>=3.0.0", "simplejson"]
__extra_requires__ = {}
Expand Down Expand Up @@ -62,7 +62,7 @@ def run(self):
pass

self.status("Building Source and Wheel distribution…")
os.system("{0} setup.py bdist_wheel".format(sys.executable))
os.system("{0} setup.py bdist_wheel sdist".format(sys.executable))

self.status("Uploading the package to PyPI via Twine…")
os.system("python -m twine upload dist/*")
Expand All @@ -88,7 +88,7 @@ def run(self):
classifiers=[
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
Expand Down
Loading

0 comments on commit dd9a1b6

Please sign in to comment.