Skip to content

Commit

Permalink
fix how list of lists treat multipoint geoms
Browse files Browse the repository at this point in the history
  • Loading branch information
mattijn committed Oct 19, 2023
1 parent 48ad0e6 commit fc4816a
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions topojson/core/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def __init__(
winding_order="CW_CCW",
object_name="data",
):

options = TopoOptions(locals())

# shortcut when dealing with topojson data
Expand Down Expand Up @@ -496,7 +495,7 @@ def toposimplify(
# dequantize if transform exist
if transform is not None:
power_estimate = len(str(int(np_arcs[:, 0].max())))
quant_factor_estimate = 10 ** power_estimate
quant_factor_estimate = 10**power_estimate
np_arcs = dequantize(np_arcs, scale, translate)

# apply simplify
Expand Down Expand Up @@ -547,17 +546,14 @@ def toposimplify(
return result

def _resolve_coords(self, data):

for objectname in self.options.object_name:

if objectname not in data["objects"]:
raise SystemExit(
f"'{objectname}' is not an object name in your topojson file"
)
geoms = data["objects"][objectname]["geometries"]
for idx, feat in enumerate(geoms):
if feat["type"] in ["Point", "MultiPoint"]:

lofl = feat["coordinates"]
repeat = 1 if feat["type"] == "Point" else 2

Expand All @@ -568,7 +564,7 @@ def _resolve_coords(self, data):
coord = data["coordinates"][val][0]
lofl[idx] = np.asarray(coord).tolist()

feat["coordinates"] = lofl[0] if len(lofl) == 1 else lofl
feat["coordinates"] = lofl[0] if feat["type"] == "Point" else lofl
feat.pop("reset_coords", None)
data.pop("coordinates", None)
return data
Expand Down

0 comments on commit fc4816a

Please sign in to comment.