有效的 Topojson 和 https://mapshaper.org/
Valid Topojson and https://mapshaper.org/
所有 3 个案例都在 jsonlint 中验证,但只有第一个案例显示在 mapshaper 中。
我不明白为什么案例2和案例3没有显示。
那么我如何在 属性 的 arcs ref 中使用'-'来设置这个正确的?
- 在 https://mapshaper.org/
中显示正常
{"type":"Topology", "crs":{"type":"name","properties":{"name":"EPSG:25832"}},"objects":{"collection": { "type": "GeometryCollection", "geometries":[
{ "type": "MultiPolygon", "arcs": [[[0,1]]],"properties":{"id":9005309}}]}},"arcs":
[
[[565546,7786890.97],[565545.69,7786859.81]],
[[565545.69,7786859.81],[565545.06,7786876.95],[565546,7786890.97]]]
}
{"type":"Topology", "crs":{"type":"name","properties":{"name":"EPSG:25832"}},"objects":{"collection": { "type": "GeometryCollection", "geometries":[
{ "type": "MultiPolygon", "arcs": [[[-0,-1]]],"properties":{"id":9005309}}]}},"arcs":
[
[[565545.69,7786859.81],[565546,7786890.97]],
[[565546,7786890.97],[565545.06,7786876.95],[565545.69,7786859.81]]
]
}
{"type":"Topology", "crs":{"type":"name","properties":{"name":"EPSG:25832"}},"objects":{"collection": { "type": "GeometryCollection", "geometries":[
{ "type": "MultiPolygon", "arcs": [[[-0,1]]],"properties":{"id":9005309}}]}},"arcs":
[
[[565545.69,7786859.81],[565546,7786890.97]],
[[565545.69,7786859.81],[565545.06,7786876.95],[565546,7786890.97]]]
}
负(/反)弧的索引错误:
Each arc must be referenced by numeric zero-based index into the
containing topology’s arcs array. For example, 0 refers to the first
arc, 1 refers to the second arc, and so on.
A negative arc index indicates that the arc at the ones’ complement of
the index must be reversed to reconstruct the geometry: -1 refers to
the reversed first arc, -2 refers to the reversed second arc, and so
on. In JavaScript, you can negate a negative arc index i using the
bitwise NOT operator, ~i. (docs)
您应该使用 -1
而不是 -0
。因此,您的第二个 topojson 示例应绘制如下:
{"type":"Topology",
"crs":{"type":"name","properties": {"name":"EPSG:25832"}},
"objects":{
"collection": { "type": "GeometryCollection",
"geometries":[
{ "type": "MultiPolygon",
"arcs": [[[-1,-2]]],
"properties":{"id":9005309}}]}},
"arcs":[
[[565545.69,7786859.81],[565546,7786890.97]],
[[565546,7786890.97],[565545.06,7786876.95],[565545.69,7786859.81]]
]
}
所有 3 个案例都在 jsonlint 中验证,但只有第一个案例显示在 mapshaper 中。
我不明白为什么案例2和案例3没有显示。
那么我如何在 属性 的 arcs ref 中使用'-'来设置这个正确的?
- 在 https://mapshaper.org/ 中显示正常
{"type":"Topology", "crs":{"type":"name","properties":{"name":"EPSG:25832"}},"objects":{"collection": { "type": "GeometryCollection", "geometries":[
{ "type": "MultiPolygon", "arcs": [[[0,1]]],"properties":{"id":9005309}}]}},"arcs":
[
[[565546,7786890.97],[565545.69,7786859.81]],
[[565545.69,7786859.81],[565545.06,7786876.95],[565546,7786890.97]]]
}
{"type":"Topology", "crs":{"type":"name","properties":{"name":"EPSG:25832"}},"objects":{"collection": { "type": "GeometryCollection", "geometries":[
{ "type": "MultiPolygon", "arcs": [[[-0,-1]]],"properties":{"id":9005309}}]}},"arcs":
[
[[565545.69,7786859.81],[565546,7786890.97]],
[[565546,7786890.97],[565545.06,7786876.95],[565545.69,7786859.81]]
]
}
{"type":"Topology", "crs":{"type":"name","properties":{"name":"EPSG:25832"}},"objects":{"collection": { "type": "GeometryCollection", "geometries":[
{ "type": "MultiPolygon", "arcs": [[[-0,1]]],"properties":{"id":9005309}}]}},"arcs":
[
[[565545.69,7786859.81],[565546,7786890.97]],
[[565545.69,7786859.81],[565545.06,7786876.95],[565546,7786890.97]]]
}
负(/反)弧的索引错误:
Each arc must be referenced by numeric zero-based index into the containing topology’s arcs array. For example, 0 refers to the first arc, 1 refers to the second arc, and so on.
A negative arc index indicates that the arc at the ones’ complement of the index must be reversed to reconstruct the geometry: -1 refers to the reversed first arc, -2 refers to the reversed second arc, and so on. In JavaScript, you can negate a negative arc index i using the bitwise NOT operator, ~i. (docs)
您应该使用 -1
而不是 -0
。因此,您的第二个 topojson 示例应绘制如下:
{"type":"Topology",
"crs":{"type":"name","properties": {"name":"EPSG:25832"}},
"objects":{
"collection": { "type": "GeometryCollection",
"geometries":[
{ "type": "MultiPolygon",
"arcs": [[[-1,-2]]],
"properties":{"id":9005309}}]}},
"arcs":[
[[565545.69,7786859.81],[565546,7786890.97]],
[[565546,7786890.97],[565545.06,7786876.95],[565545.69,7786859.81]]
]
}