togo 0.1.2__cp38-cp38-musllinux_1_2_x86_64.whl → 0.1.5__cp38-cp38-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.
- {togo-0.1.2.dist-info → togo-0.1.5.dist-info}/METADATA +129 -33
- togo-0.1.5.dist-info/RECORD +8 -0
- togo.cpython-38-x86_64-linux-gnu.so +0 -0
- togo.libs/libgcc_s-0cd532bd.so.1 +0 -0
- togo.libs/libstdc++-5d72f927.so.6.0.33 +0 -0
- togo-0.1.2.dist-info/RECORD +0 -6
- {togo-0.1.2.dist-info → togo-0.1.5.dist-info}/LICENSE +0 -0
- {togo-0.1.2.dist-info → togo-0.1.5.dist-info}/WHEEL +0 -0
- {togo-0.1.2.dist-info → togo-0.1.5.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: togo
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: Lightweight Python bindings for the TG geometry library
|
|
5
5
|
Author-email: Giorgio Salluzzo <giorgio.salluzzo@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -92,24 +92,119 @@ second = gc[1]
|
|
|
92
92
|
print(first.type_string()) # 'Point'
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
-
### Point
|
|
96
|
-
|
|
97
|
-
Building blocks for constructing geometries:
|
|
95
|
+
### Point
|
|
98
96
|
|
|
99
97
|
```python
|
|
98
|
+
from togo import Point
|
|
99
|
+
|
|
100
100
|
# Create a point
|
|
101
101
|
p = Point(1.0, 2.0)
|
|
102
102
|
|
|
103
|
-
#
|
|
104
|
-
|
|
103
|
+
# Access coordinates
|
|
104
|
+
print(f"X: {p.x}, Y: {p.y}")
|
|
105
|
+
|
|
106
|
+
# Get as a tuple
|
|
107
|
+
print(p.as_tuple())
|
|
108
|
+
|
|
109
|
+
# Convert to a Geometry object
|
|
110
|
+
geom = p.as_geometry()
|
|
111
|
+
print(geom.type_string())
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Segment
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from togo import Segment, Point
|
|
118
|
+
|
|
119
|
+
# Create a segment from two points (or tuples)
|
|
120
|
+
seg = Segment(Point(0, 0), Point(1, 1))
|
|
121
|
+
# Or using tuples
|
|
122
|
+
tuple_seg = Segment((0, 0), (1, 1))
|
|
123
|
+
|
|
124
|
+
# Access endpoints
|
|
125
|
+
print(seg.a) # Point(0, 0)
|
|
126
|
+
print(seg.b) # Point(1, 1)
|
|
127
|
+
|
|
128
|
+
# Get the bounding rectangle
|
|
129
|
+
rect = seg.rect()
|
|
130
|
+
print(rect) # ((0.0, 0.0), (1.0, 1.0))
|
|
131
|
+
|
|
132
|
+
# Check intersection with another segment
|
|
133
|
+
other = Segment((1, 1), (2, 2))
|
|
134
|
+
print(seg.intersects(other)) # True or False
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Line
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
from togo import Line
|
|
141
|
+
|
|
142
|
+
# Create a line from a list of tuples
|
|
143
|
+
line = Line([(0,0), (1,1), (2,0)])
|
|
105
144
|
|
|
106
|
-
#
|
|
145
|
+
# Get number of points
|
|
146
|
+
print(f"Number of points: {line.num_points()}")
|
|
147
|
+
|
|
148
|
+
# Get all points as a list of tuples
|
|
149
|
+
print(f"Points: {line.points()}")
|
|
150
|
+
|
|
151
|
+
# Get the length of the line
|
|
152
|
+
print(f"Length: {line.length()}")
|
|
153
|
+
|
|
154
|
+
# Get the bounding box
|
|
155
|
+
print(f"Bounding box: {line.rect()}")
|
|
156
|
+
|
|
157
|
+
# Get a point by index
|
|
158
|
+
print(f"First point: {line[0].as_tuple()}")
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Ring
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
from togo import Ring
|
|
165
|
+
|
|
166
|
+
# Create a ring (must be closed)
|
|
107
167
|
ring = Ring([(0,0), (10,0), (10,10), (0,10), (0,0)])
|
|
108
168
|
|
|
109
|
-
#
|
|
169
|
+
# Get area and perimeter
|
|
170
|
+
print(f"Area: {ring.area()}")
|
|
171
|
+
print(f"Perimeter: {ring.perimeter()}")
|
|
172
|
+
|
|
173
|
+
# Check if it's convex or clockwise
|
|
174
|
+
print(f"Is convex: {ring.is_convex()}")
|
|
175
|
+
print(f"Is clockwise: {ring.is_clockwise()}")
|
|
176
|
+
|
|
177
|
+
# Get bounding box
|
|
178
|
+
min_pt, max_pt = ring.rect().min, ring.rect().max
|
|
179
|
+
print(f"Bounding box: {min_pt.as_tuple()}, {max_pt.as_tuple()}")
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Poly
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
from togo import Poly, Ring, Point
|
|
186
|
+
|
|
187
|
+
# Create a polygon with one exterior ring and one interior hole
|
|
110
188
|
exterior = Ring([(0,0), (10,0), (10,10), (0,10), (0,0)])
|
|
111
|
-
|
|
112
|
-
poly = Poly(exterior, [
|
|
189
|
+
hole1 = Ring([(1,1), (2,1), (2,2), (1,2), (1,1)])
|
|
190
|
+
poly = Poly(exterior, holes=[hole1])
|
|
191
|
+
|
|
192
|
+
# Get the exterior ring
|
|
193
|
+
ext_ring = poly.exterior()
|
|
194
|
+
print(f"Exterior has {ext_ring.num_points()} points")
|
|
195
|
+
|
|
196
|
+
# Get number of holes
|
|
197
|
+
print(f"Number of holes: {poly.num_holes()}")
|
|
198
|
+
|
|
199
|
+
# Get a hole by index
|
|
200
|
+
h = poly.hole(0)
|
|
201
|
+
print(f"Hole area: {h.area()}")
|
|
202
|
+
|
|
203
|
+
# A polygon is a geometry, so you can use geometry methods
|
|
204
|
+
geom = poly.as_geometry()
|
|
205
|
+
print(f"Contains point (5,5): {geom.contains(Point(5,5).as_geometry())}")
|
|
206
|
+
# Point is inside the hole, so it is not contained by the polygon
|
|
207
|
+
print(f"Contains point (1.5,1.5): {geom.contains(Point(1.5,1.5).as_geometry())}")
|
|
113
208
|
```
|
|
114
209
|
|
|
115
210
|
### MultiGeometries
|
|
@@ -117,6 +212,8 @@ poly = Poly(exterior, [hole])
|
|
|
117
212
|
Creating collections of geometries:
|
|
118
213
|
|
|
119
214
|
```python
|
|
215
|
+
from togo import Geometry, Point, Line, Poly, Ring
|
|
216
|
+
|
|
120
217
|
# Create a MultiPoint
|
|
121
218
|
multi_point = Geometry.from_multipoint([(0,0), (1,1), Point(2,2)])
|
|
122
219
|
|
|
@@ -132,42 +229,41 @@ poly2 = Poly(Ring([(2,2), (3,2), (3,3), (2,3), (2,2)]))
|
|
|
132
229
|
multi_poly = Geometry.from_multipolygon([poly1, poly2])
|
|
133
230
|
```
|
|
134
231
|
|
|
135
|
-
|
|
232
|
+
## Polygon Indexing
|
|
136
233
|
|
|
137
|
-
|
|
234
|
+
Togo supports different polygon indexing strategies for optimized spatial operations:
|
|
138
235
|
|
|
139
236
|
```python
|
|
140
|
-
from togo import
|
|
141
|
-
|
|
142
|
-
# Create a segment from two points (or tuples)
|
|
143
|
-
seg = Segment(Point(0, 0), Point(1, 1))
|
|
144
|
-
# Or using tuples
|
|
145
|
-
tuple_seg = Segment((0, 0), (1, 1))
|
|
237
|
+
from togo import TGIndex, set_polygon_indexing_mode
|
|
146
238
|
|
|
147
|
-
#
|
|
148
|
-
|
|
149
|
-
|
|
239
|
+
# Set the indexing mode
|
|
240
|
+
set_polygon_indexing_mode(TGIndex.NATURAL) # or NONE, YSTRIPES
|
|
241
|
+
```
|
|
150
242
|
|
|
151
|
-
|
|
152
|
-
rect = seg.rect()
|
|
153
|
-
print(rect) # ((0.0, 0.0), (1.0, 1.0))
|
|
243
|
+
## Integration with tgx and libgeos
|
|
154
244
|
|
|
155
|
-
|
|
156
|
-
other = Segment((1, 1), (2, 2))
|
|
157
|
-
print(seg.intersects(other)) # True or False
|
|
158
|
-
```
|
|
245
|
+
Togo integrates with the [tgx](https://github.com/tidwall/tgx) extension and [libgeos](https://libgeos.org/) to provide advanced geometry operations, such as topological unions and conversions between TG and GEOS geometry formats. This allows you to leverage the speed of TG for basic operations and the flexibility of GEOS for more complex tasks.
|
|
159
246
|
|
|
160
|
-
|
|
247
|
+
### Example: Unary Union (GEOS integration)
|
|
161
248
|
|
|
162
|
-
|
|
249
|
+
The `unary_union` method demonstrates this integration. It combines multiple geometries into a single geometry using GEOS's topological union, with all conversions handled automatically:
|
|
163
250
|
|
|
164
251
|
```python
|
|
165
|
-
from togo import
|
|
252
|
+
from togo import Geometry, Point, Poly, Ring
|
|
166
253
|
|
|
167
|
-
#
|
|
168
|
-
|
|
254
|
+
# Create several polygons
|
|
255
|
+
poly1 = Poly(Ring([(0,0), (2,0), (2,2), (0,2), (0,0)]))
|
|
256
|
+
poly2 = Poly(Ring([(1,1), (3,1), (3,3), (1,3), (1,1)]))
|
|
257
|
+
|
|
258
|
+
# Perform unary union (requires tgx and libgeos)
|
|
259
|
+
union = Geometry.unary_union([poly1, poly2])
|
|
260
|
+
|
|
261
|
+
# The result is a single geometry representing the union of the input polygons
|
|
262
|
+
print(union.to_wkt())
|
|
169
263
|
```
|
|
170
264
|
|
|
265
|
+
This operation uses `tgx` to convert `TG` geometries to `GEOS`, applies the union in `libgeos`, and converts the result back to `TG` format for further use in `ToGo`.
|
|
266
|
+
|
|
171
267
|
## Performance Considerations
|
|
172
268
|
|
|
173
269
|
- Togo is optimized for speed and memory efficiency
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
togo.cpython-38-x86_64-linux-gnu.so,sha256=0_s1l8CE1A6M2aIJFA3Bukyddc__SdBsIAQwu8YRiwA,9413729
|
|
2
|
+
togo.libs/libgcc_s-0cd532bd.so.1,sha256=yPk0-VjyKzucjnkP3mvC0vVaua6Ln17qZUJbICcXgtA,181737
|
|
3
|
+
togo.libs/libstdc++-5d72f927.so.6.0.33,sha256=fogxHsmB1_D6C-a_-uHh8Ei_6Qh52a8vLlicJRM3ehk,3562401
|
|
4
|
+
togo-0.1.5.dist-info/LICENSE,sha256=OfTFHFMDSt9X89g-BWUVis-GuTPWAdjplg2z9d2dBCw,1073
|
|
5
|
+
togo-0.1.5.dist-info/METADATA,sha256=u3TsXridgsfSPM-9uW6cEvfXMe4pc2lB7se3D9guiOA,7683
|
|
6
|
+
togo-0.1.5.dist-info/WHEEL,sha256=AtKzrIIwO6LyEQPNa-CKogjoLSeXFnST8-hqmpwwZQA,110
|
|
7
|
+
togo-0.1.5.dist-info/top_level.txt,sha256=bldd6tssR8THqoSDFauQQdh_pg79DMHBDhiNKgS4ttM,5
|
|
8
|
+
togo-0.1.5.dist-info/RECORD,,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
togo-0.1.2.dist-info/RECORD
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
togo.cpython-38-x86_64-linux-gnu.so,sha256=H_MJ0aPGj3-sVpLBX38PjiYDtBl_cJ1-466sE4RZGls,2616296
|
|
2
|
-
togo-0.1.2.dist-info/LICENSE,sha256=OfTFHFMDSt9X89g-BWUVis-GuTPWAdjplg2z9d2dBCw,1073
|
|
3
|
-
togo-0.1.2.dist-info/METADATA,sha256=g_-jjPQBASw6rWSrqArK8Ad9VHx14-oiegCsedd7Nm8,4897
|
|
4
|
-
togo-0.1.2.dist-info/WHEEL,sha256=AtKzrIIwO6LyEQPNa-CKogjoLSeXFnST8-hqmpwwZQA,110
|
|
5
|
-
togo-0.1.2.dist-info/top_level.txt,sha256=bldd6tssR8THqoSDFauQQdh_pg79DMHBDhiNKgS4ttM,5
|
|
6
|
-
togo-0.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|