Giter Site home page Giter Site logo

Comments (4)

mattijn avatar mattijn commented on May 24, 2024

Thanks for raising the issue. Could you please provide a small reproducible code snippet of the geometry that gives this error?

from topojson.

mattijn avatar mattijn commented on May 24, 2024

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)
Total Geometries: 19

image

topojson.Topology(geoms, prequantize=False, topology=True)
---------------------------------------------------------------------------

TypeError                                 Traceback (most recent call last)

<ipython-input-2-a207dd4fcbb5> in <module>
----> 1 topojson.Topology(geoms, prequantize=False, topology=True)


~/topojson/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


~/topojson/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


~/topojson/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):


~/topojson/topojson/core/dedup.py in deduper(self, data)
     77             # apply linemerge on geoms containing contigious arcs and maintain
     78             # bookkeeping
---> 79             self.merge_contigious_arcs(data, sliced_array_bk_ndp)
     80 
     81             # pop the merged contigious arcs and maintain bookkeeping.


~/topojson/topojson/core/dedup.py in merge_contigious_arcs(self, data, sliced_array_bk_ndp)
    219 
    220                 # replace linestring of idx_keep with merged linestring
--> 221                 data["linestrings"][idx_keep] = ndp_arcs[idx_merg_arc]
    222                 self.merged_arcs_idx.append(idx_pop)
    223 


TypeError: list indices must be integers or slices, not NoneType

from topojson.

mattijn avatar mattijn commented on May 24, 2024

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.

from topojson.

matdeof avatar matdeof commented on May 24, 2024

Sorry, the late reply.

Got it, thanks a lot @mattijn !!

from topojson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.