diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 236ba26..8e264ec 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python-version: [3.7, 3.8, 3.9] + python-version: ['3.10', '3.11', '3.12', '3.13'] steps: - uses: actions/checkout@v2 diff --git a/README.md b/README.md index d2c39c5..598a40e 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,10 @@ It supports below features: - [Random](https://github.com/omanges/turfpy/blob/master/random.md) +- [Feature Conversion](https://github.com/omanges/turfpy/blob/master/feature_conversion.md) + +- [Boolean](https://github.com/omanges/turfpy/blob/master/boolean.md) + ## Documentation Documentation can be found at: [docs](https://turfpy.readthedocs.io/en/latest/) diff --git a/boolean.md b/boolean.md new file mode 100644 index 0000000..6305aea --- /dev/null +++ b/boolean.md @@ -0,0 +1,41 @@ +## Boolean Examples : +* boolean_disjoint : Takes two features and returns (TRUE) if the two geometries do not touch or overlap. + +| Argument| Type | Description| +| ------- |------ | ----------- | +| `feature_1` |Feature | Feature 1 | +| `feature_2` |Feature | Feature 2 | + + +| Return | Type | Description | +| ------- | ------ | ----------- | +| `bool` | bool | Return true or false | + +```python +from geojson import Feature, Point +from turfpy.boolean import boolean_disjoint + +feature_1 = Feature(geometry=Point((19.0760, 72.8777))) +feature_2 = Feature(geometry=Point((29.0760, 72.8777))) +boolean_disjoint(feature_1, feature_2) +``` + +* boolean_intersects : Takes two features and returns (TRUE) if the intersection of the two geometries is NOT an empty set. + +| Argument| Type | Description| +| ------- |------ | ----------- | +| `feature_1` |Feature | Feature 1 | +| `feature_2` |Feature | Feature 2 | + +| Return | Type | Description | +| ------- | ------ | ----------- | +| `bool` | bool | Return true or false | + +```python +from geojson import Feature, Point +from turfpy.boolean import boolean_intersects + +feature_1 = Feature(geometry=Point((19.0760, 72.8777))) +feature_2 = Feature(geometry=Point((29.0760, 72.8777))) +boolean_intersects(feature_1, feature_2) +``` \ No newline at end of file diff --git a/dev_requirements.txt b/dev_requirements.txt index c95e728..d9b4518 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,17 +1,13 @@ #test -pytest -mypy -coverage -black -mypy -pytest-cov -pytest-mypy -pytest-flake8 -isort -Sphinx>=2.4.0 -sphinx-rtd-theme -jupyter-sphinx==0.2.4a1 -ipyleaflet -# optional dependencies required for line_intersect -geopandas -pygeos \ No newline at end of file +pytest==8.3.3 +mypy==1.13.0 +coverage==7.6.4 +black==24.10.0 +pytest-cov==6.0.0 +pytest-mypy==0.10.3 +pytest-flake8==1.2.2 +isort==5.13.2 +Sphinx==8.1.3 +sphinx-rtd-theme==3.0.1 +jupyter-sphinx==0.5.3 +ipyleaflet==0.19.2 \ No newline at end of file diff --git a/docs/source/boolean/boolean_disjoint.rst b/docs/source/boolean/boolean_disjoint.rst new file mode 100644 index 0000000..49805d9 --- /dev/null +++ b/docs/source/boolean/boolean_disjoint.rst @@ -0,0 +1,16 @@ +Boolean Disjoint +================= +Takes two features and returns (TRUE) if the two geometries do not touch or overlap. + +Example +------- + +.. jupyter-execute:: + + from geojson import Feature, Point + from turfpy.boolean import boolean_disjoint + + feature_1 = Feature(geometry=Point((19.0760, 72.8777))) + feature_2 = Feature(geometry=Point((29.0760, 72.8777))) + boolean_disjoint(feature_1, feature_2) + diff --git a/docs/source/boolean/boolean_intersects.rst b/docs/source/boolean/boolean_intersects.rst new file mode 100644 index 0000000..e809e5e --- /dev/null +++ b/docs/source/boolean/boolean_intersects.rst @@ -0,0 +1,16 @@ +Boolean Intersects +================== +Takes two features and returns (TRUE) if the intersection of the two geometries is NOT an empty set. + +Example +------- + +.. jupyter-execute:: + + from geojson import Feature, Point + from turfpy.boolean import boolean_intersects + + feature_1 = Feature(geometry=Point((19.0760, 72.8777))) + feature_2 = Feature(geometry=Point((29.0760, 72.8777))) + boolean_intersects(feature_1, feature_2) + diff --git a/docs/source/feature_conversion/polygon_to_line.rst b/docs/source/feature_conversion/polygon_to_line.rst new file mode 100644 index 0000000..96fa276 --- /dev/null +++ b/docs/source/feature_conversion/polygon_to_line.rst @@ -0,0 +1,46 @@ +Polygon to Line +================ +Takes a Polygon or MultiPolygon and convert it to a line. + +Example +------- + +.. jupyter-execute:: + + from geojson import Feature, Polygon + from turfpy.feature_conversion import polygon_to_line + + feature_1 = Feature(geometry=Polygon([[(2.38, 57.322), (23.194, -20.28), (-120.43, 19.15), (2.38, 57.322)]])) + polygon_to_line(feature_1) + +Interactive Example +------------------- + +.. jupyter-execute:: + + from turfpy.feature_conversion import polygon_to_line + from geojson import Polygon + from geojson import Feature + from ipyleaflet import Map, WidgetControl + from ipywidgets import HTML + + feature_1 = Feature(geometry=Polygon([[(2.38, 57.322), (23.194, -20.28), (-120.43, 19.15), (2.38, 57.322)]])) + + geo_json = polygon_to_line(feature_1) + + m = Map(center=[20.04303061200023, -11.832275390625002], zoom=2) + + m.add_layer(geo_json) + + html = HTML() + html.layout.margin = "0px 20px 10px 20px" + html.value = """ +

Polygon to Line for given geojson

+

{}

+ """.format( + geo_json + ) + control = WidgetControl(widget=html, position="topright") + m.add_control(control) + + m diff --git a/docs/source/index.rst b/docs/source/index.rst index 63b4e28..ca988fe 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -63,6 +63,18 @@ A Python library for performing geospatial data analysis which reimplements `tur Line Offset Voronoi +.. toctree:: + :maxdepth: 1 + :caption: Boolean + + Boolean Disjoint + Boolean Intersects + +.. toctree:: + :maxdepth: 1 + :caption: Feature Conversion + + Polygon To Line .. toctree:: :maxdepth: 1 diff --git a/docs/source/measurements/area.rst b/docs/source/measurements/area.rst index 5af117e..5e6100d 100644 --- a/docs/source/measurements/area.rst +++ b/docs/source/measurements/area.rst @@ -51,9 +51,9 @@ Interactive Example feature_2 = Feature(geometry=geometry_2) feature_collection = FeatureCollection([feature_1, feature_2]) geo_json = GeoJSON(data=feature_collection) - watercolor = basemap_to_tiles(basemaps.Stamen.Watercolor) + mapnik = basemap_to_tiles(basemaps.OpenStreetMap.Mapnik) - m = Map(layers=(watercolor,), center=[20.04303061200023, -11.832275390625002], zoom=2) + m = Map(layers=(mapnik,), center=[20.04303061200023, -11.832275390625002], zoom=2) m.add_layer(geo_json) diff --git a/docs/source/turfpy.boolean.rst b/docs/source/turfpy.boolean.rst new file mode 100644 index 0000000..db97314 --- /dev/null +++ b/docs/source/turfpy.boolean.rst @@ -0,0 +1,8 @@ +turfpy.boolean module +========================= + +.. automodule:: turfpy.boolean + :members: + :undoc-members: + :show-inheritance: + :private-members: diff --git a/docs/source/turfpy.feature_conversion.rst b/docs/source/turfpy.feature_conversion.rst new file mode 100644 index 0000000..3fa22e0 --- /dev/null +++ b/docs/source/turfpy.feature_conversion.rst @@ -0,0 +1,8 @@ +turfpy.turfpy.feature_conversion module +========================= + +.. automodule:: turfpy.turfpy.feature_conversion + :members: + :undoc-members: + :show-inheritance: + :private-members: diff --git a/docs/source/turfpy.random.rst b/docs/source/turfpy.random.rst new file mode 100644 index 0000000..150744d --- /dev/null +++ b/docs/source/turfpy.random.rst @@ -0,0 +1,8 @@ +turfpy.random module +==================== + +.. automodule:: turfpy.random + :members: + :undoc-members: + :show-inheritance: + :private-members: diff --git a/examples/boolean.ipynb b/examples/boolean.ipynb new file mode 100644 index 0000000..9da8fee --- /dev/null +++ b/examples/boolean.ipynb @@ -0,0 +1,77 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Boolean\n", + "This notebook demonstrates all the examples of boolean" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Boolean Disjoint\n", + "Takes two features and returns (TRUE) if the two geometries do not touch or overlap." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from geojson import Feature, Point\n", + "from turfpy.boolean import boolean_disjoint\n", + "\n", + "feature_1 = Feature(geometry=Point((19.0760, 72.8777)))\n", + "feature_2 = Feature(geometry=Point((29.0760, 72.8777)))\n", + "boolean_disjoint(feature_1, feature_2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Boolean Intersects\n", + "Takes two features and returns (TRUE) if the intersection of the two geometries is NOT an empty set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from geojson import Feature, Point\n", + "from turfpy.boolean import boolean_intersects\n", + "\n", + "feature_1 = Feature(geometry=Point((19.0760, 72.8777)))\n", + "feature_2 = Feature(geometry=Point((29.0760, 72.8777)))\n", + "boolean_intersects(feature_1, feature_2)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.10" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/feature_conversion.ipynb b/examples/feature_conversion.ipynb new file mode 100644 index 0000000..767b99a --- /dev/null +++ b/examples/feature_conversion.ipynb @@ -0,0 +1,89 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Feature Conversion\n", + "This notebook demonstrates all the examples of feature conversion" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Polygon To Line\n", + "Takes a Polygon or MultiPolygon and convert it to a line." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d91a3338fe6e44328d770d3a215c8220", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Map(center=[20.04303061200023, -11.832275390625002], controls=(ZoomControl(options=['position', 'zoom_in_text'…" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from turfpy.feature_conversion import polygon_to_line\n", + "from geojson import Polygon\n", + "from geojson import Feature\n", + "from ipyleaflet import Map, WidgetControl\n", + "from ipywidgets import HTML\n", + "\n", + "feature_1 = Feature(geometry=Polygon([[(2.38, 57.322), (23.194, -20.28), (-120.43, 19.15), (2.38, 57.322)]]))\n", + "\n", + "geo_json = polygon_to_line(feature_1)\n", + "\n", + "m = Map(center=[20.04303061200023, -11.832275390625002], zoom=2)\n", + "\n", + "m.add_layer(geo_json)\n", + "\n", + "html = HTML()\n", + "html.layout.margin = \"0px 20px 10px 20px\"\n", + "html.value = \"\"\"\n", + "

Polygon to Line for given geojson

\n", + "

{}

\n", + " \"\"\".format(\n", + " geo_json\n", + ")\n", + "control = WidgetControl(widget=html, position=\"topright\")\n", + "m.add_control(control)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.10" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/feature_conversion.md b/feature_conversion.md new file mode 100644 index 0000000..5b0d45b --- /dev/null +++ b/feature_conversion.md @@ -0,0 +1,20 @@ +## Feature Conversion Examples : +* polygon_to_line : Takes a Polygon or MultiPolygon and convert it to a line. + +| Argument| Type | Description| +| ------- |------ | ----------- | +| `polygon` | Polygon | Multipolygon | a polygon or multipolygon | +| `options` | float | A dict representing additional properties | + + +| Return | Type | Description | +| ------- | ------ | ----------- | +| `object` | Feature | FeatureCollection | Return a feature or feature collection | + +```python +from geojson import Feature, Polygon +from turfpy.feature_conversion import polygon_to_line + +feature_1 = Feature(geometry=Polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]])) +polygon_to_line(feature_1) +``` diff --git a/requirements.txt b/requirements.txt index a94b615..2546740 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ # Core -geojson -shapely -scipy -numpy \ No newline at end of file +geojson==3.1.0 +geopandas==1.0.1 +shapely==2.0.6 +scipy==1.14.1 +numpy==1.26.4 \ No newline at end of file diff --git a/setup.py b/setup.py index 4c98336..f99c525 100644 --- a/setup.py +++ b/setup.py @@ -47,9 +47,10 @@ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ], project_urls={ "Documentation": "https://turfpy.readthedocs.io", diff --git a/tests/boolean_disjoint_test/false/LineString/LineString/LineString-LineString.geojson b/tests/boolean_disjoint_test/false/LineString/LineString/LineString-LineString.geojson new file mode 100644 index 0000000..5ad6f98 --- /dev/null +++ b/tests/boolean_disjoint_test/false/LineString/LineString/LineString-LineString.geojson @@ -0,0 +1,31 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [0, 2], + [12, 2], + [12, 3], + [12, 4] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/LineString/Point/LineString-Point-1.geojson b/tests/boolean_disjoint_test/false/LineString/Point/LineString-Point-1.geojson new file mode 100644 index 0000000..39e7953 --- /dev/null +++ b/tests/boolean_disjoint_test/false/LineString/Point/LineString-Point-1.geojson @@ -0,0 +1,26 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [1, 1] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/LineString/Point/LineString-Point-2.geojson b/tests/boolean_disjoint_test/false/LineString/Point/LineString-Point-2.geojson new file mode 100644 index 0000000..323ca4e --- /dev/null +++ b/tests/boolean_disjoint_test/false/LineString/Point/LineString-Point-2.geojson @@ -0,0 +1,26 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [1, 1.5] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/LineString/Polygon/LineString-In-Polygon.geojson b/tests/boolean_disjoint_test/false/LineString/Polygon/LineString-In-Polygon.geojson new file mode 100644 index 0000000..62d55b6 --- /dev/null +++ b/tests/boolean_disjoint_test/false/LineString/Polygon/LineString-In-Polygon.geojson @@ -0,0 +1,32 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 2.5], + [2, 2.5] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/LineString/Polygon/LineString-Polygon.geojson b/tests/boolean_disjoint_test/false/LineString/Polygon/LineString-Polygon.geojson new file mode 100644 index 0000000..be2b968 --- /dev/null +++ b/tests/boolean_disjoint_test/false/LineString/Polygon/LineString-Polygon.geojson @@ -0,0 +1,34 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [0, 2], + [12, 2], + [12, 3], + [12, 4] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/MultiPoint/LineString/MultiPoint-LineString.geojson b/tests/boolean_disjoint_test/false/MultiPoint/LineString/MultiPoint-LineString.geojson new file mode 100644 index 0000000..f7bc3dd --- /dev/null +++ b/tests/boolean_disjoint_test/false/MultiPoint/LineString/MultiPoint-LineString.geojson @@ -0,0 +1,29 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [1, 1], + [0, 0] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/MultiPoint/MultiPoint/MultiPoint-MultiPoint.geojson b/tests/boolean_disjoint_test/false/MultiPoint/MultiPoint/MultiPoint-MultiPoint.geojson new file mode 100644 index 0000000..5ed4a6d --- /dev/null +++ b/tests/boolean_disjoint_test/false/MultiPoint/MultiPoint/MultiPoint-MultiPoint.geojson @@ -0,0 +1,27 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [0, 0], + [12, 12] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [0, 0], + [12, 12] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/MultiPoint/Polygon/MultiPoint-Polygon.geojson b/tests/boolean_disjoint_test/false/MultiPoint/Polygon/MultiPoint-Polygon.geojson new file mode 100644 index 0000000..da402f3 --- /dev/null +++ b/tests/boolean_disjoint_test/false/MultiPoint/Polygon/MultiPoint-Polygon.geojson @@ -0,0 +1,32 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [-1, 2], + [-2, -2] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/MultiPolygon/Polygon/MultiPolygon-Polygon.geojson b/tests/boolean_disjoint_test/false/MultiPolygon/Polygon/MultiPolygon-Polygon.geojson new file mode 100644 index 0000000..706074d --- /dev/null +++ b/tests/boolean_disjoint_test/false/MultiPolygon/Polygon/MultiPolygon-Polygon.geojson @@ -0,0 +1,52 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "fill": "#ff0000" + }, + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [122.6953125, -19.186677697957833], + [128.759765625, -19.186677697957833], + [128.759765625, -15.28418511407642], + [122.6953125, -15.28418511407642], + [122.6953125, -19.186677697957833] + ] + ], + [ + [ + [123.74999999999999, -25.918526162075153], + [130.25390625, -25.918526162075153], + [130.25390625, -20.715015145512087], + [123.74999999999999, -20.715015145512087], + [123.74999999999999, -25.918526162075153] + ] + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "fill": "#0000ff" + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [119.20166015624999, -22.776181505086495], + [125.09033203124999, -22.776181505086495], + [125.09033203124999, -18.417078658661257], + [119.20166015624999, -18.417078658661257], + [119.20166015624999, -22.776181505086495] + ] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/Point/LineString/Point-LineString-1.geojson b/tests/boolean_disjoint_test/false/Point/LineString/Point-LineString-1.geojson new file mode 100644 index 0000000..b84728a --- /dev/null +++ b/tests/boolean_disjoint_test/false/Point/LineString/Point-LineString-1.geojson @@ -0,0 +1,26 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [1, 1] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/Point/LineString/Point-LineString-2.geojson b/tests/boolean_disjoint_test/false/Point/LineString/Point-LineString-2.geojson new file mode 100644 index 0000000..a937db0 --- /dev/null +++ b/tests/boolean_disjoint_test/false/Point/LineString/Point-LineString-2.geojson @@ -0,0 +1,26 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [1, 1.5] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/Point/LineString/Point-LineString-3.geojson b/tests/boolean_disjoint_test/false/Point/LineString/Point-LineString-3.geojson new file mode 100644 index 0000000..46d3569 --- /dev/null +++ b/tests/boolean_disjoint_test/false/Point/LineString/Point-LineString-3.geojson @@ -0,0 +1,26 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [2.5, 1] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [2, 1], + [3, 1], + [4, 1] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/Point/LineString/Point-LineString-4.geojson b/tests/boolean_disjoint_test/false/Point/LineString/Point-LineString-4.geojson new file mode 100644 index 0000000..cf348f6 --- /dev/null +++ b/tests/boolean_disjoint_test/false/Point/LineString/Point-LineString-4.geojson @@ -0,0 +1,26 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [2.5, 2.5] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [2, 2], + [3, 3], + [4, 4] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/Point/MultiPoint/Point-MultiPoint.geojson b/tests/boolean_disjoint_test/false/Point/MultiPoint/Point-MultiPoint.geojson new file mode 100644 index 0000000..f958a47 --- /dev/null +++ b/tests/boolean_disjoint_test/false/Point/MultiPoint/Point-MultiPoint.geojson @@ -0,0 +1,24 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [1, 1] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [1, 1], + [12, 12] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/Point/Point/Point-Point.geojson b/tests/boolean_disjoint_test/false/Point/Point/Point-Point.geojson new file mode 100644 index 0000000..15b60d6 --- /dev/null +++ b/tests/boolean_disjoint_test/false/Point/Point/Point-Point.geojson @@ -0,0 +1,21 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/Point/Polygon/Point-Polygon-1.geojson b/tests/boolean_disjoint_test/false/Point/Polygon/Point-Polygon-1.geojson new file mode 100644 index 0000000..5ef704e --- /dev/null +++ b/tests/boolean_disjoint_test/false/Point/Polygon/Point-Polygon-1.geojson @@ -0,0 +1,29 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [1, 2.5] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/Point/Polygon/Point-Polygon-2.geojson b/tests/boolean_disjoint_test/false/Point/Polygon/Point-Polygon-2.geojson new file mode 100644 index 0000000..b3a139a --- /dev/null +++ b/tests/boolean_disjoint_test/false/Point/Polygon/Point-Polygon-2.geojson @@ -0,0 +1,29 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [-1, 2] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/Polygon/LineString/Polygon-Containing-Linestring.geojson b/tests/boolean_disjoint_test/false/Polygon/LineString/Polygon-Containing-Linestring.geojson new file mode 100644 index 0000000..a840dc0 --- /dev/null +++ b/tests/boolean_disjoint_test/false/Polygon/LineString/Polygon-Containing-Linestring.geojson @@ -0,0 +1,32 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 2.5], + [2, 2.5] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/Polygon/LineString/Polygon-LineString.geojson b/tests/boolean_disjoint_test/false/Polygon/LineString/Polygon-LineString.geojson new file mode 100644 index 0000000..8332352 --- /dev/null +++ b/tests/boolean_disjoint_test/false/Polygon/LineString/Polygon-LineString.geojson @@ -0,0 +1,34 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [0, 2], + [12, 2], + [12, 3], + [12, 4] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/Polygon/MultiPolygon/Polygon-MultiPolygon.geojson b/tests/boolean_disjoint_test/false/Polygon/MultiPolygon/Polygon-MultiPolygon.geojson new file mode 100644 index 0000000..59b2a57 --- /dev/null +++ b/tests/boolean_disjoint_test/false/Polygon/MultiPolygon/Polygon-MultiPolygon.geojson @@ -0,0 +1,52 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "fill": "#0000ff" + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [119.20166015624999, -22.776181505086495], + [125.09033203124999, -22.776181505086495], + [125.09033203124999, -18.417078658661257], + [119.20166015624999, -18.417078658661257], + [119.20166015624999, -22.776181505086495] + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "fill": "#ff0000" + }, + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [122.6953125, -19.186677697957833], + [128.759765625, -19.186677697957833], + [128.759765625, -15.28418511407642], + [122.6953125, -15.28418511407642], + [122.6953125, -19.186677697957833] + ] + ], + [ + [ + [123.74999999999999, -25.918526162075153], + [130.25390625, -25.918526162075153], + [130.25390625, -20.715015145512087], + [123.74999999999999, -20.715015145512087], + [123.74999999999999, -25.918526162075153] + ] + ] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/Polygon/Point/Polygon-Point.geojson b/tests/boolean_disjoint_test/false/Polygon/Point/Polygon-Point.geojson new file mode 100644 index 0000000..c2131b4 --- /dev/null +++ b/tests/boolean_disjoint_test/false/Polygon/Point/Polygon-Point.geojson @@ -0,0 +1,29 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [1, 2.5] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/Polygon/Polygon/Large-Inside-Small.geojson b/tests/boolean_disjoint_test/false/Polygon/Polygon/Large-Inside-Small.geojson new file mode 100644 index 0000000..9a52b0d --- /dev/null +++ b/tests/boolean_disjoint_test/false/Polygon/Polygon/Large-Inside-Small.geojson @@ -0,0 +1,39 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [19.6875, 34.016241889667015], + [14.765625, 26.745610382199022], + [19.6875, 23.563987128451217], + [23.203125, 26.43122806450644], + [22.148437499999996, 30.44867367928756], + [19.6875, 34.016241889667015] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [18.984375, 40.44694705960048], + [7.03125, 25.48295117535531], + [19.335937499999996, 18.979025953255267], + [31.640625, 24.206889622398023], + [24.960937499999996, 34.88593094075317], + [18.984375, 40.44694705960048] + ] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/Polygon/Polygon/Polygon-Polygon.geojson b/tests/boolean_disjoint_test/false/Polygon/Polygon/Polygon-Polygon.geojson new file mode 100644 index 0000000..70b69b8 --- /dev/null +++ b/tests/boolean_disjoint_test/false/Polygon/Polygon/Polygon-Polygon.geojson @@ -0,0 +1,37 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [-13, -12], + [-13, -13], + [-11, -13], + [-1, 2] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/Polygon/Polygon/Small-Inside-Large.geojson b/tests/boolean_disjoint_test/false/Polygon/Polygon/Small-Inside-Large.geojson new file mode 100644 index 0000000..15e635f --- /dev/null +++ b/tests/boolean_disjoint_test/false/Polygon/Polygon/Small-Inside-Large.geojson @@ -0,0 +1,39 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [18.984375, 40.44694705960048], + [7.03125, 25.48295117535531], + [19.335937499999996, 18.979025953255267], + [31.640625, 24.206889622398023], + [24.960937499999996, 34.88593094075317], + [18.984375, 40.44694705960048] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [19.6875, 34.016241889667015], + [14.765625, 26.745610382199022], + [19.6875, 23.563987128451217], + [23.203125, 26.43122806450644], + [22.148437499999996, 30.44867367928756], + [19.6875, 34.016241889667015] + ] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/false/Polygon/Polygon/issue-1216.geojson b/tests/boolean_disjoint_test/false/Polygon/Polygon/issue-1216.geojson new file mode 100644 index 0000000..be10770 --- /dev/null +++ b/tests/boolean_disjoint_test/false/Polygon/Polygon/issue-1216.geojson @@ -0,0 +1,41 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [6.638240782825051, 46.513552354874435], + [6.638240782825051, 46.52452567471025], + [6.632039186485088, 46.52452567471025], + [6.632039186485088, 46.513552354874435], + [6.638240782825051, 46.513552354874435] + ] + ] + }, + "bbox": [ + 6.632039186485088, 46.513552354874435, 6.638240782825051, 46.52452567471025 + ] + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [6.645459572232596, 46.51709747623775], + [6.645459572232596, 46.52102619404951], + [6.626132904233913, 46.52102619404951], + [6.626132904233913, 46.51709747623775], + [6.645459572232596, 46.51709747623775] + ] + ] + }, + "bbox": [6.626132904233913, 46.51709747623775, 6.645459572232596, 46.52102619404951] + } + ] +} diff --git a/tests/boolean_disjoint_test/true/LineString/LineString/LineString-LineString.geojson b/tests/boolean_disjoint_test/true/LineString/LineString/LineString-LineString.geojson new file mode 100644 index 0000000..6c774ab --- /dev/null +++ b/tests/boolean_disjoint_test/true/LineString/LineString/LineString-LineString.geojson @@ -0,0 +1,31 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [0, 0], + [12, 2], + [12, 3], + [12, 4] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/true/LineString/Point/LineString-Point.geojson b/tests/boolean_disjoint_test/true/LineString/Point/LineString-Point.geojson new file mode 100644 index 0000000..e327ba9 --- /dev/null +++ b/tests/boolean_disjoint_test/true/LineString/Point/LineString-Point.geojson @@ -0,0 +1,26 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/true/LineString/Polygon/LineString-Polygon.geojson b/tests/boolean_disjoint_test/true/LineString/Polygon/LineString-Polygon.geojson new file mode 100644 index 0000000..d34e7dc --- /dev/null +++ b/tests/boolean_disjoint_test/true/LineString/Polygon/LineString-Polygon.geojson @@ -0,0 +1,34 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [0, 0], + [12, 2], + [12, 3], + [12, 4] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/true/MultiPoint/LineString/MultiPoint-LineString.geojson b/tests/boolean_disjoint_test/true/MultiPoint/LineString/MultiPoint-LineString.geojson new file mode 100644 index 0000000..77b1b71 --- /dev/null +++ b/tests/boolean_disjoint_test/true/MultiPoint/LineString/MultiPoint-LineString.geojson @@ -0,0 +1,29 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [2, 2], + [0, 0] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/true/MultiPoint/MultiPoint/MultiPoint-MultiPoint.geojson b/tests/boolean_disjoint_test/true/MultiPoint/MultiPoint/MultiPoint-MultiPoint.geojson new file mode 100644 index 0000000..7e3143a --- /dev/null +++ b/tests/boolean_disjoint_test/true/MultiPoint/MultiPoint/MultiPoint-MultiPoint.geojson @@ -0,0 +1,27 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [0, 0], + [13, 13] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [1, 1], + [12, 12] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/true/MultiPoint/Point/MultiPoint-Point.geojson b/tests/boolean_disjoint_test/true/MultiPoint/Point/MultiPoint-Point.geojson new file mode 100644 index 0000000..eb6182a --- /dev/null +++ b/tests/boolean_disjoint_test/true/MultiPoint/Point/MultiPoint-Point.geojson @@ -0,0 +1,24 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [1, 1], + [12, 12] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/true/MultiPoint/Polygon/MultiPoint-Polygon.geojson b/tests/boolean_disjoint_test/true/MultiPoint/Polygon/MultiPoint-Polygon.geojson new file mode 100644 index 0000000..469de62 --- /dev/null +++ b/tests/boolean_disjoint_test/true/MultiPoint/Polygon/MultiPoint-Polygon.geojson @@ -0,0 +1,32 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [-3, -3], + [-2, -2] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/true/MultiPolygon/Polygon/MultiPolygon-Polygon.geojson b/tests/boolean_disjoint_test/true/MultiPolygon/Polygon/MultiPolygon-Polygon.geojson new file mode 100644 index 0000000..3b2ea41 --- /dev/null +++ b/tests/boolean_disjoint_test/true/MultiPolygon/Polygon/MultiPolygon-Polygon.geojson @@ -0,0 +1,52 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "fill": "#ff0000" + }, + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [122.6953125, -19.186677697957833], + [128.759765625, -19.186677697957833], + [128.759765625, -15.28418511407642], + [122.6953125, -15.28418511407642], + [122.6953125, -19.186677697957833] + ] + ], + [ + [ + [123.74999999999999, -25.918526162075153], + [130.25390625, -25.918526162075153], + [130.25390625, -20.715015145512087], + [123.74999999999999, -20.715015145512087], + [123.74999999999999, -25.918526162075153] + ] + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "fill": "#0000ff" + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [116.98242187499999, -24.647017162630352], + [122.87109375, -24.647017162630352], + [122.87109375, -20.34462694382967], + [116.98242187499999, -20.34462694382967], + [116.98242187499999, -24.647017162630352] + ] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/true/Point/LineString/Point-LineString.geojson b/tests/boolean_disjoint_test/true/Point/LineString/Point-LineString.geojson new file mode 100644 index 0000000..be63516 --- /dev/null +++ b/tests/boolean_disjoint_test/true/Point/LineString/Point-LineString.geojson @@ -0,0 +1,26 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/true/Point/MultiPoint/Point-Multipoint.geojson b/tests/boolean_disjoint_test/true/Point/MultiPoint/Point-Multipoint.geojson new file mode 100644 index 0000000..542362e --- /dev/null +++ b/tests/boolean_disjoint_test/true/Point/MultiPoint/Point-Multipoint.geojson @@ -0,0 +1,24 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [1, 1], + [12, 12] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/true/Point/Point/Point-Point.geojson b/tests/boolean_disjoint_test/true/Point/Point/Point-Point.geojson new file mode 100644 index 0000000..6d022c5 --- /dev/null +++ b/tests/boolean_disjoint_test/true/Point/Point/Point-Point.geojson @@ -0,0 +1,21 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [0, 1] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/true/Point/Polygon/Point-Polygon.geojson b/tests/boolean_disjoint_test/true/Point/Polygon/Point-Polygon.geojson new file mode 100644 index 0000000..c3d4c6d --- /dev/null +++ b/tests/boolean_disjoint_test/true/Point/Polygon/Point-Polygon.geojson @@ -0,0 +1,29 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [1, 1] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/true/Polygon/LineString/Polygon-LineString.geojson b/tests/boolean_disjoint_test/true/Polygon/LineString/Polygon-LineString.geojson new file mode 100644 index 0000000..52b4a49 --- /dev/null +++ b/tests/boolean_disjoint_test/true/Polygon/LineString/Polygon-LineString.geojson @@ -0,0 +1,34 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [0, 0], + [12, 2], + [12, 3], + [12, 4] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/true/Polygon/MultiPolygon/Polygon-MultiPolygon.geojson b/tests/boolean_disjoint_test/true/Polygon/MultiPolygon/Polygon-MultiPolygon.geojson new file mode 100644 index 0000000..d165d17 --- /dev/null +++ b/tests/boolean_disjoint_test/true/Polygon/MultiPolygon/Polygon-MultiPolygon.geojson @@ -0,0 +1,52 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "fill": "#0000ff" + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [116.98242187499999, -24.647017162630352], + [122.87109375, -24.647017162630352], + [122.87109375, -20.34462694382967], + [116.98242187499999, -20.34462694382967], + [116.98242187499999, -24.647017162630352] + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "fill": "#ff0000" + }, + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [122.6953125, -19.186677697957833], + [128.759765625, -19.186677697957833], + [128.759765625, -15.28418511407642], + [122.6953125, -15.28418511407642], + [122.6953125, -19.186677697957833] + ] + ], + [ + [ + [123.74999999999999, -25.918526162075153], + [130.25390625, -25.918526162075153], + [130.25390625, -20.715015145512087], + [123.74999999999999, -20.715015145512087], + [123.74999999999999, -25.918526162075153] + ] + ] + ] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/true/Polygon/Point/Polygon-Point.geojson b/tests/boolean_disjoint_test/true/Polygon/Point/Polygon-Point.geojson new file mode 100644 index 0000000..557d45b --- /dev/null +++ b/tests/boolean_disjoint_test/true/Polygon/Point/Polygon-Point.geojson @@ -0,0 +1,29 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [1, 1] + } + } + ] +} diff --git a/tests/boolean_disjoint_test/true/Polygon/Polygon/Polygon-Polygon.geojson b/tests/boolean_disjoint_test/true/Polygon/Polygon/Polygon-Polygon.geojson new file mode 100644 index 0000000..66d7ab5 --- /dev/null +++ b/tests/boolean_disjoint_test/true/Polygon/Polygon/Polygon-Polygon.geojson @@ -0,0 +1,37 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-11, -12], + [-13, -12], + [-13, -13], + [-11, -13], + [-11, -12] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/false/LineString/LineString/LineString-LineString.geojson b/tests/boolean_intersects_test/false/LineString/LineString/LineString-LineString.geojson new file mode 100644 index 0000000..6c774ab --- /dev/null +++ b/tests/boolean_intersects_test/false/LineString/LineString/LineString-LineString.geojson @@ -0,0 +1,31 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [0, 0], + [12, 2], + [12, 3], + [12, 4] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/false/LineString/Point/LineString-Point.geojson b/tests/boolean_intersects_test/false/LineString/Point/LineString-Point.geojson new file mode 100644 index 0000000..e327ba9 --- /dev/null +++ b/tests/boolean_intersects_test/false/LineString/Point/LineString-Point.geojson @@ -0,0 +1,26 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } + } + ] +} diff --git a/tests/boolean_intersects_test/false/LineString/Polygon/LineString-Polygon.geojson b/tests/boolean_intersects_test/false/LineString/Polygon/LineString-Polygon.geojson new file mode 100644 index 0000000..d34e7dc --- /dev/null +++ b/tests/boolean_intersects_test/false/LineString/Polygon/LineString-Polygon.geojson @@ -0,0 +1,34 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [0, 0], + [12, 2], + [12, 3], + [12, 4] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/false/MultiPoint/LineString/MultiPoint-LineString.geojson b/tests/boolean_intersects_test/false/MultiPoint/LineString/MultiPoint-LineString.geojson new file mode 100644 index 0000000..77b1b71 --- /dev/null +++ b/tests/boolean_intersects_test/false/MultiPoint/LineString/MultiPoint-LineString.geojson @@ -0,0 +1,29 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [2, 2], + [0, 0] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/false/MultiPoint/MultiPoint/MultiPoint-MultiPoint.geojson b/tests/boolean_intersects_test/false/MultiPoint/MultiPoint/MultiPoint-MultiPoint.geojson new file mode 100644 index 0000000..7e3143a --- /dev/null +++ b/tests/boolean_intersects_test/false/MultiPoint/MultiPoint/MultiPoint-MultiPoint.geojson @@ -0,0 +1,27 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [0, 0], + [13, 13] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [1, 1], + [12, 12] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/false/MultiPoint/Point/MultiPoint-Point.geojson b/tests/boolean_intersects_test/false/MultiPoint/Point/MultiPoint-Point.geojson new file mode 100644 index 0000000..eb6182a --- /dev/null +++ b/tests/boolean_intersects_test/false/MultiPoint/Point/MultiPoint-Point.geojson @@ -0,0 +1,24 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [1, 1], + [12, 12] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } + } + ] +} diff --git a/tests/boolean_intersects_test/false/MultiPoint/Polygon/MultiPoint-Polygon.geojson b/tests/boolean_intersects_test/false/MultiPoint/Polygon/MultiPoint-Polygon.geojson new file mode 100644 index 0000000..469de62 --- /dev/null +++ b/tests/boolean_intersects_test/false/MultiPoint/Polygon/MultiPoint-Polygon.geojson @@ -0,0 +1,32 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [-3, -3], + [-2, -2] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/false/MultiPolygon/Polygon/MultiPolygon-Polygon.geojson b/tests/boolean_intersects_test/false/MultiPolygon/Polygon/MultiPolygon-Polygon.geojson new file mode 100644 index 0000000..3b2ea41 --- /dev/null +++ b/tests/boolean_intersects_test/false/MultiPolygon/Polygon/MultiPolygon-Polygon.geojson @@ -0,0 +1,52 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "fill": "#ff0000" + }, + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [122.6953125, -19.186677697957833], + [128.759765625, -19.186677697957833], + [128.759765625, -15.28418511407642], + [122.6953125, -15.28418511407642], + [122.6953125, -19.186677697957833] + ] + ], + [ + [ + [123.74999999999999, -25.918526162075153], + [130.25390625, -25.918526162075153], + [130.25390625, -20.715015145512087], + [123.74999999999999, -20.715015145512087], + [123.74999999999999, -25.918526162075153] + ] + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "fill": "#0000ff" + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [116.98242187499999, -24.647017162630352], + [122.87109375, -24.647017162630352], + [122.87109375, -20.34462694382967], + [116.98242187499999, -20.34462694382967], + [116.98242187499999, -24.647017162630352] + ] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/false/Point/LineString/Point-LineString.geojson b/tests/boolean_intersects_test/false/Point/LineString/Point-LineString.geojson new file mode 100644 index 0000000..be63516 --- /dev/null +++ b/tests/boolean_intersects_test/false/Point/LineString/Point-LineString.geojson @@ -0,0 +1,26 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/false/Point/MultiPoint/Point-Multipoint.geojson b/tests/boolean_intersects_test/false/Point/MultiPoint/Point-Multipoint.geojson new file mode 100644 index 0000000..542362e --- /dev/null +++ b/tests/boolean_intersects_test/false/Point/MultiPoint/Point-Multipoint.geojson @@ -0,0 +1,24 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [1, 1], + [12, 12] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/false/Point/Point/Point-Point.geojson b/tests/boolean_intersects_test/false/Point/Point/Point-Point.geojson new file mode 100644 index 0000000..6d022c5 --- /dev/null +++ b/tests/boolean_intersects_test/false/Point/Point/Point-Point.geojson @@ -0,0 +1,21 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [0, 1] + } + } + ] +} diff --git a/tests/boolean_intersects_test/false/Point/Polygon/Point-Polygon.geojson b/tests/boolean_intersects_test/false/Point/Polygon/Point-Polygon.geojson new file mode 100644 index 0000000..c3d4c6d --- /dev/null +++ b/tests/boolean_intersects_test/false/Point/Polygon/Point-Polygon.geojson @@ -0,0 +1,29 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [1, 1] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/false/Polygon/LineString/Polygon-LineString.geojson b/tests/boolean_intersects_test/false/Polygon/LineString/Polygon-LineString.geojson new file mode 100644 index 0000000..52b4a49 --- /dev/null +++ b/tests/boolean_intersects_test/false/Polygon/LineString/Polygon-LineString.geojson @@ -0,0 +1,34 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [0, 0], + [12, 2], + [12, 3], + [12, 4] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/false/Polygon/MultiPolygon/Polygon-MultiPolygon.geojson b/tests/boolean_intersects_test/false/Polygon/MultiPolygon/Polygon-MultiPolygon.geojson new file mode 100644 index 0000000..d165d17 --- /dev/null +++ b/tests/boolean_intersects_test/false/Polygon/MultiPolygon/Polygon-MultiPolygon.geojson @@ -0,0 +1,52 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "fill": "#0000ff" + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [116.98242187499999, -24.647017162630352], + [122.87109375, -24.647017162630352], + [122.87109375, -20.34462694382967], + [116.98242187499999, -20.34462694382967], + [116.98242187499999, -24.647017162630352] + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "fill": "#ff0000" + }, + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [122.6953125, -19.186677697957833], + [128.759765625, -19.186677697957833], + [128.759765625, -15.28418511407642], + [122.6953125, -15.28418511407642], + [122.6953125, -19.186677697957833] + ] + ], + [ + [ + [123.74999999999999, -25.918526162075153], + [130.25390625, -25.918526162075153], + [130.25390625, -20.715015145512087], + [123.74999999999999, -20.715015145512087], + [123.74999999999999, -25.918526162075153] + ] + ] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/false/Polygon/Point/Polygon-Point.geojson b/tests/boolean_intersects_test/false/Polygon/Point/Polygon-Point.geojson new file mode 100644 index 0000000..557d45b --- /dev/null +++ b/tests/boolean_intersects_test/false/Polygon/Point/Polygon-Point.geojson @@ -0,0 +1,29 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [1, 1] + } + } + ] +} diff --git a/tests/boolean_intersects_test/false/Polygon/Polygon/Polygon-Polygon.geojson b/tests/boolean_intersects_test/false/Polygon/Polygon/Polygon-Polygon.geojson new file mode 100644 index 0000000..66d7ab5 --- /dev/null +++ b/tests/boolean_intersects_test/false/Polygon/Polygon/Polygon-Polygon.geojson @@ -0,0 +1,37 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-11, -12], + [-13, -12], + [-13, -13], + [-11, -13], + [-11, -12] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/LineString/LineString/LineString-LineString.geojson b/tests/boolean_intersects_test/true/LineString/LineString/LineString-LineString.geojson new file mode 100644 index 0000000..5ad6f98 --- /dev/null +++ b/tests/boolean_intersects_test/true/LineString/LineString/LineString-LineString.geojson @@ -0,0 +1,31 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [0, 2], + [12, 2], + [12, 3], + [12, 4] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/LineString/Point/LineString-Point-1.geojson b/tests/boolean_intersects_test/true/LineString/Point/LineString-Point-1.geojson new file mode 100644 index 0000000..39e7953 --- /dev/null +++ b/tests/boolean_intersects_test/true/LineString/Point/LineString-Point-1.geojson @@ -0,0 +1,26 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [1, 1] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/LineString/Point/LineString-Point-2.geojson b/tests/boolean_intersects_test/true/LineString/Point/LineString-Point-2.geojson new file mode 100644 index 0000000..323ca4e --- /dev/null +++ b/tests/boolean_intersects_test/true/LineString/Point/LineString-Point-2.geojson @@ -0,0 +1,26 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [1, 1.5] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/LineString/Polygon/LineString-In-Polygon.geojson b/tests/boolean_intersects_test/true/LineString/Polygon/LineString-In-Polygon.geojson new file mode 100644 index 0000000..62d55b6 --- /dev/null +++ b/tests/boolean_intersects_test/true/LineString/Polygon/LineString-In-Polygon.geojson @@ -0,0 +1,32 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 2.5], + [2, 2.5] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/LineString/Polygon/LineString-Polygon.geojson b/tests/boolean_intersects_test/true/LineString/Polygon/LineString-Polygon.geojson new file mode 100644 index 0000000..be2b968 --- /dev/null +++ b/tests/boolean_intersects_test/true/LineString/Polygon/LineString-Polygon.geojson @@ -0,0 +1,34 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [0, 2], + [12, 2], + [12, 3], + [12, 4] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/MultiPoint/LineString/MultiPoint-LineString.geojson b/tests/boolean_intersects_test/true/MultiPoint/LineString/MultiPoint-LineString.geojson new file mode 100644 index 0000000..f7bc3dd --- /dev/null +++ b/tests/boolean_intersects_test/true/MultiPoint/LineString/MultiPoint-LineString.geojson @@ -0,0 +1,29 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [1, 1], + [0, 0] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/MultiPoint/MultiPoint/MultiPoint-MultiPoint.geojson b/tests/boolean_intersects_test/true/MultiPoint/MultiPoint/MultiPoint-MultiPoint.geojson new file mode 100644 index 0000000..5ed4a6d --- /dev/null +++ b/tests/boolean_intersects_test/true/MultiPoint/MultiPoint/MultiPoint-MultiPoint.geojson @@ -0,0 +1,27 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [0, 0], + [12, 12] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [0, 0], + [12, 12] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/MultiPoint/Polygon/MultiPoint-Polygon.geojson b/tests/boolean_intersects_test/true/MultiPoint/Polygon/MultiPoint-Polygon.geojson new file mode 100644 index 0000000..da402f3 --- /dev/null +++ b/tests/boolean_intersects_test/true/MultiPoint/Polygon/MultiPoint-Polygon.geojson @@ -0,0 +1,32 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [-1, 2], + [-2, -2] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/MultiPolygon/Polygon/MultiPolygon-Polygon.geojson b/tests/boolean_intersects_test/true/MultiPolygon/Polygon/MultiPolygon-Polygon.geojson new file mode 100644 index 0000000..706074d --- /dev/null +++ b/tests/boolean_intersects_test/true/MultiPolygon/Polygon/MultiPolygon-Polygon.geojson @@ -0,0 +1,52 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "fill": "#ff0000" + }, + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [122.6953125, -19.186677697957833], + [128.759765625, -19.186677697957833], + [128.759765625, -15.28418511407642], + [122.6953125, -15.28418511407642], + [122.6953125, -19.186677697957833] + ] + ], + [ + [ + [123.74999999999999, -25.918526162075153], + [130.25390625, -25.918526162075153], + [130.25390625, -20.715015145512087], + [123.74999999999999, -20.715015145512087], + [123.74999999999999, -25.918526162075153] + ] + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "fill": "#0000ff" + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [119.20166015624999, -22.776181505086495], + [125.09033203124999, -22.776181505086495], + [125.09033203124999, -18.417078658661257], + [119.20166015624999, -18.417078658661257], + [119.20166015624999, -22.776181505086495] + ] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/Point/LineString/Point-LineString-1.geojson b/tests/boolean_intersects_test/true/Point/LineString/Point-LineString-1.geojson new file mode 100644 index 0000000..b84728a --- /dev/null +++ b/tests/boolean_intersects_test/true/Point/LineString/Point-LineString-1.geojson @@ -0,0 +1,26 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [1, 1] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/Point/LineString/Point-LineString-2.geojson b/tests/boolean_intersects_test/true/Point/LineString/Point-LineString-2.geojson new file mode 100644 index 0000000..a937db0 --- /dev/null +++ b/tests/boolean_intersects_test/true/Point/LineString/Point-LineString-2.geojson @@ -0,0 +1,26 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [1, 1.5] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [1, 2], + [1, 3], + [1, 4] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/Point/LineString/Point-LineString-3.geojson b/tests/boolean_intersects_test/true/Point/LineString/Point-LineString-3.geojson new file mode 100644 index 0000000..46d3569 --- /dev/null +++ b/tests/boolean_intersects_test/true/Point/LineString/Point-LineString-3.geojson @@ -0,0 +1,26 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [2.5, 1] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [2, 1], + [3, 1], + [4, 1] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/Point/LineString/Point-LineString-4.geojson b/tests/boolean_intersects_test/true/Point/LineString/Point-LineString-4.geojson new file mode 100644 index 0000000..cf348f6 --- /dev/null +++ b/tests/boolean_intersects_test/true/Point/LineString/Point-LineString-4.geojson @@ -0,0 +1,26 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [2.5, 2.5] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 1], + [2, 2], + [3, 3], + [4, 4] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/Point/MultiPoint/Point-MultiPoint.geojson b/tests/boolean_intersects_test/true/Point/MultiPoint/Point-MultiPoint.geojson new file mode 100644 index 0000000..f958a47 --- /dev/null +++ b/tests/boolean_intersects_test/true/Point/MultiPoint/Point-MultiPoint.geojson @@ -0,0 +1,24 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [1, 1] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "MultiPoint", + "coordinates": [ + [1, 1], + [12, 12] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/Point/Point/Point-Point.geojson b/tests/boolean_intersects_test/true/Point/Point/Point-Point.geojson new file mode 100644 index 0000000..15b60d6 --- /dev/null +++ b/tests/boolean_intersects_test/true/Point/Point/Point-Point.geojson @@ -0,0 +1,21 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/Point/Polygon/Point-Polygon-1.geojson b/tests/boolean_intersects_test/true/Point/Polygon/Point-Polygon-1.geojson new file mode 100644 index 0000000..5ef704e --- /dev/null +++ b/tests/boolean_intersects_test/true/Point/Polygon/Point-Polygon-1.geojson @@ -0,0 +1,29 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [1, 2.5] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/Point/Polygon/Point-Polygon-2.geojson b/tests/boolean_intersects_test/true/Point/Polygon/Point-Polygon-2.geojson new file mode 100644 index 0000000..b3a139a --- /dev/null +++ b/tests/boolean_intersects_test/true/Point/Polygon/Point-Polygon-2.geojson @@ -0,0 +1,29 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [-1, 2] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/Polygon/LineString/Polygon-Containing-Linestring.geojson b/tests/boolean_intersects_test/true/Polygon/LineString/Polygon-Containing-Linestring.geojson new file mode 100644 index 0000000..a840dc0 --- /dev/null +++ b/tests/boolean_intersects_test/true/Polygon/LineString/Polygon-Containing-Linestring.geojson @@ -0,0 +1,32 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [1, 2.5], + [2, 2.5] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/Polygon/LineString/Polygon-LineString.geojson b/tests/boolean_intersects_test/true/Polygon/LineString/Polygon-LineString.geojson new file mode 100644 index 0000000..8332352 --- /dev/null +++ b/tests/boolean_intersects_test/true/Polygon/LineString/Polygon-LineString.geojson @@ -0,0 +1,34 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [0, 2], + [12, 2], + [12, 3], + [12, 4] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/Polygon/MultiPolygon/Polygon-MultiPolygon.geojson b/tests/boolean_intersects_test/true/Polygon/MultiPolygon/Polygon-MultiPolygon.geojson new file mode 100644 index 0000000..59b2a57 --- /dev/null +++ b/tests/boolean_intersects_test/true/Polygon/MultiPolygon/Polygon-MultiPolygon.geojson @@ -0,0 +1,52 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "fill": "#0000ff" + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [119.20166015624999, -22.776181505086495], + [125.09033203124999, -22.776181505086495], + [125.09033203124999, -18.417078658661257], + [119.20166015624999, -18.417078658661257], + [119.20166015624999, -22.776181505086495] + ] + ] + } + }, + { + "type": "Feature", + "properties": { + "fill": "#ff0000" + }, + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [122.6953125, -19.186677697957833], + [128.759765625, -19.186677697957833], + [128.759765625, -15.28418511407642], + [122.6953125, -15.28418511407642], + [122.6953125, -19.186677697957833] + ] + ], + [ + [ + [123.74999999999999, -25.918526162075153], + [130.25390625, -25.918526162075153], + [130.25390625, -20.715015145512087], + [123.74999999999999, -20.715015145512087], + [123.74999999999999, -25.918526162075153] + ] + ] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/Polygon/Point/Polygon-Point.geojson b/tests/boolean_intersects_test/true/Polygon/Point/Polygon-Point.geojson new file mode 100644 index 0000000..c2131b4 --- /dev/null +++ b/tests/boolean_intersects_test/true/Polygon/Point/Polygon-Point.geojson @@ -0,0 +1,29 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Point", + "coordinates": [1, 2.5] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/Polygon/Polygon/Large-Inside-Small.geojson b/tests/boolean_intersects_test/true/Polygon/Polygon/Large-Inside-Small.geojson new file mode 100644 index 0000000..9a52b0d --- /dev/null +++ b/tests/boolean_intersects_test/true/Polygon/Polygon/Large-Inside-Small.geojson @@ -0,0 +1,39 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [19.6875, 34.016241889667015], + [14.765625, 26.745610382199022], + [19.6875, 23.563987128451217], + [23.203125, 26.43122806450644], + [22.148437499999996, 30.44867367928756], + [19.6875, 34.016241889667015] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [18.984375, 40.44694705960048], + [7.03125, 25.48295117535531], + [19.335937499999996, 18.979025953255267], + [31.640625, 24.206889622398023], + [24.960937499999996, 34.88593094075317], + [18.984375, 40.44694705960048] + ] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/Polygon/Polygon/Polygon-Polygon.geojson b/tests/boolean_intersects_test/true/Polygon/Polygon/Polygon-Polygon.geojson new file mode 100644 index 0000000..70b69b8 --- /dev/null +++ b/tests/boolean_intersects_test/true/Polygon/Polygon/Polygon-Polygon.geojson @@ -0,0 +1,37 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [-13, -12], + [-13, -13], + [-11, -13], + [-1, 2] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1, 2], + [3, 2], + [3, 3], + [-1, 3], + [-1, 2] + ] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/Polygon/Polygon/Small-Inside-Large.geojson b/tests/boolean_intersects_test/true/Polygon/Polygon/Small-Inside-Large.geojson new file mode 100644 index 0000000..15e635f --- /dev/null +++ b/tests/boolean_intersects_test/true/Polygon/Polygon/Small-Inside-Large.geojson @@ -0,0 +1,39 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [18.984375, 40.44694705960048], + [7.03125, 25.48295117535531], + [19.335937499999996, 18.979025953255267], + [31.640625, 24.206889622398023], + [24.960937499999996, 34.88593094075317], + [18.984375, 40.44694705960048] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [19.6875, 34.016241889667015], + [14.765625, 26.745610382199022], + [19.6875, 23.563987128451217], + [23.203125, 26.43122806450644], + [22.148437499999996, 30.44867367928756], + [19.6875, 34.016241889667015] + ] + ] + } + } + ] +} diff --git a/tests/boolean_intersects_test/true/Polygon/Polygon/issue-1216.geojson b/tests/boolean_intersects_test/true/Polygon/Polygon/issue-1216.geojson new file mode 100644 index 0000000..be10770 --- /dev/null +++ b/tests/boolean_intersects_test/true/Polygon/Polygon/issue-1216.geojson @@ -0,0 +1,41 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [6.638240782825051, 46.513552354874435], + [6.638240782825051, 46.52452567471025], + [6.632039186485088, 46.52452567471025], + [6.632039186485088, 46.513552354874435], + [6.638240782825051, 46.513552354874435] + ] + ] + }, + "bbox": [ + 6.632039186485088, 46.513552354874435, 6.638240782825051, 46.52452567471025 + ] + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [6.645459572232596, 46.51709747623775], + [6.645459572232596, 46.52102619404951], + [6.626132904233913, 46.52102619404951], + [6.626132904233913, 46.51709747623775], + [6.645459572232596, 46.51709747623775] + ] + ] + }, + "bbox": [6.626132904233913, 46.51709747623775, 6.645459572232596, 46.52102619404951] + } + ] +} diff --git a/tests/feature_conversion_polygon_to_line_test/in/geometry-polygon.geojson b/tests/feature_conversion_polygon_to_line_test/in/geometry-polygon.geojson new file mode 100644 index 0000000..401ebe2 --- /dev/null +++ b/tests/feature_conversion_polygon_to_line_test/in/geometry-polygon.geojson @@ -0,0 +1,12 @@ +{ + "type": "Polygon", + "coordinates": [ + [ + [-2.275543, 53.464547], + [-2.275543, 53.489271], + [-2.215118, 53.489271], + [-2.215118, 53.464547], + [-2.275543, 53.464547] + ] + ] +} diff --git a/tests/feature_conversion_polygon_to_line_test/in/multi-polygon-outer-doughnut.geojson b/tests/feature_conversion_polygon_to_line_test/in/multi-polygon-outer-doughnut.geojson new file mode 100644 index 0000000..037a064 --- /dev/null +++ b/tests/feature_conversion_polygon_to_line_test/in/multi-polygon-outer-doughnut.geojson @@ -0,0 +1,44 @@ +{ + "type": "Feature", + "properties": { + "stroke": "#F0F", + "stroke-width": 6 + }, + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [115.927734375, -34.016241889667015], + [134.560546875, -34.016241889667015], + [134.560546875, -16.8886597873816], + [115.927734375, -16.8886597873816], + [115.927734375, -34.016241889667015] + ], + [ + [118.65234374999999, -30.90222470517144], + [131.484375, -30.90222470517144], + [131.484375, -19.808054128088575], + [118.65234374999999, -19.808054128088575], + [118.65234374999999, -30.90222470517144] + ] + ], + [ + [ + [120.9375, -28.998531814051795], + [129.7265625, -28.998531814051795], + [129.7265625, -22.105998799750566], + [120.9375, -22.105998799750566], + [120.9375, -28.998531814051795] + ], + [ + [123.48632812499999, -27.137368359795584], + [127.44140625, -27.137368359795584], + [127.44140625, -24.126701958681668], + [123.48632812499999, -24.126701958681668], + [123.48632812499999, -27.137368359795584] + ] + ] + ] + } +} diff --git a/tests/feature_conversion_polygon_to_line_test/in/multi-polygon-with-holes.geojson b/tests/feature_conversion_polygon_to_line_test/in/multi-polygon-with-holes.geojson new file mode 100644 index 0000000..dd14d7c --- /dev/null +++ b/tests/feature_conversion_polygon_to_line_test/in/multi-polygon-with-holes.geojson @@ -0,0 +1,53 @@ +{ + "type": "Feature", + "properties": { + "stroke": "#F00", + "stroke-width": 6 + }, + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [102, 2], + [103, 2], + [103, 3], + [102, 3], + [102, 2] + ], + [ + [102.227783203125, 2.191238104506552], + [102.227783203125, 2.8223442468940902], + [102.843017578125, 2.8223442468940902], + [102.843017578125, 2.191238104506552], + [102.227783203125, 2.191238104506552] + ] + ], + [ + [ + [100, 0], + [101, 0], + [101, 1], + [100, 1], + [100, 0] + ], + [ + [100.206298828125, 0.2526847277643438], + [100.206298828125, 0.7909904981540058], + [100.8050537109375, 0.7909904981540058], + [100.8050537109375, 0.2526847277643438], + [100.206298828125, 0.2526847277643438] + ] + ], + [ + [ + [101.700439453125, 0.5273363048115169], + [102.645263671875, 0.5273363048115169], + [102.645263671875, 1.3511930983018892], + [101.700439453125, 1.3511930983018892], + [101.700439453125, 0.5273363048115169] + ] + ] + ] + } +} diff --git a/tests/feature_conversion_polygon_to_line_test/in/multi-polygon.geojson b/tests/feature_conversion_polygon_to_line_test/in/multi-polygon.geojson new file mode 100644 index 0000000..d8731f8 --- /dev/null +++ b/tests/feature_conversion_polygon_to_line_test/in/multi-polygon.geojson @@ -0,0 +1,30 @@ +{ + "type": "Feature", + "properties": { + "stroke": "#F00", + "stroke-width": 6 + }, + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [102, 2], + [103, 2], + [103, 3], + [102, 3], + [102, 2] + ] + ], + [ + [ + [100, 0], + [101, 0], + [101, 1], + [100, 1], + [100, 0] + ] + ] + ] + } +} diff --git a/tests/feature_conversion_polygon_to_line_test/in/polygon-with-hole.geojson b/tests/feature_conversion_polygon_to_line_test/in/polygon-with-hole.geojson new file mode 100644 index 0000000..20bb898 --- /dev/null +++ b/tests/feature_conversion_polygon_to_line_test/in/polygon-with-hole.geojson @@ -0,0 +1,26 @@ +{ + "type": "Feature", + "properties": { + "stroke": "#F00", + "stroke-width": 6 + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-2.275543, 53.464547], + [-2.215118, 53.464547], + [-2.215118, 53.489271], + [-2.275543, 53.489271], + [-2.275543, 53.464547] + ], + [ + [-2.261037826538086, 53.47062762161877], + [-2.2293663024902344, 53.47062762161877], + [-2.2293663024902344, 53.48196795587917], + [-2.261037826538086, 53.48196795587917], + [-2.261037826538086, 53.47062762161877] + ] + ] + } +} diff --git a/tests/feature_conversion_polygon_to_line_test/in/polygon.geojson b/tests/feature_conversion_polygon_to_line_test/in/polygon.geojson new file mode 100644 index 0000000..a518e3d --- /dev/null +++ b/tests/feature_conversion_polygon_to_line_test/in/polygon.geojson @@ -0,0 +1,19 @@ +{ + "type": "Feature", + "properties": { + "stroke": "#F00", + "stroke-width": 6 + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-2.275543, 53.464547], + [-2.275543, 53.489271], + [-2.215118, 53.489271], + [-2.215118, 53.464547], + [-2.275543, 53.464547] + ] + ] + } +} diff --git a/tests/feature_conversion_polygon_to_line_test/out/geometry-polygon.geojson b/tests/feature_conversion_polygon_to_line_test/out/geometry-polygon.geojson new file mode 100644 index 0000000..c8c6b04 --- /dev/null +++ b/tests/feature_conversion_polygon_to_line_test/out/geometry-polygon.geojson @@ -0,0 +1,14 @@ +{ + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [-2.275543, 53.464547], + [-2.275543, 53.489271], + [-2.215118, 53.489271], + [-2.215118, 53.464547], + [-2.275543, 53.464547] + ] + } +} diff --git a/tests/feature_conversion_polygon_to_line_test/out/multi-polygon-outer-doughnut.geojson b/tests/feature_conversion_polygon_to_line_test/out/multi-polygon-outer-doughnut.geojson new file mode 100644 index 0000000..11fb7a0 --- /dev/null +++ b/tests/feature_conversion_polygon_to_line_test/out/multi-polygon-outer-doughnut.geojson @@ -0,0 +1,117 @@ +{ + "features": [ + { + "geometry": { + "coordinates": [ + [ + [ + 115.927734, + -34.016242 + ], + [ + 134.560547, + -34.016242 + ], + [ + 134.560547, + -16.88866 + ], + [ + 115.927734, + -16.88866 + ], + [ + 115.927734, + -34.016242 + ] + ], + [ + [ + 118.652344, + -30.902225 + ], + [ + 131.484375, + -30.902225 + ], + [ + 131.484375, + -19.808054 + ], + [ + 118.652344, + -19.808054 + ], + [ + 118.652344, + -30.902225 + ] + ] + ], + "type": "MultiLineString" + }, + "properties": { + "stroke": "#F0F", + "stroke-width": 6 + }, + "type": "Feature" + }, + { + "geometry": { + "coordinates": [ + [ + [ + 120.9375, + -28.998532 + ], + [ + 129.726562, + -28.998532 + ], + [ + 129.726562, + -22.105999 + ], + [ + 120.9375, + -22.105999 + ], + [ + 120.9375, + -28.998532 + ] + ], + [ + [ + 123.486328, + -27.137368 + ], + [ + 127.441406, + -27.137368 + ], + [ + 127.441406, + -24.126702 + ], + [ + 123.486328, + -24.126702 + ], + [ + 123.486328, + -27.137368 + ] + ] + ], + "type": "MultiLineString" + }, + "properties": { + "stroke": "#F0F", + "stroke-width": 6 + }, + "type": "Feature" + } + ], + "type": "FeatureCollection" +} \ No newline at end of file diff --git a/tests/feature_conversion_polygon_to_line_test/out/multi-polygon-with-holes.geojson b/tests/feature_conversion_polygon_to_line_test/out/multi-polygon-with-holes.geojson new file mode 100644 index 0000000..f247759 --- /dev/null +++ b/tests/feature_conversion_polygon_to_line_test/out/multi-polygon-with-holes.geojson @@ -0,0 +1,149 @@ +{ + "features": [ + { + "geometry": { + "coordinates": [ + [ + [ + 102, + 2 + ], + [ + 103, + 2 + ], + [ + 103, + 3 + ], + [ + 102, + 3 + ], + [ + 102, + 2 + ] + ], + [ + [ + 102.227783, + 2.191238 + ], + [ + 102.227783, + 2.822344 + ], + [ + 102.843018, + 2.822344 + ], + [ + 102.843018, + 2.191238 + ], + [ + 102.227783, + 2.191238 + ] + ] + ], + "type": "MultiLineString" + }, + "properties": { + "stroke": "#F00", + "stroke-width": 6 + }, + "type": "Feature" + }, + { + "geometry": { + "coordinates": [ + [ + [ + 100, + 0 + ], + [ + 101, + 0 + ], + [ + 101, + 1 + ], + [ + 100, + 1 + ], + [ + 100, + 0 + ] + ], + [ + [ + 100.206299, + 0.252685 + ], + [ + 100.206299, + 0.79099 + ], + [ + 100.805054, + 0.79099 + ], + [ + 100.805054, + 0.252685 + ], + [ + 100.206299, + 0.252685 + ] + ] + ], + "type": "MultiLineString" + }, + "properties": { + "stroke": "#F00", + "stroke-width": 6 + }, + "type": "Feature" + }, + { + "geometry": { + "coordinates": [ + [ + 101.700439, + 0.527336 + ], + [ + 102.645264, + 0.527336 + ], + [ + 102.645264, + 1.351193 + ], + [ + 101.700439, + 1.351193 + ], + [ + 101.700439, + 0.527336 + ] + ], + "type": "LineString" + }, + "properties": { + "stroke": "#F00", + "stroke-width": 6 + }, + "type": "Feature" + } + ], + "type": "FeatureCollection" +} \ No newline at end of file diff --git a/tests/feature_conversion_polygon_to_line_test/out/multi-polygon.geojson b/tests/feature_conversion_polygon_to_line_test/out/multi-polygon.geojson new file mode 100644 index 0000000..fa82c4d --- /dev/null +++ b/tests/feature_conversion_polygon_to_line_test/out/multi-polygon.geojson @@ -0,0 +1,39 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "stroke": "#F00", + "stroke-width": 6 + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [102, 2], + [103, 2], + [103, 3], + [102, 3], + [102, 2] + ] + } + }, + { + "type": "Feature", + "properties": { + "stroke": "#F00", + "stroke-width": 6 + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [100, 0], + [101, 0], + [101, 1], + [100, 1], + [100, 0] + ] + } + } + ] +} diff --git a/tests/feature_conversion_polygon_to_line_test/out/polygon-with-hole.geojson b/tests/feature_conversion_polygon_to_line_test/out/polygon-with-hole.geojson new file mode 100644 index 0000000..339ea8a --- /dev/null +++ b/tests/feature_conversion_polygon_to_line_test/out/polygon-with-hole.geojson @@ -0,0 +1,56 @@ +{ + "geometry": { + "coordinates": [ + [ + [ + -2.275543, + 53.464547 + ], + [ + -2.215118, + 53.464547 + ], + [ + -2.215118, + 53.489271 + ], + [ + -2.275543, + 53.489271 + ], + [ + -2.275543, + 53.464547 + ] + ], + [ + [ + -2.261038, + 53.470628 + ], + [ + -2.229366, + 53.470628 + ], + [ + -2.229366, + 53.481968 + ], + [ + -2.261038, + 53.481968 + ], + [ + -2.261038, + 53.470628 + ] + ] + ], + "type": "MultiLineString" + }, + "properties": { + "stroke": "#F00", + "stroke-width": 6 + }, + "type": "Feature" +} \ No newline at end of file diff --git a/tests/feature_conversion_polygon_to_line_test/out/polygon.geojson b/tests/feature_conversion_polygon_to_line_test/out/polygon.geojson new file mode 100644 index 0000000..b453fed --- /dev/null +++ b/tests/feature_conversion_polygon_to_line_test/out/polygon.geojson @@ -0,0 +1,17 @@ +{ + "type": "Feature", + "properties": { + "stroke": "#F00", + "stroke-width": 6 + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [-2.275543, 53.464547], + [-2.275543, 53.489271], + [-2.215118, 53.489271], + [-2.215118, 53.464547], + [-2.275543, 53.464547] + ] + } +} diff --git a/tests/test_boolean.py b/tests/test_boolean.py new file mode 100644 index 0000000..c63539e --- /dev/null +++ b/tests/test_boolean.py @@ -0,0 +1,77 @@ +""" +Test module for booleans. +""" + +import glob +import json +import os +import unittest + +from turfpy.boolean import boolean_disjoint, boolean_intersects + + +def load_json_file_sync(filepath): + with open(filepath) as f: + return json.load(f) + + +class TestTurfBooleanDisjoint(unittest.TestCase): + def setUp(self): + self.dirname = os.path.dirname(os.path.abspath(__file__)) + + def test_true_fixtures(self): + for filepath in glob.glob( + os.path.join( + self.dirname, "boolean_disjoint_test", "true", "**", "*.geojson" + ), + recursive=True, + ): + geojson = load_json_file_sync(filepath) + feature1 = geojson["features"][0] + feature2 = geojson["features"][1] + result = boolean_disjoint(feature1, feature2) + self.assertTrue(result, True) + + def test_false_fixtures(self): + for filepath in glob.glob( + os.path.join( + self.dirname, "boolean_disjoint_test", "false", "**", "*.geojson" + ), + recursive=True, + ): + geojson = load_json_file_sync(filepath) + feature1 = geojson["features"][0] + feature2 = geojson["features"][1] + result = boolean_disjoint(feature1, feature2) + self.assertFalse(result, False) + + +class TestTurfBooleanIntersects(unittest.TestCase): + def setUp(self): + self.dirname = os.path.dirname(os.path.abspath(__file__)) + + def test_true_fixtures(self): + for filepath in glob.glob( + os.path.join( + self.dirname, "boolean_intersects_test", "true", "**", "*.geojson" + ), + recursive=True, + ): + geojson = load_json_file_sync(filepath) + feature1 = geojson["features"][0] + feature2 = geojson["features"][1] + result = boolean_intersects(feature1, feature2) + self.assertTrue(result, True) + + def test_false_fixtures(self): + for filepath in glob.glob( + os.path.join( + self.dirname, "boolean_intersects_test", "false", "**", "*.geojson" + ), + recursive=True, + ): + geojson = load_json_file_sync(filepath) + feature1 = geojson["features"][0] + feature2 = geojson["features"][1] + result = boolean_intersects(feature1, feature2) + self.assertFalse(result, False) diff --git a/tests/test_feature_conversion.py b/tests/test_feature_conversion.py new file mode 100644 index 0000000..ba6decd --- /dev/null +++ b/tests/test_feature_conversion.py @@ -0,0 +1,50 @@ +""" +Test module for feature conversions. +""" + +import json +import os +import unittest +from pathlib import Path + +from turfpy.feature_conversion import polygon_to_line + +# Define directories +current_dir = Path(__file__).resolve().parent +directories = { + "in": current_dir / "feature_conversion_polygon_to_line_test" / "in", + "out": current_dir / "feature_conversion_polygon_to_line_test" / "out", +} + +# Load fixtures +fixtures = [] +for filename in os.listdir(directories["in"]): + filepath = directories["in"] / filename + with open(filepath, "r") as file: + geojson = json.load(file) + fixtures.append( + { + "filename": filename, + "name": Path(filename).stem, + "geojson": geojson, + } + ) + + +class TestPolygonToLine(unittest.TestCase): + + def test_polygon_to_linestring(self): + for fixture in fixtures: + name = fixture["name"] + filename = fixture["filename"] + geojson = fixture["geojson"] + + # Perform the conversion + results = polygon_to_line(geojson) + + # Load the expected results + with open(directories["out"] / filename, "r") as file: + expected_results = json.load(file) + + # Assert the results are as expected + self.assertEqual(results, expected_results, name) diff --git a/tests/test_helper.py b/tests/test_helper.py index 46bbd9f..3a86d11 100644 --- a/tests/test_helper.py +++ b/tests/test_helper.py @@ -1,6 +1,7 @@ """ This module will test all functions in helper module. """ + from geojson import Feature, Point, Polygon from turfpy.helper import get_coord, get_coords diff --git a/tests/test_random.py b/tests/test_random.py index c645903..2e53c23 100644 --- a/tests/test_random.py +++ b/tests/test_random.py @@ -1,6 +1,7 @@ """ Test module for randoms. """ + from geojson import Feature, Point from turfpy.measurement import bbox, boolean_point_in_polygon diff --git a/tests/test_transformation.py b/tests/test_transformation.py index a0a6aae..d92f4f1 100644 --- a/tests/test_transformation.py +++ b/tests/test_transformation.py @@ -1,6 +1,7 @@ """ Test module for transformations. """ + from geojson import ( Feature, FeatureCollection, @@ -65,14 +66,7 @@ def test_bbox_clip(): assert clip.type == "Polygon" assert len(clip.coordinates[0]) == 6 assert clip.coordinates == [ - [ - [10.0, 7.777778], - [10.0, 6.0], - [8.0, 4.0], - [2.0, 2.0], - [3.0, 7.0], - [10.0, 7.777778], - ] + [[10.0, 6.0], [10.0, 7.777778], [3.0, 7.0], [2.0, 2.0], [8.0, 4.0], [10.0, 6.0]] ] @@ -114,13 +108,13 @@ def test_intersection(): assert len(inter.coordinates[0]) == 7 assert inter.coordinates == [ [ - [-122.689027, 45.48565], [-122.669906, 45.507309], - [-122.720031, 45.526554], - [-122.64038, 45.553967], - [-122.584762, 45.545509], - [-122.584762, 45.48565], [-122.689027, 45.48565], + [-122.584762, 45.48565], + [-122.584762, 45.545509], + [-122.64038, 45.553967], + [-122.720031, 45.526554], + [-122.669906, 45.507309], ] ] @@ -158,8 +152,8 @@ def test_intersection(): inter = inter.geometry assert inter.type == "GeometryCollection" assert len(inter.geometries) == 2 - assert inter.geometries[0]["type"] == "LineString" - assert inter.geometries[1]["type"] == "Polygon" + assert inter.geometries[0]["type"] == "Polygon" + assert inter.geometries[1]["type"] == "LineString" def test_bezier_spline(): @@ -218,7 +212,6 @@ def test_union(): "geometry": { "coordinates": [ [ - [-82.560024, 35.585153], [-82.560024, 35.594087], [-82.574787, 35.594087], [-82.574787, 35.615581], @@ -227,6 +220,7 @@ def test_union(): [-82.52964, 35.602602], [-82.52964, 35.585153], [-82.560024, 35.585153], + [-82.560024, 35.594087], ] ], "type": "Polygon", @@ -303,15 +297,14 @@ def test_difference(): ) difference_result = difference(f1, f2) - assert difference_result["type"] == "Feature" assert len(difference_result["geometry"]["coordinates"][0]) == 5 assert difference_result["geometry"]["coordinates"][0] == [ - [140.0, -21.0], [141.0, -21.0], [141.0, -26.0], [140.0, -26.0], [140.0, -21.0], + [141.0, -21.0], ] @@ -577,12 +570,12 @@ def test_voronoi(): "coordinates": [ [ [ - [-69.341595, 43.651138], [-69.165621, 44.71768], [-68.778553, 44.742594], [-68.357297, 44.174238], [-68.456663, 42.944], [-69.341595, 43.651138], + [-69.165621, 44.71768], ] ], [ @@ -617,7 +610,6 @@ def test_voronoi(): ], [ [ - [-69.165621, 44.71768], [-69.311112, 44.75806], [-69.803243, 47.636922], [-68.920065, 47.475451], @@ -625,6 +617,7 @@ def test_voronoi(): [-68.528813, 45.10431], [-68.778553, 44.742594], [-69.165621, 44.71768], + [-69.311112, 44.75806], ] ], [ @@ -652,7 +645,6 @@ def test_voronoi(): ], [ [ - [-68.402835, 42.747442], [-68.456663, 42.944], [-68.357297, 44.174238], [-66.60483, 44.375006], @@ -660,6 +652,7 @@ def test_voronoi(): [-66.229319, 43.585762], [-67.709376, 42.399187], [-68.402835, 42.747442], + [-68.456663, 42.944], ] ], [ @@ -674,13 +667,13 @@ def test_voronoi(): ], [ [ - [-69.109818, 49.67141], [-69.13914, 50.232093], [-68.888249, 50.598076], [-68.457587, 50.676396], [-68.091294, 50.63908], [-68.2834, 49.738998], [-69.109818, 49.67141], + [-69.13914, 50.232093], ] ], [ @@ -695,24 +688,24 @@ def test_voronoi(): ], [ [ - [-61.907059, 58.570287], [-61.200486, 57.981275], [-61.176593, 57.41325], [-62.390875, 56.820434], [-63.047906, 57.536916], [-62.523439, 58.587777], [-61.907059, 58.570287], + [-61.200486, 57.981275], ] ], [ [ - [-62.930959, 59.990927], [-62.523439, 58.587777], [-63.047906, 57.536916], [-63.298993, 57.55999], [-64.019466, 58.565766], [-63.816295, 59.184735], [-62.930959, 59.990927], + [-62.523439, 58.587777], ] ], [ @@ -728,7 +721,6 @@ def test_voronoi(): ], [ [ - [-60.700817, 55.29907], [-60.755079, 54.697224], [-60.793568, 54.684065], [-60.798058, 54.684416], @@ -738,6 +730,7 @@ def test_voronoi(): [-62.384722, 56.550471], [-60.758232, 56.25665], [-60.700817, 55.29907], + [-60.755079, 54.697224], ] ], [ @@ -762,23 +755,23 @@ def test_voronoi(): ], [ [ - [-60.904624, 51.240154], [-60.328187, 50.753482], [-62.622199, 50.04518], [-63.291895, 50.029214], [-62.423765, 51.203424], [-61.540015, 51.510769], [-60.904624, 51.240154], + [-60.328187, 50.753482], ] ], [ [ - [-60.793568, 54.684065], [-60.904624, 51.240154], [-61.540015, 51.510769], [-62.829759, 53.070215], [-60.798058, 54.684416], [-60.793568, 54.684065], + [-60.904624, 51.240154], ] ], [ @@ -794,13 +787,13 @@ def test_voronoi(): ], [ [ - [-63.464372, 40.68111], [-64.533301, 40.578529], [-64.713039, 41.271618], [-64.340982, 41.837472], [-64.21284, 41.996761], [-62.593969, 41.868138], [-63.464372, 40.68111], + [-64.533301, 40.578529], ] ], [ @@ -826,33 +819,33 @@ def test_voronoi(): ], [ [ - [-68.357297, 44.174238], [-68.778553, 44.742594], [-68.528813, 45.10431], [-68.131254, 45.163981], [-66.772422, 44.682886], [-66.60483, 44.375006], [-68.357297, 44.174238], + [-68.778553, 44.742594], ] ], [ [ - [-68.672282, 46.987185], [-68.920065, 47.475451], [-67.461655, 48.08959], [-66.689239, 46.131497], [-66.981801, 45.788497], [-67.448546, 45.934443], [-68.672282, 46.987185], + [-68.920065, 47.475451], ] ], [ [ - [-68.528813, 45.10431], [-68.672282, 46.987185], [-67.448546, 45.934443], [-68.131254, 45.163981], [-68.528813, 45.10431], + [-68.672282, 46.987185], ] ], [ @@ -870,11 +863,11 @@ def test_voronoi(): ], [ [ - [-68.888249, 50.598076], [-69.732985, 52.244378], [-68.717465, 52.109978], [-68.457587, 50.676396], [-68.888249, 50.598076], + [-69.732985, 52.244378], ] ], [ @@ -889,44 +882,44 @@ def test_voronoi(): ], [ [ - [-68.787076, 56.055792], [-68.804662, 56.178409], [-68.509799, 56.771456], [-68.370847, 56.712079], [-67.749682, 56.107668], [-67.915551, 55.050079], [-68.787076, 56.055792], + [-68.804662, 56.178409], ] ], [ [ - [-69.068307, 54.980762], [-68.787076, 56.055792], [-67.915551, 55.050079], [-67.862662, 54.865204], [-68.933613, 54.245603], [-69.068307, 54.980762], + [-68.787076, 56.055792], ] ], [ [ - [-69.018096, 54.100934], [-68.933613, 54.245603], [-67.862662, 54.865204], [-66.767766, 54.679264], [-66.750431, 54.63851], [-67.240581, 52.949003], [-69.018096, 54.100934], + [-68.933613, 54.245603], ] ], [ [ - [-68.720108, 57.098347], [-68.801977, 57.941933], [-68.425974, 58.836434], [-67.717239, 57.8765], [-68.593112, 57.006576], [-68.720108, 57.098347], + [-68.801977, 57.941933], ] ], [ @@ -941,18 +934,17 @@ def test_voronoi(): ], [ [ - [-60.59862, 56.828828], [-60.758232, 56.25665], [-62.384722, 56.550471], [-62.390875, 56.820434], [-61.176593, 57.41325], [-60.861104, 57.275846], [-60.59862, 56.828828], + [-60.758232, 56.25665], ] ], [ [ - [-62.390875, 56.820434], [-62.384722, 56.550471], [-62.464923, 55.798318], [-63.444534, 55.587305], @@ -960,11 +952,11 @@ def test_voronoi(): [-63.298993, 57.55999], [-63.047906, 57.536916], [-62.390875, 56.820434], + [-62.384722, 56.550471], ] ], [ [ - [-63.298993, 57.55999], [-64.224386, 57.101556], [-64.662258, 57.024246], [-65.363808, 57.210479], @@ -972,21 +964,21 @@ def test_voronoi(): [-64.500872, 58.53237], [-64.019466, 58.565766], [-63.298993, 57.55999], + [-64.224386, 57.101556], ] ], [ [ - [-64.224386, 57.101556], [-63.444534, 55.587305], [-63.545405, 55.529856], [-64.339978, 55.461772], [-64.662258, 57.024246], [-64.224386, 57.101556], + [-63.444534, 55.587305], ] ], [ [ - [-63.444534, 55.587305], [-62.464923, 55.798318], [-62.461734, 55.793861], [-63.246204, 53.479829], @@ -994,11 +986,11 @@ def test_voronoi(): [-63.630718, 53.58069], [-63.545405, 55.529856], [-63.444534, 55.587305], + [-62.464923, 55.798318], ] ], [ [ - [-68.593112, 57.006576], [-67.717239, 57.8765], [-66.393058, 58.150471], [-66.046137, 57.546222], @@ -1006,6 +998,7 @@ def test_voronoi(): [-68.370847, 56.712079], [-68.509799, 56.771456], [-68.593112, 57.006576], + [-67.717239, 57.8765], ] ], [ @@ -1023,37 +1016,36 @@ def test_voronoi(): ], [ [ - [-63.816295, 59.184735], [-64.019466, 58.565766], [-64.500872, 58.53237], [-65.445288, 59.744365], [-63.816295, 59.184735], + [-64.019466, 58.565766], ] ], [ [ - [-65.572056, 57.342562], [-65.363808, 57.210479], [-65.246275, 55.50073], [-66.522429, 55.40378], [-66.572933, 55.679512], [-65.921232, 57.425878], [-65.572056, 57.342562], + [-65.363808, 57.210479], ] ], [ [ - [-65.363808, 57.210479], [-64.662258, 57.024246], [-64.339978, 55.461772], [-64.726679, 55.159408], [-65.246275, 55.50073], [-65.363808, 57.210479], + [-64.662258, 57.024246], ] ], [ [ - [-65.246275, 55.50073], [-64.726679, 55.159408], [-64.85245, 54.048027], [-65.21253, 53.980132], @@ -1061,43 +1053,43 @@ def test_voronoi(): [-66.767766, 54.679264], [-66.522429, 55.40378], [-65.246275, 55.50073], + [-64.726679, 55.159408], ] ], [ [ - [-64.726679, 55.159408], [-64.339978, 55.461772], [-63.545405, 55.529856], [-63.630718, 53.58069], [-64.501956, 53.809337], [-64.85245, 54.048027], [-64.726679, 55.159408], + [-64.339978, 55.461772], ] ], [ [ - [-67.240581, 52.949003], [-66.750431, 54.63851], [-65.21253, 53.980132], [-66.477256, 52.046803], [-67.155688, 52.599753], [-67.240581, 52.949003], + [-66.750431, 54.63851], ] ], [ [ - [-67.155688, 52.599753], [-66.477256, 52.046803], [-66.390077, 51.885168], [-66.935723, 50.725848], [-67.863057, 50.730188], [-68.524546, 52.11599], [-67.155688, 52.599753], + [-66.477256, 52.046803], ] ], [ [ - [-66.477256, 52.046803], [-65.21253, 53.980132], [-64.85245, 54.048027], [-64.501956, 53.809337], @@ -1105,11 +1097,11 @@ def test_voronoi(): [-66.009697, 51.80042], [-66.390077, 51.885168], [-66.477256, 52.046803], + [-65.21253, 53.980132], ] ], [ [ - [-64.501956, 53.809337], [-63.630718, 53.58069], [-63.291536, 53.375844], [-63.143452, 53.185966], @@ -1117,95 +1109,95 @@ def test_voronoi(): [-64.307805, 52.234171], [-64.98774, 52.362053], [-64.501956, 53.809337], + [-63.630718, 53.58069], ] ], [ [ - [-68.131254, 45.163981], [-67.448546, 45.934443], [-66.981801, 45.788497], [-66.772422, 44.682886], [-68.131254, 45.163981], + [-67.448546, 45.934443], ] ], [ [ - [-62.622199, 50.04518], [-63.000505, 48.748604], [-63.567003, 48.769673], [-63.706995, 48.844798], [-63.955472, 49.577609], [-63.291895, 50.029214], [-62.622199, 50.04518], + [-63.000505, 48.748604], ] ], [ [ - [-63.567003, 48.769673], [-63.000505, 48.748604], [-61.679226, 48.626676], [-62.03623, 46.408914], [-63.293215, 46.516428], [-63.567003, 48.769673], + [-63.000505, 48.748604], ] ], [ [ - [-63.706995, 48.844798], [-63.567003, 48.769673], [-63.293215, 46.516428], [-64.39133, 46.008699], [-65.311425, 47.295289], [-65.41372, 47.682668], [-63.706995, 48.844798], + [-63.567003, 48.769673], ] ], [ [ - [-63.955472, 49.577609], [-63.706995, 48.844798], [-65.41372, 47.682668], [-65.790402, 47.926576], [-64.661564, 50.115186], [-64.482861, 50.201208], [-63.955472, 49.577609], + [-63.706995, 48.844798], ] ], [ [ - [-63.291895, 50.029214], [-63.955472, 49.577609], [-64.482861, 50.201208], [-64.504725, 50.541144], [-63.761308, 51.170749], [-62.423765, 51.203424], [-63.291895, 50.029214], + [-63.955472, 49.577609], ] ], [ [ - [-68.457587, 50.676396], [-68.717465, 52.109978], [-68.524546, 52.11599], [-67.863057, 50.730188], [-68.091294, 50.63908], [-68.457587, 50.676396], + [-68.717465, 52.109978], ] ], [ [ - [-68.091294, 50.63908], [-67.863057, 50.730188], [-66.935723, 50.725848], [-66.660415, 49.378892], [-66.890978, 48.658947], [-68.2834, 49.738998], [-68.091294, 50.63908], + [-67.863057, 50.730188], ] ], [ [ - [-66.935723, 50.725848], [-66.390077, 51.885168], [-66.009697, 51.80042], [-64.743651, 50.815689], @@ -1214,71 +1206,71 @@ def test_voronoi(): [-64.661564, 50.115186], [-66.660415, 49.378892], [-66.935723, 50.725848], + [-66.390077, 51.885168], ] ], [ [ - [-66.046137, 57.546222], [-65.921232, 57.425878], [-66.572933, 55.679512], [-67.191287, 56.006194], [-67.244563, 56.866571], [-66.046137, 57.546222], + [-65.921232, 57.425878], ] ], [ [ - [-63.246204, 53.479829], [-62.461734, 55.793861], [-61.702232, 55.226953], [-63.246204, 53.479829], + [-62.461734, 55.793861], ] ], [ [ - [-63.246204, 53.479829], [-61.702232, 55.226953], [-60.798058, 54.684416], [-62.829759, 53.070215], [-63.143452, 53.185966], [-63.291536, 53.375844], [-63.246204, 53.479829], + [-61.702232, 55.226953], ] ], [ [ - [-62.423765, 51.203424], [-63.761308, 51.170749], [-63.758966, 52.381606], [-63.143452, 53.185966], [-62.829759, 53.070215], [-61.540015, 51.510769], [-62.423765, 51.203424], + [-63.761308, 51.170749], ] ], [ [ - [-63.758966, 52.381606], [-63.761308, 51.170749], [-64.504725, 50.541144], [-64.743651, 50.815689], [-64.307805, 52.234171], [-63.758966, 52.381606], + [-63.761308, 51.170749], ] ], [ [ - [-66.660415, 49.378892], [-64.661564, 50.115186], [-65.790402, 47.926576], [-66.897845, 48.521491], [-66.890978, 48.658947], [-66.660415, 49.378892], + [-64.661564, 50.115186], ] ], [ [ - [-66.897845, 48.521491], [-65.790402, 47.926576], [-65.41372, 47.682668], [-65.311425, 47.295289], @@ -1286,30 +1278,30 @@ def test_voronoi(): [-66.689239, 46.131497], [-67.461655, 48.08959], [-66.897845, 48.521491], + [-65.790402, 47.926576], ] ], [ [ - [-64.743651, 50.815689], [-66.009697, 51.80042], [-64.98774, 52.362053], [-64.307805, 52.234171], [-64.743651, 50.815689], + [-66.009697, 51.80042], ] ], [ [ - [-65.311425, 47.295289], [-64.39133, 46.008699], [-64.414776, 45.922739], [-65.083804, 45.309838], [-66.563924, 46.16575], [-65.311425, 47.295289], + [-64.39133, 46.008699], ] ], [ [ - [-64.39133, 46.008699], [-63.293215, 46.516428], [-62.03623, 46.408914], [-62.02117, 46.392798], @@ -1319,20 +1311,20 @@ def test_voronoi(): [-63.723399, 44.937568], [-64.414776, 45.922739], [-64.39133, 46.008699], + [-63.293215, 46.516428], ] ], [ [ - [-68.370847, 56.712079], [-67.244563, 56.866571], [-67.191287, 56.006194], [-67.749682, 56.107668], [-68.370847, 56.712079], + [-67.244563, 56.866571], ] ], [ [ - [-66.767766, 54.679264], [-67.862662, 54.865204], [-67.915551, 55.050079], [-67.749682, 56.107668], @@ -1340,21 +1332,21 @@ def test_voronoi(): [-66.572933, 55.679512], [-66.522429, 55.40378], [-66.767766, 54.679264], + [-67.862662, 54.865204], ] ], [ [ - [-65.083804, 45.309838], [-64.414776, 45.922739], [-63.723399, 44.937568], [-64.50239, 43.955688], [-65.664771, 44.409635], [-65.083804, 45.309838], + [-64.414776, 45.922739], ] ], [ [ - [-66.563924, 46.16575], [-65.083804, 45.309838], [-65.664771, 44.409635], [-66.192858, 44.031389], @@ -1363,17 +1355,18 @@ def test_voronoi(): [-66.981801, 45.788497], [-66.689239, 46.131497], [-66.563924, 46.16575], + [-65.083804, 45.309838], ] ], [ [ - [-67.545074, 41.475183], [-67.709376, 42.399187], [-66.229319, 43.585762], [-66.052135, 43.378452], [-66.144297, 41.053141], [-66.186908, 41.023722], [-67.545074, 41.475183], + [-67.709376, 42.399187], ] ], [ @@ -1389,7 +1382,6 @@ def test_voronoi(): ], [ [ - [-66.192858, 44.031389], [-65.664771, 44.409635], [-64.50239, 43.955688], [-64.048674, 43.570106], @@ -1398,40 +1390,40 @@ def test_voronoi(): [-66.052135, 43.378452], [-66.229319, 43.585762], [-66.192858, 44.031389], + [-65.664771, 44.409635], ] ], [ [ - [-66.144297, 41.053141], [-66.052135, 43.378452], [-65.935304, 43.289411], [-65.612919, 42.065656], [-65.885626, 41.139652], [-66.144297, 41.053141], + [-66.052135, 43.378452], ] ], [ [ - [-64.713039, 41.271618], [-65.885626, 41.139652], [-65.612919, 42.065656], [-64.340982, 41.837472], [-64.713039, 41.271618], + [-65.885626, 41.139652], ] ], [ [ - [-64.340982, 41.837472], [-65.612919, 42.065656], [-65.935304, 43.289411], [-64.486341, 42.521923], [-64.21284, 41.996761], [-64.340982, 41.837472], + [-65.612919, 42.065656], ] ], [ [ - [-64.21284, 41.996761], [-64.486341, 42.521923], [-64.048674, 43.570106], [-63.806547, 43.665685], @@ -1440,56 +1432,57 @@ def test_voronoi(): [-62.55729, 41.874168], [-62.593969, 41.868138], [-64.21284, 41.996761], + [-64.486341, 42.521923], ] ], [ [ - [-61.782087, 41.657115], [-62.55729, 41.874168], [-63.021562, 43.374746], [-62.105205, 44.113351], [-61.316855, 42.800556], [-61.782087, 41.657115], + [-62.55729, 41.874168], ] ], [ [ - [-63.723399, 44.937568], [-63.624771, 44.843543], [-63.806547, 43.665685], [-64.048674, 43.570106], [-64.50239, 43.955688], [-63.723399, 44.937568], + [-63.624771, 44.843543], ] ], [ [ - [-63.806547, 43.665685], [-63.624771, 44.843543], [-62.989139, 44.665362], [-63.157718, 43.496673], [-63.806547, 43.665685], + [-63.624771, 44.843543], ] ], [ [ - [-62.989139, 44.665362], [-62.255971, 44.797507], [-62.103711, 44.596733], [-62.105205, 44.113351], [-63.021562, 43.374746], [-63.157718, 43.496673], [-62.989139, 44.665362], + [-62.255971, 44.797507], ] ], [ [ - [-62.105205, 44.113351], [-62.103711, 44.596733], [-60.26029, 44.493097], [-61.193774, 42.911554], [-61.316855, 42.800556], [-62.105205, 44.113351], + [-62.103711, 44.596733], ] ], [ diff --git a/turfpy/__init__.py b/turfpy/__init__.py index 4c1d1c3..020cef4 100644 --- a/turfpy/__init__.py +++ b/turfpy/__init__.py @@ -1,3 +1,4 @@ """A Python library for performing geospatial data analysis which reimplements turf.js """ + from .__version__ import __version__ # noqa F401 diff --git a/turfpy/_compact.py b/turfpy/_compact.py index 6fd65ea..d41bfd2 100644 --- a/turfpy/_compact.py +++ b/turfpy/_compact.py @@ -3,6 +3,7 @@ can be used to check whether a dependency is installed or not. """ + HAS_PYGEOS = None HAS_GEOPANDAS = None diff --git a/turfpy/boolean.py b/turfpy/boolean.py new file mode 100644 index 0000000..a09450f --- /dev/null +++ b/turfpy/boolean.py @@ -0,0 +1,279 @@ +""" +This module implements some of the spatial analysis techniques and processes used to +understand the patterns and relationships of geographic features. +This is mainly inspired by turf.js. +link: http://turfjs.org/ +""" + +from geojson import Feature, LineString, Point, Polygon + +from turfpy.feature_conversion import polygon_to_line +from turfpy.measurement import boolean_point_in_polygon +from turfpy.meta import flatten_each +from turfpy.misc import line_intersect + + +def __is_point_on_line(line_string: LineString, point: Point) -> bool: + """ + Determine if point is on a line + + :param line_string: GeoJSON LineString + :type line_string: LineString + :param point: GeoJSON Point + :type point: Point + :returns: True if the point is on the line + :rtype: bool + """ + coordinates = line_string["coordinates"] + pt_coordinates = point["coordinates"] + + for i in range(len(coordinates) - 1): + if __is_point_on_line_segment(coordinates[i], coordinates[i + 1], pt_coordinates): + return True + return False + + +def __is_line_on_line(line_string_1: LineString, line_string_2: LineString) -> bool: + """ + Determine if line is on line + + :param line_string_1: GeoJSON LineString + :type line_string_1: LineString + :param line_string_2: GeoJSON LineString + :type line_string_2: LineString + :returns: True if the line is on the other line + :rtype: bool + """ + do_lines_intersect = line_intersect(line_string_1, line_string_2) + + if len(do_lines_intersect["features"]) > 0: + return True + return False + + +def __is_line_in_poly(polygon: Polygon, line_string: LineString) -> bool: + """ + Determine if line is in a polygon + + + :param polygon: GeoJSON Polygon + :type polygon: Polygon + :param line_string: GeoJSON LineString + :type line_string: LineString + :returns: True if the line is in the polygon + :rtype: bool + """ + for coord in line_string["coordinates"]: + if boolean_point_in_polygon(coord, polygon): + return True + + do_lines_intersect = line_intersect(line_string, polygon_to_line(polygon)) + + if len(do_lines_intersect["features"]) > 0: + return True + + return False + + +def __is_poly_in_poly(feature1: Polygon, feature2: Polygon) -> bool: + """ + Determine if a polygon is in another polygon + + :param feature1: GeoJSON Polygon + :type feature1: Polygon + :param feature2: GeoJSON Polygon + :type feature2: Polygon + :returns: True if the polygon is in the other polygon + :rtype: bool + """ + for coord1 in feature1["coordinates"][0]: + if boolean_point_in_polygon(coord1, feature2): + return True + + for coord2 in feature2["coordinates"][0]: + if boolean_point_in_polygon(coord2, feature1): + return True + + do_lines_intersect = line_intersect( + polygon_to_line(feature1), polygon_to_line(feature2) + ) + + if len(do_lines_intersect["features"]) > 0: + return True + + return False + + +def __is_point_on_line_segment( + line_segment_start: list, line_segment_end: list, point: list +) -> bool: + """ + Determine if point is on a line segment + + :param line_segment_start: start of line segment + :type line_segment_start: list + :param line_segment_end: end of line segment + :type line_segment_end: list + :param point: point to check + :type point: list + :returns: True if point is on the line segment + :rtype: bool + """ + + dxc = point[0] - line_segment_start[0] + dyc = point[1] - line_segment_start[1] + dxl = line_segment_end[0] - line_segment_start[0] + dyl = line_segment_end[1] - line_segment_start[1] + cross = dxc * dyl - dyc * dxl + + if cross != 0: + return False + + if abs(dxl) >= abs(dyl): + if dxl > 0: + return line_segment_start[0] <= point[0] <= line_segment_end[0] + else: + return line_segment_end[0] <= point[0] <= line_segment_start[0] + else: + if dyl > 0: + return line_segment_start[1] <= point[1] <= line_segment_end[1] + else: + return line_segment_end[1] <= point[1] <= line_segment_start[1] + + +def __compare_coords(pair1: list, pair2: list) -> bool: + """ + Compare coordinates to see if they match + + :param pair1: pair of coordinates + :type pair1: list + :param pair2: pair of coordinates + :type pair2: list + :returns: True if the two pairs of coordinates match + :rtype: bool + """ + + return pair1[0] == pair2[0] and pair1[1] == pair2[1] + + +def __disjoint(feature_1: Feature, feature_2: Feature) -> bool: + """ + Disjoint operation for simple Geometries (Point/LineString/Polygon) + + :param feature_1: GeoJSON Feature or Geometry + :type feature_1: Feature + :param feature_2: GeoJSON Feature or Geometry + :type feature_2: Feature + :param ignore_self_intersections: whether to ignore self intersections + :type ignore_self_intersections: bool + :returns: True if the two geometries do not touch or overlap. + :rtype: bool + """ + + geom1_type = feature_1["geometry"]["type"] + geom2_type = feature_2["geometry"]["type"] + + if geom1_type == "Point": + if geom2_type == "Point": + return not __compare_coords( + feature_1["geometry"]["coordinates"], feature_2["geometry"]["coordinates"] + ) + elif geom2_type == "LineString": + return not __is_point_on_line(feature_2["geometry"], feature_1["geometry"]) + elif geom2_type == "Polygon": + return not boolean_point_in_polygon( + feature_1["geometry"], feature_2["geometry"] + ) + + elif geom1_type == "LineString": + if geom2_type == "Point": + return not __is_point_on_line(feature_1["geometry"], feature_2["geometry"]) + elif geom2_type == "LineString": + return not __is_line_on_line(feature_1["geometry"], feature_2["geometry"]) + elif geom2_type == "Polygon": + return not __is_line_in_poly(feature_2["geometry"], feature_1["geometry"]) + + elif geom1_type == "Polygon": + if geom2_type == "Point": + return not boolean_point_in_polygon( + feature_2["geometry"], feature_1["geometry"] + ) + elif geom2_type == "LineString": + return not __is_line_in_poly(feature_1["geometry"], feature_2["geometry"]) + elif geom2_type == "Polygon": + return not __is_poly_in_poly(feature_2["geometry"], feature_1["geometry"]) + + return False + + +def boolean_disjoint(feature_1: Feature, feature_2: Feature) -> bool: + """ + Boolean-disjoint returns (TRUE) if the two geometries do not touch or overlap. + + :param feature_1: GeoJSON Feature or Geometry + :type feature_1: Feature + :param feature_2: GeoJSON Feature or Geometry + :type feature_2: Feature + :returns: True if the two geometries do not touch or overlap. + :rtype: bool + + + Example: + + >>> from turfpy.boolean import boolean_disjoint + >>> from geojson import Feature, Polygon + >>> boolean_disjoint() + + """ + + bool_result = True + + def check_disjoint(flatten1, index1, feature_collection1): + nonlocal bool_result + if not bool_result: + return False + + def inner_check(flatten2, index2, feature_collection2): + nonlocal bool_result + if not bool_result: + return False + bool_result = __disjoint(flatten1, flatten2) + + flatten_each(feature_2, inner_check) + + flatten_each(feature_1, check_disjoint) + + return bool_result + + +def boolean_intersects(feature_1: Feature, feature_2: Feature) -> bool: + """ + Boolean-intersects returns (TRUE) if the intersection of + the two geometries is NOT an empty set. + + :param feature_1: GeoJSON Feature or Geometry + :type feature_1: Feature + :param feature_2: GeoJSON Feature or Geometry + :type feature_2: Feature + :returns: True if the intersection of the two geometries is NOT an empty set. + :rtype: bool + """ + + bool_result = False + + def check_intersection(flatten1, index1, feature_collection1): + nonlocal bool_result + if bool_result: + return True + + def inner_check(flatten2, index2, feature_collection2): + nonlocal bool_result + if bool_result: + return True + bool_result = not boolean_disjoint(flatten1["geometry"], flatten2["geometry"]) + + flatten_each(feature_2, inner_check) + + flatten_each(feature_1, check_intersection) + + return bool_result diff --git a/turfpy/feature_conversion.py b/turfpy/feature_conversion.py new file mode 100644 index 0000000..d79bf7b --- /dev/null +++ b/turfpy/feature_conversion.py @@ -0,0 +1,83 @@ +from geojson import ( + Feature, + FeatureCollection, + LineString, + MultiLineString, + MultiPolygon, + Polygon, +) + +from turfpy.helper import get_geom + + +def __coords_to_line(coords, properties) -> Feature: + """ + Convert a list of coordinates to a line + + :param coords: input coordinates + :param properties: properties + :return: A GeoJSON Feature + """ + if len(coords) > 1: + return Feature(geometry=MultiLineString(coords), properties=properties) + return Feature(geometry=LineString(coords[0]), properties=properties) + + +def __single_polygon_to_line(polygon: Polygon, options=None) -> Feature: + """ + Convert a single polygon to a line + + :param polygon: input polygon + :param options: options + :return: A GeoJSON Feature + """ + if options is None: + options = {} + geom = get_geom(polygon) + coords = geom["coordinates"] + properties = options.get("properties", polygon.get("properties", {})) + return __coords_to_line(coords, properties) + + +def __multi_polygon_to_line( + multi_polygon: MultiPolygon, options=None +) -> FeatureCollection: + """ + Convert a multi polygon to a line + + :param multi_polygon: input multi polygon + :param options: options + :return: A GeoJSON FeatureCollection + """ + if options is None: + options = {} + geom = get_geom(multi_polygon) + coords = geom["coordinates"] + properties = options.get("properties", multi_polygon.get("properties", {})) + lines = [__coords_to_line(coord, properties) for coord in coords] + return FeatureCollection(lines) + + +def polygon_to_line( + polygon: Polygon | MultiPolygon, options=None +) -> Feature | FeatureCollection: + """ + Convert a polygon to line + + :param polygon: input polygon + :param options: options + :return: A GeoJSON Feature or FeatureCollection + """ + + if options is None: + options = {} + geom = get_geom(polygon) + if not options.get("properties") and polygon["type"] == "Feature": + options["properties"] = polygon.get("properties", {}) + + if geom["type"] == "Polygon": + return __single_polygon_to_line(polygon, options) + elif geom["type"] == "MultiPolygon": + return __multi_polygon_to_line(polygon, options) + else: + raise ValueError("invalid polygon") diff --git a/turfpy/helper.py b/turfpy/helper.py index bb82166..1eb1ea8 100644 --- a/turfpy/helper.py +++ b/turfpy/helper.py @@ -85,8 +85,10 @@ def get_coord(coord): raise Exception("coord must be GeoJSON Point or an Array of numbers") -def get_geom(geojson): - """#TODO: Add description""" +def get_geom(geojson: Feature) -> Feature: + """ + Return geometry object from a GeoJSON object. + """ if geojson["type"] == "Feature": return geojson["geometry"] return geojson diff --git a/turfpy/measurement.py b/turfpy/measurement.py index 90746d4..ae7797f 100644 --- a/turfpy/measurement.py +++ b/turfpy/measurement.py @@ -4,11 +4,13 @@ This is mainly inspired by turf.js. link: http://turfjs.org/ """ + import concurrent.futures from functools import partial from math import asin, atan2, cos, degrees, log, pi, pow, radians, sin, sqrt, tan from multiprocessing import Manager -from typing import List, Optional, Union +from multiprocessing.managers import ListProxy +from typing import Optional, Union from geojson import ( Feature, @@ -424,7 +426,7 @@ def destination( # ----------- Centroid --------------# -def centroid(geojson, properties: dict = None) -> Feature: +def centroid(geojson, properties: dict = {}) -> Feature: """ Takes one or more features and calculates the centroid using the mean of all vertices. @@ -1331,7 +1333,7 @@ def points_within_polygon( points = FeatureCollection([points]) manager = Manager() - results: List[dict] = manager.list() + results: ListProxy[dict] = manager.list() part_func = partial( check_each_point, diff --git a/turfpy/misc.py b/turfpy/misc.py index 2b1f69a..6e0dbe6 100644 --- a/turfpy/misc.py +++ b/turfpy/misc.py @@ -3,9 +3,11 @@ analyse geojson linestring. This is mainly inspired by turf.js Misc section. link: http://turfjs.org/ """ + from functools import reduce from typing import List, Union +import geopandas from geojson import ( Feature, FeatureCollection, @@ -17,7 +19,6 @@ ) from shapely.geometry import mapping, shape -import turfpy._compact as compat from turfpy.helper import convert_angle_to_360, get_coord, get_coords, get_type from turfpy.measurement import bearing, destination, distance from turfpy.meta import coord_each, flatten_each @@ -48,19 +49,6 @@ def line_intersect( >>> l2 = Feature(geometry=LineString([[123, -18], [131, -14]])) >>> line_intersect(l1, l2) """ - if not compat.HAS_GEOPANDAS: - raise ImportError( - "line_intersect requires `Spatial indexes` for which it " - "requires `geopandas` and either `rtree` or `pygeos`. " - "See installation instructions at https://geopandas.org/install.html" - ) - elif not compat.HAS_PYGEOS and not compat.HAS_RTREE: - raise ImportError( - "line_intersect requires `Spatial indexes` for which it " - "requires `geopandas` and either `rtree` or `pygeos`. " - "See installation instructions at https://geopandas.org/install.html" - ) - import geopandas # noqa unique = set() results: List[Feature] = [] diff --git a/turfpy/random.py b/turfpy/random.py index bc55541..6ae2cc0 100644 --- a/turfpy/random.py +++ b/turfpy/random.py @@ -4,12 +4,14 @@ This is mainly inspired by turf.js. link: http://turfjs.org/ """ + import random +from typing import Any, Optional from geojson import Feature, FeatureCollection, Point -def random_position(bbox: list = None): +def random_position(bbox: Optional[list[Any]] = None): """ Generates a random position, if bbox provided then the generated position will be in the bbox. @@ -51,7 +53,7 @@ def coord_in_bbox(bbox: list): ] -def random_points(count: int = 1, bbox: list = None) -> FeatureCollection: +def random_points(count: int = 1, bbox: Optional[list[Any]] = None) -> FeatureCollection: """ Generates geojson random points, if bbox provided then the generated points will be in the bbox. diff --git a/turfpy/transformation.py b/turfpy/transformation.py index 2381aab..3860918 100644 --- a/turfpy/transformation.py +++ b/turfpy/transformation.py @@ -4,6 +4,7 @@ This is mainly inspired by turf.js. link: http://turfjs.org/ """ + import copy import itertools import math @@ -18,7 +19,7 @@ from shapely import geometry as geometry from shapely.geometry import LineString as ShapelyLineString from shapely.geometry import MultiPoint, MultiPolygon, Point, mapping, shape -from shapely.ops import cascaded_union, clip_by_rect, polygonize, unary_union +from shapely.ops import clip_by_rect, polygonize, unary_union from turfpy.helper import get_coord, get_coords, get_geom, get_type, length_to_degrees from turfpy.measurement import ( @@ -100,6 +101,26 @@ def bbox_clip(geojson: Feature, bbox: list) -> Feature: return bb_clip +def _enforce_right_hand_rule(geojson_feature: Feature) -> Feature: + """ + Ensure that the polygon follows the right-hand rule for coordinates. + """ + + feature = geojson_feature + + if geojson_feature["type"] == "Polygon": + feature = shape(geojson_feature) + if not feature.exterior.is_ccw: + reversed_coords = feature.exterior.coords[::-1] + polygon = Polygon(reversed_coords) + new_coords = [list(coord) for coord in polygon["coordinates"]] + new_feature = {"type": "Polygon", "coordinates": [new_coords]} + + return new_feature + + return feature + + def intersect(features: Union[List[Feature], FeatureCollection]) -> Feature: """ Takes polygons and finds their intersection @@ -157,6 +178,8 @@ def intersect(features: Union[List[Feature], FeatureCollection]) -> Feature: intersection = mapping(intersection) + intersection = _enforce_right_hand_rule(intersection) + if ( len(intersection.get("coordinates", [])) == 0 and len(intersection.get("geometries", [])) == 0 @@ -280,7 +303,7 @@ def union( if "properties" in f.keys(): properties_list.append(f["properties"]) - result = cascaded_union(shapes) + result = unary_union(shapes) result = mapping(result) properties = merge_dict(properties_list) @@ -322,7 +345,7 @@ def add_edge(edges, edge_points, coords, i, j): edge_points = [] # loop over triangles: # ia, ib, ic = indices of corner points of the triangle - for ia, ib, ic in tri.vertices: + for ia, ib, ic in tri.simplices: pa = coords[ia] pb = coords[ib] pc = coords[ic] @@ -351,7 +374,7 @@ def add_edge(edges, edge_points, coords, i, j): m = geometry.MultiLineString(edge_points) triangles = list(polygonize(m)) - return cascaded_union(triangles), edge_points + return unary_union(triangles), edge_points def get_points(features): @@ -450,7 +473,7 @@ def convex(features: Union[Feature, FeatureCollection]): def dissolve( - features: Union[List[Feature], FeatureCollection], property_name: str = None + features: Union[List[Feature], FeatureCollection], property_name: Optional[str] = None ) -> FeatureCollection: """ Take FeatureCollection or list of features to dissolve based on @@ -564,7 +587,7 @@ def difference(feature_1: Feature, feature_2: Feature) -> Feature: def transform_rotate( feature: Union[List[Feature], FeatureCollection], angle: float, - pivot: list = None, + pivot: Optional[list] = None, mutate: bool = False, ): """ @@ -1058,7 +1081,8 @@ def voronoi( convex_hull = MultiPoint([Point(i) for i in points]).convex_hull.buffer(2) result = MultiPolygon([poly.intersection(convex_hull) for poly in polygonize(lines)]) result = MultiPolygon( - [p for p in result] + [p for p in convex_hull.difference(unary_union(result))] + [p for p in result.geoms] + + [p for p in convex_hull.difference(unary_union(result)).geoms] ) if bbox is not None: w, s, e, n = bbox