rust-geo-python 0.1.6__tar.gz → 0.1.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rust_geo_python-0.1.6 → rust_geo_python-0.1.7}/.github/workflows/CI.yml +49 -31
- {rust_geo_python-0.1.6 → rust_geo_python-0.1.7}/.gitignore +1 -0
- {rust_geo_python-0.1.6 → rust_geo_python-0.1.7}/Cargo.lock +37 -5
- {rust_geo_python-0.1.6 → rust_geo_python-0.1.7}/Cargo.toml +5 -4
- {rust_geo_python-0.1.6 → rust_geo_python-0.1.7}/PKG-INFO +1 -1
- {rust_geo_python-0.1.6 → rust_geo_python-0.1.7}/src/enums.rs +16 -377
- {rust_geo_python-0.1.6 → rust_geo_python-0.1.7}/src/lib.rs +2 -0
- rust_geo_python-0.1.7/src/macros.rs +128 -0
- {rust_geo_python-0.1.6 → rust_geo_python-0.1.7}/LICENSE.txt +0 -0
- {rust_geo_python-0.1.6 → rust_geo_python-0.1.7}/README.md +0 -0
- {rust_geo_python-0.1.6 → rust_geo_python-0.1.7}/pyproject.toml +0 -0
- {rust_geo_python-0.1.6 → rust_geo_python-0.1.7}/src/functions.rs +0 -0
- {rust_geo_python-0.1.6 → rust_geo_python-0.1.7}/src/pyfunctions.rs +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# This file is autogenerated by maturin v1.
|
|
1
|
+
# This file is autogenerated by maturin v1.11.5
|
|
2
2
|
# To update, run
|
|
3
3
|
#
|
|
4
|
-
# maturin generate-ci github
|
|
4
|
+
# maturin generate-ci github --manifest-path Cargo.toml --platform all
|
|
5
5
|
#
|
|
6
6
|
name: CI
|
|
7
7
|
|
|
@@ -36,8 +36,8 @@ jobs:
|
|
|
36
36
|
- runner: ubuntu-22.04
|
|
37
37
|
target: ppc64le
|
|
38
38
|
steps:
|
|
39
|
-
- uses: actions/checkout@
|
|
40
|
-
- uses: actions/setup-python@
|
|
39
|
+
- uses: actions/checkout@v6
|
|
40
|
+
- uses: actions/setup-python@v6
|
|
41
41
|
with:
|
|
42
42
|
python-version: 3.x
|
|
43
43
|
- name: Build wheels
|
|
@@ -55,7 +55,7 @@ jobs:
|
|
|
55
55
|
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
56
56
|
manylinux: auto
|
|
57
57
|
- name: Upload wheels
|
|
58
|
-
uses: actions/upload-artifact@
|
|
58
|
+
uses: actions/upload-artifact@v5
|
|
59
59
|
with:
|
|
60
60
|
name: wheels-linux-${{ matrix.platform.target }}
|
|
61
61
|
path: dist
|
|
@@ -74,8 +74,8 @@ jobs:
|
|
|
74
74
|
- runner: ubuntu-22.04
|
|
75
75
|
target: armv7
|
|
76
76
|
steps:
|
|
77
|
-
- uses: actions/checkout@
|
|
78
|
-
- uses: actions/setup-python@
|
|
77
|
+
- uses: actions/checkout@v6
|
|
78
|
+
- uses: actions/setup-python@v6
|
|
79
79
|
with:
|
|
80
80
|
python-version: 3.x
|
|
81
81
|
- name: Build wheels
|
|
@@ -93,7 +93,7 @@ jobs:
|
|
|
93
93
|
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
94
94
|
manylinux: musllinux_1_2
|
|
95
95
|
- name: Upload wheels
|
|
96
|
-
uses: actions/upload-artifact@
|
|
96
|
+
uses: actions/upload-artifact@v5
|
|
97
97
|
with:
|
|
98
98
|
name: wheels-musllinux-${{ matrix.platform.target }}
|
|
99
99
|
path: dist
|
|
@@ -105,24 +105,29 @@ jobs:
|
|
|
105
105
|
platform:
|
|
106
106
|
- runner: windows-latest
|
|
107
107
|
target: x64
|
|
108
|
+
python_arch: x64
|
|
108
109
|
- runner: windows-latest
|
|
109
110
|
target: x86
|
|
111
|
+
python_arch: x86
|
|
112
|
+
- runner: windows-latest
|
|
113
|
+
target: aarch64
|
|
114
|
+
python_arch: x64
|
|
110
115
|
steps:
|
|
111
|
-
- uses: actions/checkout@
|
|
112
|
-
- uses: actions/setup-python@
|
|
116
|
+
- uses: actions/checkout@v6
|
|
117
|
+
- uses: actions/setup-python@v6
|
|
113
118
|
with:
|
|
114
|
-
python-version: 3.
|
|
115
|
-
architecture: ${{ matrix.platform.
|
|
119
|
+
python-version: 3.13
|
|
120
|
+
architecture: ${{ matrix.platform.python_arch }}
|
|
116
121
|
- name: Build wheels
|
|
117
122
|
uses: PyO3/maturin-action@v1
|
|
118
123
|
with:
|
|
119
124
|
target: ${{ matrix.platform.target }}
|
|
120
125
|
args: --release --out dist
|
|
121
126
|
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
122
|
-
- uses: actions/setup-python@
|
|
127
|
+
- uses: actions/setup-python@v6
|
|
123
128
|
with:
|
|
124
129
|
python-version: 3.13t
|
|
125
|
-
architecture: ${{ matrix.platform.
|
|
130
|
+
architecture: ${{ matrix.platform.python_arch }}
|
|
126
131
|
- name: Build free-threaded wheels
|
|
127
132
|
uses: PyO3/maturin-action@v1
|
|
128
133
|
with:
|
|
@@ -130,7 +135,7 @@ jobs:
|
|
|
130
135
|
args: --release --out dist -i python3.13t
|
|
131
136
|
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
132
137
|
- name: Upload wheels
|
|
133
|
-
uses: actions/upload-artifact@
|
|
138
|
+
uses: actions/upload-artifact@v5
|
|
134
139
|
with:
|
|
135
140
|
name: wheels-windows-${{ matrix.platform.target }}
|
|
136
141
|
path: dist
|
|
@@ -140,13 +145,13 @@ jobs:
|
|
|
140
145
|
strategy:
|
|
141
146
|
matrix:
|
|
142
147
|
platform:
|
|
143
|
-
- runner: macos-15
|
|
148
|
+
- runner: macos-15-intel
|
|
144
149
|
target: x86_64
|
|
145
|
-
- runner: macos-
|
|
150
|
+
- runner: macos-latest
|
|
146
151
|
target: aarch64
|
|
147
152
|
steps:
|
|
148
|
-
- uses: actions/checkout@
|
|
149
|
-
- uses: actions/setup-python@
|
|
153
|
+
- uses: actions/checkout@v6
|
|
154
|
+
- uses: actions/setup-python@v6
|
|
150
155
|
with:
|
|
151
156
|
python-version: 3.x
|
|
152
157
|
- name: Build wheels
|
|
@@ -162,7 +167,7 @@ jobs:
|
|
|
162
167
|
args: --release --out dist -i python3.13t
|
|
163
168
|
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
164
169
|
- name: Upload wheels
|
|
165
|
-
uses: actions/upload-artifact@
|
|
170
|
+
uses: actions/upload-artifact@v5
|
|
166
171
|
with:
|
|
167
172
|
name: wheels-macos-${{ matrix.platform.target }}
|
|
168
173
|
path: dist
|
|
@@ -170,14 +175,14 @@ jobs:
|
|
|
170
175
|
sdist:
|
|
171
176
|
runs-on: ubuntu-latest
|
|
172
177
|
steps:
|
|
173
|
-
- uses: actions/checkout@
|
|
178
|
+
- uses: actions/checkout@v6
|
|
174
179
|
- name: Build sdist
|
|
175
180
|
uses: PyO3/maturin-action@v1
|
|
176
181
|
with:
|
|
177
182
|
command: sdist
|
|
178
183
|
args: --out dist
|
|
179
184
|
- name: Upload sdist
|
|
180
|
-
uses: actions/upload-artifact@
|
|
185
|
+
uses: actions/upload-artifact@v5
|
|
181
186
|
with:
|
|
182
187
|
name: wheels-sdist
|
|
183
188
|
path: dist
|
|
@@ -185,20 +190,33 @@ jobs:
|
|
|
185
190
|
release:
|
|
186
191
|
name: Release
|
|
187
192
|
runs-on: ubuntu-latest
|
|
188
|
-
|
|
189
|
-
#if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
|
|
193
|
+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
|
|
190
194
|
needs: [linux, musllinux, windows, macos, sdist]
|
|
195
|
+
environment:
|
|
196
|
+
# Create this environment in the GitHub repository under Settings -> Environments
|
|
197
|
+
name: release
|
|
191
198
|
permissions:
|
|
192
199
|
# Use to sign the release artifacts
|
|
193
200
|
id-token: write
|
|
194
201
|
# Used to upload release artifacts
|
|
195
202
|
contents: write
|
|
203
|
+
# Used to generate artifact attestation
|
|
204
|
+
attestations: write
|
|
196
205
|
steps:
|
|
197
|
-
- uses: actions/download-artifact@
|
|
206
|
+
- uses: actions/download-artifact@v6
|
|
207
|
+
- name: Generate artifact attestation
|
|
208
|
+
uses: actions/attest-build-provenance@v3
|
|
209
|
+
with:
|
|
210
|
+
subject-path: 'wheels-*/*'
|
|
211
|
+
- name: Install uv
|
|
212
|
+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
213
|
+
uses: astral-sh/setup-uv@v7
|
|
198
214
|
- name: Publish to PyPI
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
215
|
+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
216
|
+
run: uv publish 'wheels-*/*'
|
|
217
|
+
- name: Upload to GitHub Release
|
|
218
|
+
uses: softprops/action-gh-release@v1
|
|
219
|
+
with:
|
|
220
|
+
files: |
|
|
221
|
+
wasm-wheels/*.whl
|
|
222
|
+
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }}
|
|
@@ -29,6 +29,16 @@ version = "1.5.0"
|
|
|
29
29
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
30
30
|
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
|
31
31
|
|
|
32
|
+
[[package]]
|
|
33
|
+
name = "cc"
|
|
34
|
+
version = "1.2.53"
|
|
35
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
36
|
+
checksum = "755d2fce177175ffca841e9a06afdb2c4ab0f593d53b4dee48147dfaade85932"
|
|
37
|
+
dependencies = [
|
|
38
|
+
"find-msvc-tools",
|
|
39
|
+
"shlex",
|
|
40
|
+
]
|
|
41
|
+
|
|
32
42
|
[[package]]
|
|
33
43
|
name = "cfg-if"
|
|
34
44
|
version = "1.0.4"
|
|
@@ -82,6 +92,12 @@ version = "1.0.2"
|
|
|
82
92
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
83
93
|
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
|
84
94
|
|
|
95
|
+
[[package]]
|
|
96
|
+
name = "find-msvc-tools"
|
|
97
|
+
version = "0.1.8"
|
|
98
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
99
|
+
checksum = "8591b0bcc8a98a64310a2fae1bb3e9b8564dd10e381e6e28010fde8e8e8568db"
|
|
100
|
+
|
|
85
101
|
[[package]]
|
|
86
102
|
name = "float_next_after"
|
|
87
103
|
version = "1.0.0"
|
|
@@ -147,9 +163,9 @@ dependencies = [
|
|
|
147
163
|
|
|
148
164
|
[[package]]
|
|
149
165
|
name = "getrandom"
|
|
150
|
-
version = "0.2.
|
|
166
|
+
version = "0.2.17"
|
|
151
167
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
152
|
-
checksum = "
|
|
168
|
+
checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
|
|
153
169
|
dependencies = [
|
|
154
170
|
"cfg-if",
|
|
155
171
|
"libc",
|
|
@@ -314,9 +330,9 @@ dependencies = [
|
|
|
314
330
|
|
|
315
331
|
[[package]]
|
|
316
332
|
name = "ndarray"
|
|
317
|
-
version = "0.17.
|
|
333
|
+
version = "0.17.2"
|
|
318
334
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
319
|
-
checksum = "
|
|
335
|
+
checksum = "520080814a7a6b4a6e9070823bb24b4531daac8c4627e08ba5de8c5ef2f2752d"
|
|
320
336
|
dependencies = [
|
|
321
337
|
"matrixmultiply",
|
|
322
338
|
"num-complex",
|
|
@@ -465,6 +481,7 @@ version = "0.27.2"
|
|
|
465
481
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
466
482
|
checksum = "b455933107de8642b4487ed26d912c2d899dec6114884214a0b3bb3be9261ea6"
|
|
467
483
|
dependencies = [
|
|
484
|
+
"python3-dll-a",
|
|
468
485
|
"target-lexicon",
|
|
469
486
|
]
|
|
470
487
|
|
|
@@ -503,6 +520,15 @@ dependencies = [
|
|
|
503
520
|
"syn",
|
|
504
521
|
]
|
|
505
522
|
|
|
523
|
+
[[package]]
|
|
524
|
+
name = "python3-dll-a"
|
|
525
|
+
version = "0.2.14"
|
|
526
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
527
|
+
checksum = "d381ef313ae70b4da5f95f8a4de773c6aa5cd28f73adec4b4a31df70b66780d8"
|
|
528
|
+
dependencies = [
|
|
529
|
+
"cc",
|
|
530
|
+
]
|
|
531
|
+
|
|
506
532
|
[[package]]
|
|
507
533
|
name = "quote"
|
|
508
534
|
version = "1.0.43"
|
|
@@ -587,7 +613,7 @@ dependencies = [
|
|
|
587
613
|
|
|
588
614
|
[[package]]
|
|
589
615
|
name = "rust-geo-python"
|
|
590
|
-
version = "0.1.
|
|
616
|
+
version = "0.1.7"
|
|
591
617
|
dependencies = [
|
|
592
618
|
"geo",
|
|
593
619
|
"ndarray",
|
|
@@ -639,6 +665,12 @@ dependencies = [
|
|
|
639
665
|
"syn",
|
|
640
666
|
]
|
|
641
667
|
|
|
668
|
+
[[package]]
|
|
669
|
+
name = "shlex"
|
|
670
|
+
version = "1.3.0"
|
|
671
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
672
|
+
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
|
673
|
+
|
|
642
674
|
[[package]]
|
|
643
675
|
name = "sif-itree"
|
|
644
676
|
version = "0.4.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "rust-geo-python"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.7"
|
|
4
4
|
authors = ["plooney"]
|
|
5
5
|
edition = "2024"
|
|
6
6
|
readme = "README.md"
|
|
@@ -10,12 +10,12 @@ name = "rust_geo_python"
|
|
|
10
10
|
crate-type = ["cdylib"]
|
|
11
11
|
|
|
12
12
|
[dependencies]
|
|
13
|
-
pyo3 = { version = "0.27.
|
|
14
|
-
ndarray = {version="0.17.
|
|
13
|
+
pyo3 = { version = "0.27.2", features = ["extension-module", "abi3-py37", "generate-import-lib"] }
|
|
14
|
+
ndarray = {version="0.17.2", features = ["rayon"]}
|
|
15
15
|
numpy = "0.27.1"
|
|
16
16
|
geo = { version = "0.32.0" }
|
|
17
17
|
wkt = "0.14.0"
|
|
18
|
-
wkb = "0.9.
|
|
18
|
+
wkb = "0.9.2"
|
|
19
19
|
|
|
20
20
|
[profile.release]
|
|
21
21
|
lto = true
|
|
@@ -33,3 +33,4 @@ rustflags = [
|
|
|
33
33
|
"-C", "link-arg=-undefined",
|
|
34
34
|
"-C", "link-arg=dynamic_lookup",
|
|
35
35
|
]
|
|
36
|
+
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
use ndarray::parallel::prelude::ParallelIterator;
|
|
2
2
|
use numpy::ToPyArray;
|
|
3
3
|
use numpy::ndarray::{Array1, Array2, Axis};
|
|
4
|
-
use numpy::{
|
|
5
|
-
PyArray1, PyArray2, PyArrayMethods, PyReadonlyArray2, PyUntypedArrayMethods,
|
|
6
|
-
};
|
|
4
|
+
use numpy::{PyArray1, PyArray2, PyArrayMethods, PyReadonlyArray2, PyUntypedArrayMethods};
|
|
7
5
|
|
|
8
6
|
use geo::orient::{Direction, Orient};
|
|
9
7
|
use geo::{
|
|
@@ -326,395 +324,27 @@ impl RustMultiPolygon {
|
|
|
326
324
|
#[pymethods]
|
|
327
325
|
impl Shape {
|
|
328
326
|
fn distance(&self, rhs: &Shape) -> f64 {
|
|
329
|
-
|
|
330
|
-
(Shapes::Point(p), Shapes::Point(q)) => Euclidean.distance(p.as_ref(), q.as_ref()),
|
|
331
|
-
(Shapes::LineString(p), Shapes::Point(q)) => Euclidean.distance(p.as_ref(), q.as_ref()),
|
|
332
|
-
(Shapes::Point(p), Shapes::LineString(q)) => Euclidean.distance(p.as_ref(), q.as_ref()),
|
|
333
|
-
(Shapes::LineString(p), Shapes::LineString(q)) => {
|
|
334
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
335
|
-
}
|
|
336
|
-
(Shapes::MultiLineString(p), Shapes::Point(q)) => {
|
|
337
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
338
|
-
}
|
|
339
|
-
(Shapes::MultiLineString(p), Shapes::LineString(q)) => {
|
|
340
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
341
|
-
}
|
|
342
|
-
(Shapes::MultiLineString(p), Shapes::MultiLineString(q)) => {
|
|
343
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
344
|
-
}
|
|
345
|
-
(Shapes::Point(p), Shapes::MultiLineString(q)) => {
|
|
346
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
347
|
-
}
|
|
348
|
-
(Shapes::LineString(p), Shapes::MultiLineString(q)) => {
|
|
349
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
350
|
-
}
|
|
351
|
-
(Shapes::Polygon(p), Shapes::Point(q)) => Euclidean.distance(p.as_ref(), q.as_ref()),
|
|
352
|
-
(Shapes::Polygon(p), Shapes::LineString(q)) => {
|
|
353
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
354
|
-
}
|
|
355
|
-
(Shapes::Polygon(p), Shapes::MultiLineString(q)) => {
|
|
356
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
357
|
-
}
|
|
358
|
-
(Shapes::Polygon(p), Shapes::Polygon(q)) => Euclidean.distance(p.as_ref(), q.as_ref()),
|
|
359
|
-
(Shapes::Point(p), Shapes::Polygon(q)) => Euclidean.distance(p.as_ref(), q.as_ref()),
|
|
360
|
-
(Shapes::LineString(p), Shapes::Polygon(q)) => {
|
|
361
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
362
|
-
}
|
|
363
|
-
(Shapes::MultiLineString(p), Shapes::Polygon(q)) => {
|
|
364
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
365
|
-
}
|
|
366
|
-
(Shapes::MultiPolygon(p), Shapes::Point(q)) => {
|
|
367
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
368
|
-
}
|
|
369
|
-
(Shapes::MultiPolygon(p), Shapes::LineString(q)) => {
|
|
370
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
371
|
-
}
|
|
372
|
-
(Shapes::MultiPolygon(p), Shapes::MultiLineString(q)) => {
|
|
373
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
374
|
-
}
|
|
375
|
-
(Shapes::MultiPolygon(p), Shapes::Polygon(q)) => {
|
|
376
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
377
|
-
}
|
|
378
|
-
(Shapes::MultiPolygon(p), Shapes::MultiPolygon(q)) => {
|
|
379
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
380
|
-
}
|
|
381
|
-
(Shapes::Point(p), Shapes::MultiPolygon(q)) => {
|
|
382
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
383
|
-
}
|
|
384
|
-
(Shapes::LineString(p), Shapes::MultiPolygon(q)) => {
|
|
385
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
386
|
-
}
|
|
387
|
-
(Shapes::MultiLineString(p), Shapes::MultiPolygon(q)) => {
|
|
388
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
389
|
-
}
|
|
390
|
-
(Shapes::Polygon(p), Shapes::MultiPolygon(q)) => {
|
|
391
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
392
|
-
}
|
|
393
|
-
(Shapes::MultiPoint(p), Shapes::Point(q)) => Euclidean.distance(p.as_ref(), q.as_ref()),
|
|
394
|
-
(Shapes::MultiPoint(p), Shapes::LineString(q)) => {
|
|
395
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
396
|
-
}
|
|
397
|
-
(Shapes::MultiPoint(p), Shapes::MultiLineString(q)) => {
|
|
398
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
399
|
-
}
|
|
400
|
-
(Shapes::MultiPoint(p), Shapes::Polygon(q)) => {
|
|
401
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
402
|
-
}
|
|
403
|
-
(Shapes::MultiPoint(p), Shapes::MultiPolygon(q)) => {
|
|
404
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
405
|
-
}
|
|
406
|
-
(Shapes::MultiPoint(p), Shapes::MultiPoint(q)) => {
|
|
407
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
408
|
-
}
|
|
409
|
-
(Shapes::Point(p), Shapes::MultiPoint(q)) => Euclidean.distance(p.as_ref(), q.as_ref()),
|
|
410
|
-
(Shapes::LineString(p), Shapes::MultiPoint(q)) => {
|
|
411
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
412
|
-
}
|
|
413
|
-
(Shapes::MultiLineString(p), Shapes::MultiPoint(q)) => {
|
|
414
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
415
|
-
}
|
|
416
|
-
(Shapes::Polygon(p), Shapes::MultiPoint(q)) => {
|
|
417
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
418
|
-
}
|
|
419
|
-
(Shapes::MultiPolygon(p), Shapes::MultiPoint(q)) => {
|
|
420
|
-
Euclidean.distance(p.as_ref(), q.as_ref())
|
|
421
|
-
}
|
|
422
|
-
}
|
|
327
|
+
match_shapes_algo!(self, rhs, Euclidean, distance)
|
|
423
328
|
}
|
|
424
329
|
|
|
425
330
|
fn hausdorff_distance(&self, rhs: &Shape) -> f64 {
|
|
426
|
-
|
|
427
|
-
(Shapes::Point(p), Shapes::Point(q)) => p.as_ref().hausdorff_distance(q.as_ref()),
|
|
428
|
-
(Shapes::LineString(p), Shapes::Point(q)) => p.as_ref().hausdorff_distance(q.as_ref()),
|
|
429
|
-
(Shapes::Point(p), Shapes::LineString(q)) => p.as_ref().hausdorff_distance(q.as_ref()),
|
|
430
|
-
(Shapes::LineString(p), Shapes::LineString(q)) => {
|
|
431
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
432
|
-
}
|
|
433
|
-
(Shapes::MultiLineString(p), Shapes::Point(q)) => {
|
|
434
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
435
|
-
}
|
|
436
|
-
(Shapes::MultiLineString(p), Shapes::LineString(q)) => {
|
|
437
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
438
|
-
}
|
|
439
|
-
(Shapes::MultiLineString(p), Shapes::MultiLineString(q)) => {
|
|
440
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
441
|
-
}
|
|
442
|
-
(Shapes::Point(p), Shapes::MultiLineString(q)) => {
|
|
443
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
444
|
-
}
|
|
445
|
-
(Shapes::LineString(p), Shapes::MultiLineString(q)) => {
|
|
446
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
447
|
-
}
|
|
448
|
-
(Shapes::Polygon(p), Shapes::Point(q)) => p.as_ref().hausdorff_distance(q.as_ref()),
|
|
449
|
-
(Shapes::Polygon(p), Shapes::LineString(q)) => {
|
|
450
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
451
|
-
}
|
|
452
|
-
(Shapes::Polygon(p), Shapes::MultiLineString(q)) => {
|
|
453
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
454
|
-
}
|
|
455
|
-
(Shapes::Polygon(p), Shapes::Polygon(q)) => p.as_ref().hausdorff_distance(q.as_ref()),
|
|
456
|
-
(Shapes::Point(p), Shapes::Polygon(q)) => p.as_ref().hausdorff_distance(q.as_ref()),
|
|
457
|
-
(Shapes::LineString(p), Shapes::Polygon(q)) => {
|
|
458
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
459
|
-
}
|
|
460
|
-
(Shapes::MultiLineString(p), Shapes::Polygon(q)) => {
|
|
461
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
462
|
-
}
|
|
463
|
-
(Shapes::MultiPolygon(p), Shapes::Point(q)) => {
|
|
464
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
465
|
-
}
|
|
466
|
-
(Shapes::MultiPolygon(p), Shapes::LineString(q)) => {
|
|
467
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
468
|
-
}
|
|
469
|
-
(Shapes::MultiPolygon(p), Shapes::MultiLineString(q)) => {
|
|
470
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
471
|
-
}
|
|
472
|
-
(Shapes::MultiPolygon(p), Shapes::Polygon(q)) => {
|
|
473
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
474
|
-
}
|
|
475
|
-
(Shapes::MultiPolygon(p), Shapes::MultiPolygon(q)) => {
|
|
476
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
477
|
-
}
|
|
478
|
-
(Shapes::Point(p), Shapes::MultiPolygon(q)) => {
|
|
479
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
480
|
-
}
|
|
481
|
-
(Shapes::LineString(p), Shapes::MultiPolygon(q)) => {
|
|
482
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
483
|
-
}
|
|
484
|
-
(Shapes::MultiLineString(p), Shapes::MultiPolygon(q)) => {
|
|
485
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
486
|
-
}
|
|
487
|
-
(Shapes::Polygon(p), Shapes::MultiPolygon(q)) => {
|
|
488
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
489
|
-
}
|
|
490
|
-
(Shapes::MultiPoint(p), Shapes::Point(q)) => p.as_ref().hausdorff_distance(q.as_ref()),
|
|
491
|
-
(Shapes::MultiPoint(p), Shapes::LineString(q)) => {
|
|
492
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
493
|
-
}
|
|
494
|
-
(Shapes::MultiPoint(p), Shapes::MultiLineString(q)) => {
|
|
495
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
496
|
-
}
|
|
497
|
-
(Shapes::MultiPoint(p), Shapes::Polygon(q)) => {
|
|
498
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
499
|
-
}
|
|
500
|
-
(Shapes::MultiPoint(p), Shapes::MultiPolygon(q)) => {
|
|
501
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
502
|
-
}
|
|
503
|
-
(Shapes::MultiPoint(p), Shapes::MultiPoint(q)) => {
|
|
504
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
505
|
-
}
|
|
506
|
-
(Shapes::Point(p), Shapes::MultiPoint(q)) => p.as_ref().hausdorff_distance(q.as_ref()),
|
|
507
|
-
(Shapes::LineString(p), Shapes::MultiPoint(q)) => {
|
|
508
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
509
|
-
}
|
|
510
|
-
(Shapes::MultiLineString(p), Shapes::MultiPoint(q)) => {
|
|
511
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
512
|
-
}
|
|
513
|
-
(Shapes::Polygon(p), Shapes::MultiPoint(q)) => {
|
|
514
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
515
|
-
}
|
|
516
|
-
(Shapes::MultiPolygon(p), Shapes::MultiPoint(q)) => {
|
|
517
|
-
p.as_ref().hausdorff_distance(q.as_ref())
|
|
518
|
-
}
|
|
519
|
-
}
|
|
331
|
+
match_shapes_method!(self, rhs, hausdorff_distance)
|
|
520
332
|
}
|
|
521
333
|
|
|
522
334
|
fn contains(&self, rhs: &Shape) -> bool {
|
|
523
|
-
|
|
524
|
-
(Shapes::Point(p), Shapes::Point(q)) => p.as_ref().contains(q.as_ref()),
|
|
525
|
-
(Shapes::LineString(p), Shapes::Point(q)) => p.as_ref().contains(q.as_ref()),
|
|
526
|
-
(Shapes::Point(p), Shapes::LineString(q)) => p.as_ref().contains(q.as_ref()),
|
|
527
|
-
(Shapes::LineString(p), Shapes::LineString(q)) => p.as_ref().contains(q.as_ref()),
|
|
528
|
-
(Shapes::MultiLineString(p), Shapes::Point(q)) => p.as_ref().contains(q.as_ref()),
|
|
529
|
-
(Shapes::MultiLineString(p), Shapes::LineString(q)) => p.as_ref().contains(q.as_ref()),
|
|
530
|
-
(Shapes::MultiLineString(p), Shapes::MultiLineString(q)) => {
|
|
531
|
-
p.as_ref().contains(q.as_ref())
|
|
532
|
-
}
|
|
533
|
-
(Shapes::Point(p), Shapes::MultiLineString(q)) => p.as_ref().contains(q.as_ref()),
|
|
534
|
-
(Shapes::LineString(p), Shapes::MultiLineString(q)) => p.as_ref().contains(q.as_ref()),
|
|
535
|
-
(Shapes::Polygon(p), Shapes::Point(q)) => p.as_ref().contains(q.as_ref()),
|
|
536
|
-
(Shapes::Polygon(p), Shapes::LineString(q)) => p.as_ref().contains(q.as_ref()),
|
|
537
|
-
(Shapes::Polygon(p), Shapes::MultiLineString(q)) => p.as_ref().contains(q.as_ref()),
|
|
538
|
-
(Shapes::Polygon(p), Shapes::Polygon(q)) => p.as_ref().contains(q.as_ref()),
|
|
539
|
-
(Shapes::Point(p), Shapes::Polygon(q)) => p.as_ref().contains(q.as_ref()),
|
|
540
|
-
(Shapes::LineString(p), Shapes::Polygon(q)) => p.as_ref().contains(q.as_ref()),
|
|
541
|
-
(Shapes::MultiLineString(p), Shapes::Polygon(q)) => p.as_ref().contains(q.as_ref()),
|
|
542
|
-
(Shapes::MultiPolygon(p), Shapes::Point(q)) => p.as_ref().contains(q.as_ref()),
|
|
543
|
-
(Shapes::MultiPolygon(p), Shapes::LineString(q)) => p.as_ref().contains(q.as_ref()),
|
|
544
|
-
(Shapes::MultiPolygon(p), Shapes::MultiLineString(q)) => {
|
|
545
|
-
p.as_ref().contains(q.as_ref())
|
|
546
|
-
}
|
|
547
|
-
(Shapes::MultiPolygon(p), Shapes::Polygon(q)) => p.as_ref().contains(q.as_ref()),
|
|
548
|
-
(Shapes::MultiPolygon(p), Shapes::MultiPolygon(q)) => p.as_ref().contains(q.as_ref()),
|
|
549
|
-
(Shapes::Point(p), Shapes::MultiPolygon(q)) => p.as_ref().contains(q.as_ref()),
|
|
550
|
-
(Shapes::LineString(p), Shapes::MultiPolygon(q)) => p.as_ref().contains(q.as_ref()),
|
|
551
|
-
(Shapes::MultiLineString(p), Shapes::MultiPolygon(q)) => {
|
|
552
|
-
p.as_ref().contains(q.as_ref())
|
|
553
|
-
}
|
|
554
|
-
(Shapes::Polygon(p), Shapes::MultiPolygon(q)) => p.as_ref().contains(q.as_ref()),
|
|
555
|
-
(Shapes::MultiPoint(p), Shapes::Point(q)) => p.as_ref().contains(q.as_ref()),
|
|
556
|
-
(Shapes::MultiPoint(p), Shapes::LineString(q)) => p.as_ref().contains(q.as_ref()),
|
|
557
|
-
(Shapes::MultiPoint(p), Shapes::MultiLineString(q)) => p.as_ref().contains(q.as_ref()),
|
|
558
|
-
(Shapes::MultiPoint(p), Shapes::Polygon(q)) => p.as_ref().contains(q.as_ref()),
|
|
559
|
-
(Shapes::MultiPoint(p), Shapes::MultiPolygon(q)) => p.as_ref().contains(q.as_ref()),
|
|
560
|
-
(Shapes::MultiPoint(p), Shapes::MultiPoint(q)) => p.as_ref().contains(q.as_ref()),
|
|
561
|
-
(Shapes::Point(p), Shapes::MultiPoint(q)) => p.as_ref().contains(q.as_ref()),
|
|
562
|
-
(Shapes::LineString(p), Shapes::MultiPoint(q)) => p.as_ref().contains(q.as_ref()),
|
|
563
|
-
(Shapes::MultiLineString(p), Shapes::MultiPoint(q)) => p.as_ref().contains(q.as_ref()),
|
|
564
|
-
(Shapes::Polygon(p), Shapes::MultiPoint(q)) => p.as_ref().contains(q.as_ref()),
|
|
565
|
-
(Shapes::MultiPolygon(p), Shapes::MultiPoint(q)) => p.as_ref().contains(q.as_ref()),
|
|
566
|
-
}
|
|
335
|
+
match_shapes_method!(self, rhs, contains)
|
|
567
336
|
}
|
|
568
337
|
|
|
569
338
|
fn contains_properly(&self, rhs: &Shape) -> bool {
|
|
570
|
-
|
|
571
|
-
(Shapes::Point(p), Shapes::Point(q)) => p.as_ref().contains_properly(q.as_ref()),
|
|
572
|
-
(Shapes::LineString(p), Shapes::Point(q)) => p.as_ref().contains_properly(q.as_ref()),
|
|
573
|
-
(Shapes::Point(p), Shapes::LineString(q)) => p.as_ref().contains_properly(q.as_ref()),
|
|
574
|
-
(Shapes::LineString(p), Shapes::LineString(q)) => {
|
|
575
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
576
|
-
}
|
|
577
|
-
(Shapes::MultiLineString(p), Shapes::Point(q)) => {
|
|
578
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
579
|
-
}
|
|
580
|
-
(Shapes::MultiLineString(p), Shapes::LineString(q)) => {
|
|
581
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
582
|
-
}
|
|
583
|
-
(Shapes::MultiLineString(p), Shapes::MultiLineString(q)) => {
|
|
584
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
585
|
-
}
|
|
586
|
-
(Shapes::Point(p), Shapes::MultiLineString(q)) => {
|
|
587
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
588
|
-
}
|
|
589
|
-
(Shapes::LineString(p), Shapes::MultiLineString(q)) => {
|
|
590
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
591
|
-
}
|
|
592
|
-
(Shapes::Polygon(p), Shapes::Point(q)) => p.as_ref().contains_properly(q.as_ref()),
|
|
593
|
-
(Shapes::Polygon(p), Shapes::LineString(q)) => p.as_ref().contains_properly(q.as_ref()),
|
|
594
|
-
(Shapes::Polygon(p), Shapes::MultiLineString(q)) => {
|
|
595
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
596
|
-
}
|
|
597
|
-
(Shapes::Polygon(p), Shapes::Polygon(q)) => p.as_ref().contains_properly(q.as_ref()),
|
|
598
|
-
(Shapes::Point(p), Shapes::Polygon(q)) => p.as_ref().contains_properly(q.as_ref()),
|
|
599
|
-
(Shapes::LineString(p), Shapes::Polygon(q)) => p.as_ref().contains_properly(q.as_ref()),
|
|
600
|
-
(Shapes::MultiLineString(p), Shapes::Polygon(q)) => {
|
|
601
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
602
|
-
}
|
|
603
|
-
(Shapes::MultiPolygon(p), Shapes::Point(q)) => p.as_ref().contains_properly(q.as_ref()),
|
|
604
|
-
(Shapes::MultiPolygon(p), Shapes::LineString(q)) => {
|
|
605
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
606
|
-
}
|
|
607
|
-
(Shapes::MultiPolygon(p), Shapes::MultiLineString(q)) => {
|
|
608
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
609
|
-
}
|
|
610
|
-
(Shapes::MultiPolygon(p), Shapes::Polygon(q)) => {
|
|
611
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
612
|
-
}
|
|
613
|
-
(Shapes::MultiPolygon(p), Shapes::MultiPolygon(q)) => {
|
|
614
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
615
|
-
}
|
|
616
|
-
(Shapes::Point(p), Shapes::MultiPolygon(q)) => p.as_ref().contains_properly(q.as_ref()),
|
|
617
|
-
(Shapes::LineString(p), Shapes::MultiPolygon(q)) => {
|
|
618
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
619
|
-
}
|
|
620
|
-
(Shapes::MultiLineString(p), Shapes::MultiPolygon(q)) => {
|
|
621
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
622
|
-
}
|
|
623
|
-
(Shapes::Polygon(p), Shapes::MultiPolygon(q)) => {
|
|
624
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
625
|
-
}
|
|
626
|
-
(Shapes::MultiPoint(p), Shapes::Point(q)) => p.as_ref().contains_properly(q.as_ref()),
|
|
627
|
-
(Shapes::MultiPoint(p), Shapes::LineString(q)) => {
|
|
628
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
629
|
-
}
|
|
630
|
-
(Shapes::MultiPoint(p), Shapes::MultiLineString(q)) => {
|
|
631
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
632
|
-
}
|
|
633
|
-
(Shapes::MultiPoint(p), Shapes::Polygon(q)) => p.as_ref().contains_properly(q.as_ref()),
|
|
634
|
-
(Shapes::MultiPoint(p), Shapes::MultiPolygon(q)) => {
|
|
635
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
636
|
-
}
|
|
637
|
-
(Shapes::MultiPoint(p), Shapes::MultiPoint(q)) => {
|
|
638
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
639
|
-
}
|
|
640
|
-
(Shapes::Point(p), Shapes::MultiPoint(q)) => p.as_ref().contains_properly(q.as_ref()),
|
|
641
|
-
(Shapes::LineString(p), Shapes::MultiPoint(q)) => {
|
|
642
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
643
|
-
}
|
|
644
|
-
(Shapes::MultiLineString(p), Shapes::MultiPoint(q)) => {
|
|
645
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
646
|
-
}
|
|
647
|
-
(Shapes::Polygon(p), Shapes::MultiPoint(q)) => p.as_ref().contains_properly(q.as_ref()),
|
|
648
|
-
(Shapes::MultiPolygon(p), Shapes::MultiPoint(q)) => {
|
|
649
|
-
p.as_ref().contains_properly(q.as_ref())
|
|
650
|
-
}
|
|
651
|
-
}
|
|
339
|
+
match_shapes_method!(self, rhs, contains_properly)
|
|
652
340
|
}
|
|
653
341
|
|
|
654
342
|
fn intersects(&self, rhs: &Shape) -> bool {
|
|
655
|
-
|
|
656
|
-
(Shapes::Point(p), Shapes::Point(q)) => p.as_ref().intersects(q.as_ref()),
|
|
657
|
-
(Shapes::LineString(p), Shapes::Point(q)) => p.as_ref().intersects(q.as_ref()),
|
|
658
|
-
(Shapes::Point(p), Shapes::LineString(q)) => p.as_ref().intersects(q.as_ref()),
|
|
659
|
-
(Shapes::LineString(p), Shapes::LineString(q)) => p.as_ref().intersects(q.as_ref()),
|
|
660
|
-
(Shapes::MultiLineString(p), Shapes::Point(q)) => p.as_ref().intersects(q.as_ref()),
|
|
661
|
-
(Shapes::MultiLineString(p), Shapes::LineString(q)) => {
|
|
662
|
-
p.as_ref().intersects(q.as_ref())
|
|
663
|
-
}
|
|
664
|
-
(Shapes::MultiLineString(p), Shapes::MultiLineString(q)) => {
|
|
665
|
-
p.as_ref().intersects(q.as_ref())
|
|
666
|
-
}
|
|
667
|
-
(Shapes::Point(p), Shapes::MultiLineString(q)) => p.as_ref().intersects(q.as_ref()),
|
|
668
|
-
(Shapes::LineString(p), Shapes::MultiLineString(q)) => {
|
|
669
|
-
p.as_ref().intersects(q.as_ref())
|
|
670
|
-
}
|
|
671
|
-
(Shapes::Polygon(p), Shapes::Point(q)) => p.as_ref().intersects(q.as_ref()),
|
|
672
|
-
(Shapes::Polygon(p), Shapes::LineString(q)) => p.as_ref().intersects(q.as_ref()),
|
|
673
|
-
(Shapes::Polygon(p), Shapes::MultiLineString(q)) => p.as_ref().intersects(q.as_ref()),
|
|
674
|
-
(Shapes::Polygon(p), Shapes::Polygon(q)) => p.as_ref().intersects(q.as_ref()),
|
|
675
|
-
(Shapes::Point(p), Shapes::Polygon(q)) => p.as_ref().intersects(q.as_ref()),
|
|
676
|
-
(Shapes::LineString(p), Shapes::Polygon(q)) => p.as_ref().intersects(q.as_ref()),
|
|
677
|
-
(Shapes::MultiLineString(p), Shapes::Polygon(q)) => p.as_ref().intersects(q.as_ref()),
|
|
678
|
-
(Shapes::MultiPolygon(p), Shapes::Point(q)) => p.as_ref().intersects(q.as_ref()),
|
|
679
|
-
(Shapes::MultiPolygon(p), Shapes::LineString(q)) => p.as_ref().intersects(q.as_ref()),
|
|
680
|
-
(Shapes::MultiPolygon(p), Shapes::MultiLineString(q)) => {
|
|
681
|
-
p.as_ref().intersects(q.as_ref())
|
|
682
|
-
}
|
|
683
|
-
(Shapes::MultiPolygon(p), Shapes::Polygon(q)) => p.as_ref().intersects(q.as_ref()),
|
|
684
|
-
(Shapes::MultiPolygon(p), Shapes::MultiPolygon(q)) => p.as_ref().intersects(q.as_ref()),
|
|
685
|
-
(Shapes::Point(p), Shapes::MultiPolygon(q)) => p.as_ref().intersects(q.as_ref()),
|
|
686
|
-
(Shapes::LineString(p), Shapes::MultiPolygon(q)) => p.as_ref().intersects(q.as_ref()),
|
|
687
|
-
(Shapes::MultiLineString(p), Shapes::MultiPolygon(q)) => {
|
|
688
|
-
p.as_ref().intersects(q.as_ref())
|
|
689
|
-
}
|
|
690
|
-
(Shapes::Polygon(p), Shapes::MultiPolygon(q)) => p.as_ref().intersects(q.as_ref()),
|
|
691
|
-
(Shapes::MultiPoint(p), Shapes::Point(q)) => p.as_ref().intersects(q.as_ref()),
|
|
692
|
-
(Shapes::MultiPoint(p), Shapes::LineString(q)) => p.as_ref().intersects(q.as_ref()),
|
|
693
|
-
(Shapes::MultiPoint(p), Shapes::MultiLineString(q)) => {
|
|
694
|
-
p.as_ref().intersects(q.as_ref())
|
|
695
|
-
}
|
|
696
|
-
(Shapes::MultiPoint(p), Shapes::Polygon(q)) => p.as_ref().intersects(q.as_ref()),
|
|
697
|
-
(Shapes::MultiPoint(p), Shapes::MultiPolygon(q)) => p.as_ref().intersects(q.as_ref()),
|
|
698
|
-
(Shapes::MultiPoint(p), Shapes::MultiPoint(q)) => p.as_ref().intersects(q.as_ref()),
|
|
699
|
-
(Shapes::Point(p), Shapes::MultiPoint(q)) => p.as_ref().intersects(q.as_ref()),
|
|
700
|
-
(Shapes::LineString(p), Shapes::MultiPoint(q)) => p.as_ref().intersects(q.as_ref()),
|
|
701
|
-
(Shapes::MultiLineString(p), Shapes::MultiPoint(q)) => {
|
|
702
|
-
p.as_ref().intersects(q.as_ref())
|
|
703
|
-
}
|
|
704
|
-
(Shapes::Polygon(p), Shapes::MultiPoint(q)) => p.as_ref().intersects(q.as_ref()),
|
|
705
|
-
(Shapes::MultiPolygon(p), Shapes::MultiPoint(q)) => p.as_ref().intersects(q.as_ref()),
|
|
706
|
-
}
|
|
343
|
+
match_shapes_method!(self, rhs, intersects)
|
|
707
344
|
}
|
|
708
345
|
|
|
709
346
|
fn to_wkt(&self) -> String {
|
|
710
|
-
|
|
711
|
-
Shapes::Point(p) => p.as_ref().wkt_string(),
|
|
712
|
-
Shapes::MultiPoint(p) => p.as_ref().wkt_string(),
|
|
713
|
-
Shapes::LineString(p) => p.wkt_string(),
|
|
714
|
-
Shapes::MultiLineString(p) => p.wkt_string(),
|
|
715
|
-
Shapes::MultiPolygon(p) => p.wkt_string(),
|
|
716
|
-
Shapes::Polygon(p) => p.wkt_string(),
|
|
717
|
-
}
|
|
347
|
+
match_shape!(self, wkt_string)
|
|
718
348
|
}
|
|
719
349
|
|
|
720
350
|
fn buffer<'py>(&self, py: Python<'py>, radius: f64) -> PyResult<Py<PyAny>> {
|
|
@@ -740,6 +370,9 @@ impl Shape {
|
|
|
740
370
|
|
|
741
371
|
fn intersection<'py>(&self, py: Python<'py>, rhs: &Shape) -> PyResult<Py<PyAny>> {
|
|
742
372
|
match (&self.inner, &rhs.inner) {
|
|
373
|
+
(Shapes::Polygon(p), Shapes::Polygon(q)) => {
|
|
374
|
+
mpg_to_pyany(py, p.as_ref().intersection(q.as_ref()))
|
|
375
|
+
}
|
|
743
376
|
(Shapes::MultiPolygon(p), Shapes::Polygon(q)) => {
|
|
744
377
|
mpg_to_pyany(py, p.as_ref().intersection(q.as_ref()))
|
|
745
378
|
}
|
|
@@ -755,6 +388,9 @@ impl Shape {
|
|
|
755
388
|
|
|
756
389
|
fn union<'py>(&self, py: Python<'py>, rhs: &Shape) -> PyResult<Py<PyAny>> {
|
|
757
390
|
match (&self.inner, &rhs.inner) {
|
|
391
|
+
(Shapes::Polygon(p), Shapes::Polygon(q)) => {
|
|
392
|
+
mpg_to_pyany(py, p.as_ref().union(q.as_ref()))
|
|
393
|
+
}
|
|
758
394
|
(Shapes::MultiPolygon(p), Shapes::Polygon(q)) => {
|
|
759
395
|
mpg_to_pyany(py, p.as_ref().union(q.as_ref()))
|
|
760
396
|
}
|
|
@@ -770,6 +406,9 @@ impl Shape {
|
|
|
770
406
|
|
|
771
407
|
fn difference<'py>(&self, py: Python<'py>, rhs: &Shape) -> PyResult<Py<PyAny>> {
|
|
772
408
|
match (&self.inner, &rhs.inner) {
|
|
409
|
+
(Shapes::Polygon(p), Shapes::Polygon(q)) => {
|
|
410
|
+
mpg_to_pyany(py, p.as_ref().difference(q.as_ref()))
|
|
411
|
+
}
|
|
773
412
|
(Shapes::MultiPolygon(p), Shapes::Polygon(q)) => {
|
|
774
413
|
mpg_to_pyany(py, p.as_ref().difference(q.as_ref()))
|
|
775
414
|
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
macro_rules! match_shapes_method {
|
|
2
|
+
($self:ident, $rhs:ident, $method:ident) => {
|
|
3
|
+
match (&$self.inner, &$rhs.inner) {
|
|
4
|
+
(Shapes::Point(p), Shapes::Point(q)) => p.as_ref().$method(q.as_ref()),
|
|
5
|
+
(Shapes::LineString(p), Shapes::Point(q)) => p.as_ref().$method(q.as_ref()),
|
|
6
|
+
(Shapes::Point(p), Shapes::LineString(q)) => p.as_ref().$method(q.as_ref()),
|
|
7
|
+
(Shapes::LineString(p), Shapes::LineString(q)) => p.as_ref().$method(q.as_ref()),
|
|
8
|
+
(Shapes::MultiLineString(p), Shapes::Point(q)) => p.as_ref().$method(q.as_ref()),
|
|
9
|
+
(Shapes::MultiLineString(p), Shapes::LineString(q)) => p.as_ref().$method(q.as_ref()),
|
|
10
|
+
(Shapes::MultiLineString(p), Shapes::MultiLineString(q)) => {
|
|
11
|
+
p.as_ref().$method(q.as_ref())
|
|
12
|
+
}
|
|
13
|
+
(Shapes::Point(p), Shapes::MultiLineString(q)) => p.as_ref().$method(q.as_ref()),
|
|
14
|
+
(Shapes::LineString(p), Shapes::MultiLineString(q)) => p.as_ref().$method(q.as_ref()),
|
|
15
|
+
(Shapes::Polygon(p), Shapes::Point(q)) => p.as_ref().$method(q.as_ref()),
|
|
16
|
+
(Shapes::Polygon(p), Shapes::LineString(q)) => p.as_ref().$method(q.as_ref()),
|
|
17
|
+
(Shapes::Polygon(p), Shapes::MultiLineString(q)) => p.as_ref().$method(q.as_ref()),
|
|
18
|
+
(Shapes::Polygon(p), Shapes::Polygon(q)) => p.as_ref().$method(q.as_ref()),
|
|
19
|
+
(Shapes::Point(p), Shapes::Polygon(q)) => p.as_ref().$method(q.as_ref()),
|
|
20
|
+
(Shapes::LineString(p), Shapes::Polygon(q)) => p.as_ref().$method(q.as_ref()),
|
|
21
|
+
(Shapes::MultiLineString(p), Shapes::Polygon(q)) => p.as_ref().$method(q.as_ref()),
|
|
22
|
+
(Shapes::MultiPolygon(p), Shapes::Point(q)) => p.as_ref().$method(q.as_ref()),
|
|
23
|
+
(Shapes::MultiPolygon(p), Shapes::LineString(q)) => p.as_ref().$method(q.as_ref()),
|
|
24
|
+
(Shapes::MultiPolygon(p), Shapes::MultiLineString(q)) => p.as_ref().$method(q.as_ref()),
|
|
25
|
+
(Shapes::MultiPolygon(p), Shapes::Polygon(q)) => p.as_ref().$method(q.as_ref()),
|
|
26
|
+
(Shapes::MultiPolygon(p), Shapes::MultiPolygon(q)) => p.as_ref().$method(q.as_ref()),
|
|
27
|
+
(Shapes::Point(p), Shapes::MultiPolygon(q)) => p.as_ref().$method(q.as_ref()),
|
|
28
|
+
(Shapes::LineString(p), Shapes::MultiPolygon(q)) => p.as_ref().$method(q.as_ref()),
|
|
29
|
+
(Shapes::MultiLineString(p), Shapes::MultiPolygon(q)) => p.as_ref().$method(q.as_ref()),
|
|
30
|
+
(Shapes::Polygon(p), Shapes::MultiPolygon(q)) => p.as_ref().$method(q.as_ref()),
|
|
31
|
+
(Shapes::MultiPoint(p), Shapes::Point(q)) => p.as_ref().$method(q.as_ref()),
|
|
32
|
+
(Shapes::MultiPoint(p), Shapes::LineString(q)) => p.as_ref().$method(q.as_ref()),
|
|
33
|
+
(Shapes::MultiPoint(p), Shapes::MultiLineString(q)) => p.as_ref().$method(q.as_ref()),
|
|
34
|
+
(Shapes::MultiPoint(p), Shapes::Polygon(q)) => p.as_ref().$method(q.as_ref()),
|
|
35
|
+
(Shapes::MultiPoint(p), Shapes::MultiPolygon(q)) => p.as_ref().$method(q.as_ref()),
|
|
36
|
+
(Shapes::MultiPoint(p), Shapes::MultiPoint(q)) => p.as_ref().$method(q.as_ref()),
|
|
37
|
+
(Shapes::Point(p), Shapes::MultiPoint(q)) => p.as_ref().$method(q.as_ref()),
|
|
38
|
+
(Shapes::LineString(p), Shapes::MultiPoint(q)) => p.as_ref().$method(q.as_ref()),
|
|
39
|
+
(Shapes::MultiLineString(p), Shapes::MultiPoint(q)) => p.as_ref().$method(q.as_ref()),
|
|
40
|
+
(Shapes::Polygon(p), Shapes::MultiPoint(q)) => p.as_ref().$method(q.as_ref()),
|
|
41
|
+
(Shapes::MultiPolygon(p), Shapes::MultiPoint(q)) => p.as_ref().$method(q.as_ref()),
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
macro_rules! match_shapes_algo {
|
|
47
|
+
($self:ident, $rhs:ident, $algo:ident, $method:ident) => {
|
|
48
|
+
match (&$self.inner, &$rhs.inner) {
|
|
49
|
+
(Shapes::Point(p), Shapes::Point(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
50
|
+
(Shapes::LineString(p), Shapes::Point(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
51
|
+
(Shapes::Point(p), Shapes::LineString(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
52
|
+
(Shapes::LineString(p), Shapes::LineString(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
53
|
+
(Shapes::MultiLineString(p), Shapes::Point(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
54
|
+
(Shapes::MultiLineString(p), Shapes::LineString(q)) => {
|
|
55
|
+
$algo.$method(p.as_ref(), q.as_ref())
|
|
56
|
+
}
|
|
57
|
+
(Shapes::MultiLineString(p), Shapes::MultiLineString(q)) => {
|
|
58
|
+
$algo.$method(p.as_ref(), q.as_ref())
|
|
59
|
+
}
|
|
60
|
+
(Shapes::Point(p), Shapes::MultiLineString(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
61
|
+
(Shapes::LineString(p), Shapes::MultiLineString(q)) => {
|
|
62
|
+
$algo.$method(p.as_ref(), q.as_ref())
|
|
63
|
+
}
|
|
64
|
+
(Shapes::Polygon(p), Shapes::Point(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
65
|
+
(Shapes::Polygon(p), Shapes::LineString(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
66
|
+
(Shapes::Polygon(p), Shapes::MultiLineString(q)) => {
|
|
67
|
+
$algo.$method(p.as_ref(), q.as_ref())
|
|
68
|
+
}
|
|
69
|
+
(Shapes::Polygon(p), Shapes::Polygon(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
70
|
+
(Shapes::Point(p), Shapes::Polygon(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
71
|
+
(Shapes::LineString(p), Shapes::Polygon(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
72
|
+
(Shapes::MultiLineString(p), Shapes::Polygon(q)) => {
|
|
73
|
+
$algo.$method(p.as_ref(), q.as_ref())
|
|
74
|
+
}
|
|
75
|
+
(Shapes::MultiPolygon(p), Shapes::Point(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
76
|
+
(Shapes::MultiPolygon(p), Shapes::LineString(q)) => {
|
|
77
|
+
$algo.$method(p.as_ref(), q.as_ref())
|
|
78
|
+
}
|
|
79
|
+
(Shapes::MultiPolygon(p), Shapes::MultiLineString(q)) => {
|
|
80
|
+
$algo.$method(p.as_ref(), q.as_ref())
|
|
81
|
+
}
|
|
82
|
+
(Shapes::MultiPolygon(p), Shapes::Polygon(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
83
|
+
(Shapes::MultiPolygon(p), Shapes::MultiPolygon(q)) => {
|
|
84
|
+
$algo.$method(p.as_ref(), q.as_ref())
|
|
85
|
+
}
|
|
86
|
+
(Shapes::Point(p), Shapes::MultiPolygon(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
87
|
+
(Shapes::LineString(p), Shapes::MultiPolygon(q)) => {
|
|
88
|
+
$algo.$method(p.as_ref(), q.as_ref())
|
|
89
|
+
}
|
|
90
|
+
(Shapes::MultiLineString(p), Shapes::MultiPolygon(q)) => {
|
|
91
|
+
$algo.$method(p.as_ref(), q.as_ref())
|
|
92
|
+
}
|
|
93
|
+
(Shapes::Polygon(p), Shapes::MultiPolygon(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
94
|
+
(Shapes::MultiPoint(p), Shapes::Point(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
95
|
+
(Shapes::MultiPoint(p), Shapes::LineString(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
96
|
+
(Shapes::MultiPoint(p), Shapes::MultiLineString(q)) => {
|
|
97
|
+
$algo.$method(p.as_ref(), q.as_ref())
|
|
98
|
+
}
|
|
99
|
+
(Shapes::MultiPoint(p), Shapes::Polygon(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
100
|
+
(Shapes::MultiPoint(p), Shapes::MultiPolygon(q)) => {
|
|
101
|
+
$algo.$method(p.as_ref(), q.as_ref())
|
|
102
|
+
}
|
|
103
|
+
(Shapes::MultiPoint(p), Shapes::MultiPoint(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
104
|
+
(Shapes::Point(p), Shapes::MultiPoint(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
105
|
+
(Shapes::LineString(p), Shapes::MultiPoint(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
106
|
+
(Shapes::MultiLineString(p), Shapes::MultiPoint(q)) => {
|
|
107
|
+
$algo.$method(p.as_ref(), q.as_ref())
|
|
108
|
+
}
|
|
109
|
+
(Shapes::Polygon(p), Shapes::MultiPoint(q)) => $algo.$method(p.as_ref(), q.as_ref()),
|
|
110
|
+
(Shapes::MultiPolygon(p), Shapes::MultiPoint(q)) => {
|
|
111
|
+
$algo.$method(p.as_ref(), q.as_ref())
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
macro_rules! match_shape {
|
|
118
|
+
($self:ident, $method:ident) => {
|
|
119
|
+
match &$self.inner {
|
|
120
|
+
Shapes::Point(p) => p.as_ref().$method(),
|
|
121
|
+
Shapes::MultiPoint(p) => p.as_ref().$method(),
|
|
122
|
+
Shapes::LineString(p) => p.$method(),
|
|
123
|
+
Shapes::MultiLineString(p) => p.$method(),
|
|
124
|
+
Shapes::MultiPolygon(p) => p.$method(),
|
|
125
|
+
Shapes::Polygon(p) => p.$method(),
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|