togo 0.1.2__cp310-cp310-musllinux_1_2_x86_64.whl → 0.1.5__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: togo
3
- Version: 0.1.2
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
@@ -94,24 +94,119 @@ second = gc[1]
94
94
  print(first.type_string()) # 'Point'
95
95
  ```
96
96
 
97
- ### Point, Line, Ring, Poly
98
-
99
- Building blocks for constructing geometries:
97
+ ### Point
100
98
 
101
99
  ```python
100
+ from togo import Point
101
+
102
102
  # Create a point
103
103
  p = Point(1.0, 2.0)
104
104
 
105
- # Create a line
106
- line = Line([(0,0), (1,1), (2,2)])
105
+ # Access coordinates
106
+ print(f"X: {p.x}, Y: {p.y}")
107
+
108
+ # Get as a tuple
109
+ print(p.as_tuple())
110
+
111
+ # Convert to a Geometry object
112
+ geom = p.as_geometry()
113
+ print(geom.type_string())
114
+ ```
115
+
116
+ ### Segment
117
+
118
+ ```python
119
+ from togo import Segment, Point
120
+
121
+ # Create a segment from two points (or tuples)
122
+ seg = Segment(Point(0, 0), Point(1, 1))
123
+ # Or using tuples
124
+ tuple_seg = Segment((0, 0), (1, 1))
125
+
126
+ # Access endpoints
127
+ print(seg.a) # Point(0, 0)
128
+ print(seg.b) # Point(1, 1)
129
+
130
+ # Get the bounding rectangle
131
+ rect = seg.rect()
132
+ print(rect) # ((0.0, 0.0), (1.0, 1.0))
133
+
134
+ # Check intersection with another segment
135
+ other = Segment((1, 1), (2, 2))
136
+ print(seg.intersects(other)) # True or False
137
+ ```
138
+
139
+ ### Line
140
+
141
+ ```python
142
+ from togo import Line
143
+
144
+ # Create a line from a list of tuples
145
+ line = Line([(0,0), (1,1), (2,0)])
107
146
 
108
- # Create a ring (closed line)
147
+ # Get number of points
148
+ print(f"Number of points: {line.num_points()}")
149
+
150
+ # Get all points as a list of tuples
151
+ print(f"Points: {line.points()}")
152
+
153
+ # Get the length of the line
154
+ print(f"Length: {line.length()}")
155
+
156
+ # Get the bounding box
157
+ print(f"Bounding box: {line.rect()}")
158
+
159
+ # Get a point by index
160
+ print(f"First point: {line[0].as_tuple()}")
161
+ ```
162
+
163
+ ### Ring
164
+
165
+ ```python
166
+ from togo import Ring
167
+
168
+ # Create a ring (must be closed)
109
169
  ring = Ring([(0,0), (10,0), (10,10), (0,10), (0,0)])
110
170
 
111
- # Create a polygon with holes
171
+ # Get area and perimeter
172
+ print(f"Area: {ring.area()}")
173
+ print(f"Perimeter: {ring.perimeter()}")
174
+
175
+ # Check if it's convex or clockwise
176
+ print(f"Is convex: {ring.is_convex()}")
177
+ print(f"Is clockwise: {ring.is_clockwise()}")
178
+
179
+ # Get bounding box
180
+ min_pt, max_pt = ring.rect().min, ring.rect().max
181
+ print(f"Bounding box: {min_pt.as_tuple()}, {max_pt.as_tuple()}")
182
+ ```
183
+
184
+ ### Poly
185
+
186
+ ```python
187
+ from togo import Poly, Ring, Point
188
+
189
+ # Create a polygon with one exterior ring and one interior hole
112
190
  exterior = Ring([(0,0), (10,0), (10,10), (0,10), (0,0)])
113
- hole = Ring([(2,2), (8,2), (8,8), (2,8), (2,2)])
114
- poly = Poly(exterior, [hole])
191
+ hole1 = Ring([(1,1), (2,1), (2,2), (1,2), (1,1)])
192
+ poly = Poly(exterior, holes=[hole1])
193
+
194
+ # Get the exterior ring
195
+ ext_ring = poly.exterior()
196
+ print(f"Exterior has {ext_ring.num_points()} points")
197
+
198
+ # Get number of holes
199
+ print(f"Number of holes: {poly.num_holes()}")
200
+
201
+ # Get a hole by index
202
+ h = poly.hole(0)
203
+ print(f"Hole area: {h.area()}")
204
+
205
+ # A polygon is a geometry, so you can use geometry methods
206
+ geom = poly.as_geometry()
207
+ print(f"Contains point (5,5): {geom.contains(Point(5,5).as_geometry())}")
208
+ # Point is inside the hole, so it is not contained by the polygon
209
+ print(f"Contains point (1.5,1.5): {geom.contains(Point(1.5,1.5).as_geometry())}")
115
210
  ```
116
211
 
117
212
  ### MultiGeometries
@@ -119,6 +214,8 @@ poly = Poly(exterior, [hole])
119
214
  Creating collections of geometries:
120
215
 
121
216
  ```python
