Skip to content

.Net library for TopoJSON based on Jörg Battermann's GeoJSON.Net

License

Notifications You must be signed in to change notification settings

Freddixx/TopoJSON.Net

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TopoJSON.NET NuGet Version

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.

What's in this version?

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.

Wait! Can I see an example?

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);

Installation & Usage

Well all you basically have to do is install the TopoJSON.Net NuGet package:

PM> Install-Package TopoJSON.Net

Contributing

Highly welcome! Just fork away and send a pull request.

Thanks

This library would be NOTHING without its contributors - thanks so much!!

Copyright

GeoJSON.Net: Copyright © 2014 Jörg Battermann & Contributors TopoJSON.Net: Copyright © 2015 Friedrich Politz

License

GeoJSON and TopoJSON.Net are licensed under MIT. Refer to LICENSE.md for more information.

About

.Net library for TopoJSON based on Jörg Battermann's GeoJSON.Net

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%