Skip to content
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

Topojson bbox should not be transformed when loading Topojson-dict #138

Closed
mattijn opened this issue Sep 11, 2021 · 1 comment
Closed

Topojson bbox should not be transformed when loading Topojson-dict #138

mattijn opened this issue Sep 11, 2021 · 1 comment

Comments

@mattijn
Copy link
Owner

mattijn commented Sep 11, 2021

According the Topojson specification:

To include information on the coordinate range for a topology or geometry a TopoJSON object may have a member named “bbox”. The value of the bbox member must be a 2*n array where n is the number of dimensions represented in the contained geometries, with the lowest values for all axes followed by the highest values. The axes order of a bbox follows the axes order of geometries. The bounding box should not be transformed using the topology’s transform, if any.

Example where it is going wrong:

import topojson
data = {
    "foo": {"type": "LineString", "coordinates": [[0, 0], [1, 0], [2, 0]]},
    "bar": {"type": "LineString", "coordinates": [[0, 0], [1, 0], [2, 0]]},
}
tj = topojson.Topology(data).to_dict()
tj
{'type': 'Topology',
 'objects': {'data': {'geometries': [{'type': 'LineString', 'arcs': [0]},
    {'type': 'LineString', 'arcs': [0]}],
   'type': 'GeometryCollection'}},
 'bbox': (0.0, 0.0, 2.0, 0.0),
 'transform': {'scale': [2.000002000002e-06, 1], 'translate': [0.0, 0.0]},
 'arcs': [[[0, 0], [500000, 0], [499999, 0]]]}

Here is the 'bbox': (0.0, 0.0, 2.0, 0.0), but upon loading as Topojson-dict it changes to 'bbox': (0, 0, 500000, 0):

tp.Topology(tj, object_name='data').to_dict()
{'type': 'Topology',
 'bbox': (0, 0, 500000, 0),
 'objects': {'data': {'geometries': [{'type': 'LineString', 'arcs': [0]},
    {'type': 'LineString', 'arcs': [0]}],
   'type': 'GeometryCollection'}},
 'transform': {'scale': [2.000002000002e-06, 1], 'translate': [0.0, 0.0]},
 'arcs': [[[0, 0], [500000, 0], [499999, 0]]]}
@mattijn
Copy link
Owner Author

mattijn commented Sep 12, 2021

Fix by #139

@mattijn mattijn closed this as completed Sep 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant