Topojson bbox should not be transformed when loading Topojson-dict
Closed this issue · 1 comments
mattijn commented
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]]]}