togo 0.1.1__cp310-cp310-musllinux_1_2_x86_64.whl
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.
Potentially problematic release.
This version of togo might be problematic. Click here for more details.
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: togo
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Lightweight Python bindings for the TG geometry library
|
|
5
|
+
Author-email: Giorgio Salluzzo <giorgio.salluzzo@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/mindflayer/togo
|
|
8
|
+
Project-URL: Source, https://github.com/mindflayer/togo
|
|
9
|
+
Project-URL: Tracker, https://github.com/mindflayer/togo/issues
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: C
|
|
12
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
15
|
+
Requires-Python: >=3.8
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Dynamic: license
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# ToGo
|
|
22
|
+
Python bindings for [TG](https://github.com/tidwall/tg)
|
|
23
|
+
(Geometry library for C - Fast point-in-polygon)
|
|
24
|
+
|
|
25
|
+
ToGo is a high-performance Python library for computational geometry, providing a Cython wrapper around the above-mentioned C library.
|
|
26
|
+
|
|
27
|
+
The main goal is to offer a Pythonic, object-oriented, fast and memory-efficient library for geometric operations, including spatial predicates, format conversions, and spatial indexing.
|
|
28
|
+
|
|
29
|
+
While ToGo's API interfaces are still a work in progress, the underling C library is stable and well-tested.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install togo
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Features
|
|
38
|
+
|
|
39
|
+
- Fast and efficient geometric operations
|
|
40
|
+
- Support for standard geometry types: Point, Line, Ring, Polygon, and their multi-variants
|
|
41
|
+
- Geometric predicates: contains, intersects, covers, touches, etc.
|
|
42
|
+
- Format conversion between WKT, GeoJSON, WKB, and HEX
|
|
43
|
+
- Spatial indexing for accelerated queries
|
|
44
|
+
- Memory-efficient C implementation with Python-friendly interface
|
|
45
|
+
|
|
46
|
+
## Basic Usage
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from togo import Geometry, Point, Ring, Poly
|
|
50
|
+
|
|
51
|
+
# Create a geometry from GeoJSON
|
|
52
|
+
geom = Geometry('{"type":"Point","coordinates":[1.0,2.0]}')
|
|
53
|
+
|
|
54
|
+
# Create a point
|
|
55
|
+
point = Point(1.0, 2.0)
|
|
56
|
+
|
|
57
|
+
# Create a polygon
|
|
58
|
+
ring = Ring([(0,0), (10,0), (10,10), (0,10), (0,0)])
|
|
59
|
+
polygon = Poly(ring)
|
|
60
|
+
|
|
61
|
+
# Convert to various formats
|
|
62
|
+
wkt = polygon.as_geometry().to_wkt()
|
|
63
|
+
geojson = polygon.as_geometry().to_geojson()
|
|
64
|
+
|
|
65
|
+
# Perform spatial predicates
|
|
66
|
+
point_geom = point.as_geometry()
|
|
67
|
+
contains = polygon.as_geometry().contains(point_geom)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Core Classes
|
|
71
|
+
|
|
72
|
+
### Geometry
|
|
73
|
+
|
|
74
|
+
The base class that wraps tg_geom structures and provides core operations:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
# Create from various formats
|
|
78
|
+
g1 = Geometry('POINT(1 2)', fmt='wkt')
|
|
79
|
+
g2 = Geometry('{"type":"Point","coordinates":[1,2]}', fmt='geojson')
|
|
80
|
+
|
|
81
|
+
# Geometric predicates
|
|
82
|
+
g1.intersects(g2)
|
|
83
|
+
g1.contains(g2)
|
|
84
|
+
g1.within(g2)
|
|
85
|
+
|
|
86
|
+
# Format conversion
|
|
87
|
+
g1.to_wkt()
|
|
88
|
+
g1.to_geojson()
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Point, Line, Ring, Poly
|
|
92
|
+
|
|
93
|
+
Building blocks for constructing geometries:
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
# Create a point
|
|
97
|
+
p = Point(1.0, 2.0)
|
|
98
|
+
|
|
99
|
+
# Create a line
|
|
100
|
+
line = Line([(0,0), (1,1), (2,2)])
|
|
101
|
+
|
|
102
|
+
# Create a ring (closed line)
|
|
103
|
+
ring = Ring([(0,0), (10,0), (10,10), (0,10), (0,0)])
|
|
104
|
+
|
|
105
|
+
# Create a polygon with holes
|
|
106
|
+
exterior = Ring([(0,0), (10,0), (10,10), (0,10), (0,0)])
|
|
107
|
+
hole = Ring([(2,2), (8,2), (8,8), (2,8), (2,2)])
|
|
108
|
+
poly = Poly(exterior, [hole])
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### MultiGeometries
|
|
112
|
+
|
|
113
|
+
Creating collections of geometries:
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
# Create a MultiPoint
|
|
117
|
+
multi_point = Geometry.from_multipoint([(0,0), (1,1), Point(2,2)])
|
|
118
|
+
|
|
119
|
+
# Create a MultiLineString
|
|
120
|
+
multi_line = Geometry.from_multilinestring([
|
|
121
|
+
[(0,0), (1,1)],
|
|
122
|
+
Line([(2,2), (3,3)])
|
|
123
|
+
])
|
|
124
|
+
|
|
125
|
+
# Create a MultiPolygon
|
|
126
|
+
poly1 = Poly(Ring([(0,0), (1,0), (1,1), (0,1), (0,0)]))
|
|
127
|
+
poly2 = Poly(Ring([(2,2), (3,2), (3,3), (2,3), (2,2)]))
|
|
128
|
+
multi_poly = Geometry.from_multipolygon([poly1, poly2])
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Polygon Indexing
|
|
132
|
+
|
|
133
|
+
Togo supports different polygon indexing strategies for optimized spatial operations:
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from togo import TGIndex, set_polygon_indexing_mode
|
|
137
|
+
|
|
138
|
+
# Set the indexing mode
|
|
139
|
+
set_polygon_indexing_mode(TGIndex.NATURAL) # or NONE, YSTRIPES
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Performance Considerations
|
|
143
|
+
|
|
144
|
+
- Togo is optimized for speed and memory efficiency
|
|
145
|
+
- For large datasets, proper indexing can significantly improve performance
|
|
146
|
+
- Creating geometries with the appropriate format avoids unnecessary conversions
|
|
147
|
+
|
|
148
|
+
Soon there will be a full API documentation, for now please refer to the test suite for more usage examples.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
togo.cpython-310-x86_64-linux-gnu.so,sha256=gCLm0X6-QiyQ-Gh1MHjMG88C-7P7-sAuKuIsLS9Tkik,2368856
|
|
2
|
+
togo-0.1.1.dist-info/METADATA,sha256=smJ-qt2aCBBDfYMWWUQHrO8gjVvXQk3KB4RXAG3wQOE,4128
|
|
3
|
+
togo-0.1.1.dist-info/WHEEL,sha256=YJPq7zroHSsdctrb_KymZ4ss41PkmaA9SD9TZzqKSX8,112
|
|
4
|
+
togo-0.1.1.dist-info/top_level.txt,sha256=bldd6tssR8THqoSDFauQQdh_pg79DMHBDhiNKgS4ttM,5
|
|
5
|
+
togo-0.1.1.dist-info/RECORD,,
|
|
6
|
+
togo-0.1.1.dist-info/licenses/LICENSE,sha256=OfTFHFMDSt9X89g-BWUVis-GuTPWAdjplg2z9d2dBCw,1073
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Giorgio Salluzzo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
togo
|
|
Binary file
|