-
-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when changing covering area #50
Comments
Thanks for raising the issue. Could you please provide a small reproducible code snippet of the geometry that gives this error? |
I can reproduce the issue: import s2sphere as s2
from shapely import geometry
import topojson
region_rect = s2.LatLngRect(
s2.LatLng.from_degrees(-51.264871, -30.241701),
s2.LatLng.from_degrees(-51.04618, -30.000003))
coverer = s2.RegionCoverer()
coverer.min_level=10
coverer.max_level=11
coverer.max_cells=500
covering = coverer.get_covering(region_rect)
geoms = []
for cellid in covering:
new_cell = s2.Cell(cellid)
vertices = []
for i in range(0, 4):
vertex = new_cell.get_vertex(i)
latlng = s2.LatLng.from_point(vertex)
vertices.append((latlng.lat().degrees,latlng.lng().degrees))
geo = geometry.Polygon(vertices)
geoms.append(geo)
print("Total Geometries: {}".format(len(geoms)))
geometry.GeometryCollection(geoms)
topojson.Topology(geoms, prequantize=False, topology=True)
|
Previously the Dedup class deduplicate identical arcs and tries to apply a line merge on non-duplicate LineStrings. In this line merging section it assumed that this only could happen on 2 arcs. This assumption proved wrong and is fixed by #51. |
Sorry, the late reply. Got it, thanks a lot @mattijn !! |
Hello,
I'm using s2 geometry to create a grid over a rectangle. The idea is basically to discretize a given city space, as follows:
Once i have the geometry i'm passing it to the topojson method Topology(dictionary, prequantize=False, topology=True).
The problem is that it only works with some geometries and s2 cells levels, for example when it works for the cell level 13 but it returns an error for cell level 12. I'm running python 3.6.6 and windows 10.
Thanks in advance!
I'm getting this error:
TypeError Traceback (most recent call last)
in ()
73 j = j + 1
74
---> 75 tj = topojson.Topology(dictionary)
76 tj.to_json()
c:\users\matheus.ferreira\appdata\local\programs\python\python36\lib\site-packages\topojson\core\topology.py in init(self, data, topology, prequantize, topoquantize, presimplify, toposimplify, simplify_with, simplify_algorithm, winding_order)
94 options = TopoOptions(locals())
95 # execute previous steps
---> 96 super().init(data, options)
97
98 # execute main function of Topology
c:\users\matheus.ferreira\appdata\local\programs\python\python36\lib\site-packages\topojson\core\hashmap.py in init(self, data, options)
20 def init(self, data, options={}):
21 # execute previous step
---> 22 super().init(data, options)
23
24 # initation topology items
c:\users\matheus.ferreira\appdata\local\programs\python\python36\lib\site-packages\topojson\core\dedup.py in init(self, data, options)
26
27 # execute main function of Dedup
---> 28 self.output = self.deduper(self.output)
29
30 def repr(self):
c:\users\matheus.ferreira\appdata\local\programs\python\python36\lib\site-packages\topojson\core\dedup.py in deduper(self, data)
75 # apply linemerge on geoms containing contigious arcs and maintain
76 # bookkeeping
---> 77 self.merge_contigious_arcs(data, sliced_array_bk_ndp)
78
79 # pop the merged contigious arcs and maintain bookkeeping.
c:\users\matheus.ferreira\appdata\local\programs\python\python36\lib\site-packages\topojson\core\dedup.py in merge_contigious_arcs(self, data, sliced_array_bk_ndp)
217
218 # replace linestring of idx_keep with merged linestring
--> 219 data["linestrings"][idx_keep] = ndp_arcs[idx_merg_arc]
220 self.merged_arcs_idx.append(idx_pop)
221
TypeError: list indices must be integers or slices, not NoneType
The text was updated successfully, but these errors were encountered: