TopoJSON.Net is a fork of Jörg Battermann's wonderful GeoJSON.Net library. It extends the original lib with TopoJSON features and uses Newtonsoft Json.NET converters for serialization and deserialization.
The current release features only deserialization (which might be buggy and I'll write more tests once I have the time). Serialization will come in the next weeks.
TopoJSON.Net aims to maintain full compatibility to GeoJSON.Net. You'll find classes prefixed with TopoJSON (such as TopoJSONPolygon
) that work the same way as their GeoJSON.Net equivalents. Should be easy to exchange data between GeoJSON.Net and TopoJSON.Net.
Yup.
string topology_string =
@"
{
'type':'Topology',
'transform':{
'scale': [1,1],
'translate': [0,0]
},
'objects':{
'two-squares':{
'type': 'GeometryCollection',
'geometries':[
{'type': 'Polygon', 'arcs':[[0,1]],'properties': {'name': 'Left_Polygon' }},
{'type': 'Polygon', 'arcs':[[2,-1]],'properties': {'name': 'Right_Polygon' }}
]
},
'one-line': {
'type':'GeometryCollection',
'geometries':[
{'type': 'LineString', 'arcs': [3],'properties':{'name':'Under_LineString'}}
]
},
'two-places':{
'type':'GeometryCollection',
'geometries':[
{'type':'Point','coordinates':[0,0],'properties':{'name':'Origine_Point'}},
{'type':'Point','coordinates':[0,-1],'properties':{'name':'Under_Point'}}
]
}
},
'arcs': [
[[1,2],[0,-2]],
[[1,0],[-1,0],[0,2],[1,0]],
[[1,2],[1,0],[0,-2],[-1,0]],
[[0,-1],[2,0]]
]
}
";
var topology = JsonConvert.DeserializeObject<Topology>(topology_string);
Well all you basically have to do is install the TopoJSON.Net NuGet package:
PM> Install-Package TopoJSON.Net
Highly welcome! Just fork away and send a pull request.
This library would be NOTHING without its contributors - thanks so much!!
GeoJSON.Net: Copyright © 2014 Jörg Battermann & Contributors TopoJSON.Net: Copyright © 2015 Friedrich Politz
GeoJSON and TopoJSON.Net are licensed under MIT. Refer to LICENSE.md for more information.