217
+ from togo import Geometry, Point, Line, Poly, Ring
218
+
122
219
  # Create a MultiPoint
123
220
  multi_point = Geometry.from_multipoint([(0,0), (1,1), Point(2,2)])
124
221
 
@@ -134,42 +231,41 @@ poly2 = Poly(Ring([(2,2), (3,2), (3,3), (2,3), (2,2)]))
134
231
  multi_poly = Geometry.from_multipolygon([poly1, poly2])
135
232
  ```
136
233
 
137
- ### Segment
234
+ ## Polygon Indexing
138
235
 
139
- Represents a line segment between two points:
236
+ Togo supports different polygon indexing strategies for optimized spatial operations:
140
237
 
141
238
  ```python
142
- from togo import Segment, Point
143
-
144
- # Create a segment from two points (or tuples)
145
- seg = Segment(Point(0, 0), Point(1, 1))
146
- # Or using tuples
147
- tuple_seg = Segment((0, 0), (1, 1))
239
+ from togo import TGIndex, set_polygon_indexing_mode
148
240
 
149
- # Access endpoints
150
- print(seg.a) # Point(0, 0)
151
- print(seg.b) # Point(1, 1)
241
+ # Set the indexing mode
242
+ set_polygon_indexing_mode(TGIndex.NATURAL) # or NONE, YSTRIPES
243
+ ```
152
244
 
153
- # Get the bounding rectangle
154
- rect = seg.rect()
155
- print(rect) # ((0.0, 0.0), (1.0, 1.0))
245
+ ## Integration with tgx and libgeos
156
246
 
157
- # Check intersection with another segment
158
- other = Segment((1, 1), (2, 2))
159
- print(seg.intersects(other)) # True or False
160
- ```
247
+ 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.
161
248
 
162
- ## Polygon Indexing
249
+ ### Example: Unary Union (GEOS integration)
163
250
 
164
- Togo supports different polygon indexing strategies for optimized spatial operations:
251
+ 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:
165
252
 
166
253
  ```python
167
- from togo import TGIndex, set_polygon_indexing_mode
254
+ from togo import Geometry, Point, Poly, Ring
168
255
 
169
- # Set the indexing mode
170
- set_polygon_indexing_mode(TGIndex.NATURAL) # or NONE, YSTRIPES
256
+ # Create several polygons
257
+ poly1 = Poly(Ring([(0,0), (2,0), (2,2), (0,2), (0,0)]))
258
+ poly2 = Poly(Ring([(1,1), (3,1), (3,3), (1,3), (1,1)]))
259
+
260
+ # Perform unary union (requires tgx and libgeos)
261
+ union = Geometry.unary_union([poly1, poly2])
262
+
263
+ # The result is a single geometry representing the union of the input polygons
264
+ print(union.to_wkt())
171
265
  ```
172
266
 
267
+ 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`.
268
+
173
269
  ## Performance Considerations
174
270
 
175
271
  - Togo is optimized for speed and memory efficiency
@@ -0,0 +1,8 @@
1
+ togo.cpython-310-x86_64-linux-gnu.so,sha256=StqZuoVj0DzTnmGmGN1-AE0eTXOGVzHOMziNC2-zcxw,9352337
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/METADATA,sha256=J4BU0w5iNSqsEQ56hodktVSrffMKO8xItT6zCuGfk9s,7722
5
+ togo-0.1.5.dist-info/WHEEL,sha256=YJPq7zroHSsdctrb_KymZ4ss41PkmaA9SD9TZzqKSX8,112
6
+ togo-0.1.5.dist-info/top_level.txt,sha256=bldd6tssR8THqoSDFauQQdh_pg79DMHBDhiNKgS4ttM,5
7
+ togo-0.1.5.dist-info/RECORD,,
8
+ togo-0.1.5.dist-info/licenses/LICENSE,sha256=OfTFHFMDSt9X89g-BWUVis-GuTPWAdjplg2z9d2dBCw,1073
Binary file
Binary file
Binary file
@@ -1,6 +0,0 @@
1
- togo.cpython-310-x86_64-linux-gnu.so,sha256=lQ7Op3rW5HTTRJy-_5uSSV9kd3l_hSxhdPKviJ9Wqrg,2545088
2
- togo-0.1.2.dist-info/METADATA,sha256=YHTXCAcsWj8Qs61iTDJHDuWGjfiyfvBAwaqomdPsXas,4936
3
- togo-0.1.2.dist-info/WHEEL,sha256=YJPq7zroHSsdctrb_KymZ4ss41PkmaA9SD9TZzqKSX8,112
4
- togo-0.1.2.dist-info/top_level.txt,sha256=bldd6tssR8THqoSDFauQQdh_pg79DMHBDhiNKgS4ttM,5
5
- togo-0.1.2.dist-info/RECORD,,
6
- togo-0.1.2.dist-info/licenses/LICENSE,sha256=OfTFHFMDSt9X89g-BWUVis-GuTPWAdjplg2z9d2dBCw,1073
File without changes