Coder Social home page Coder Social logo

nettopologysuite.io.geojson's Introduction

GeoJSON

GeoJSON (RFC 7946) IO module for NTS.

GeoJSON4STJ Usage

This is the package for System.Text.Json serialization and deserialization.

ASP.NET Core Example

Add the System.Text.Json.Serializer.JsonConverterFactory, GeoJsonConverterFactory, to the JsonSerializerOptions when you configure your controllers, MVC, etc in the ConfigureServices method of your Startup.cs class.

public void ConfigureServices(IServiceCollection services) {
  services.AddControllers()
  .AddJsonOptions(options => {
    options.JsonSerializerOptions.Converters.Add(new NetTopologySuite.IO.Converters.GeoJsonConverterFactory());
  });
}

GeoJSON Usage

GeoJSON to Geometry:

var geoJson = "{\"type\":\"Point\",\"coordinates\":[0.0,0.0]}";
Geometry geometry;

var serializer = GeoJsonSerializer.Create();
using (var stringReader = new StringReader(geoJson))
using (var jsonReader = new JsonTextReader(stringReader))
{
    geometry = serializer.Deserialize<Geometry>(jsonReader);
}

Geometry to GeoJSON:

var geometry = new Point(0, 0);
string geoJson;

var serializer = GeoJsonSerializer.Create();
using (var stringWriter = new StringWriter())
using (var jsonWriter = new JsonTextWriter(stringWriter))
{
    serializer.Serialize(jsonWriter, geometry);
    geoJson = stringWriter.ToString();
}

nettopologysuite.io.geojson's People

Contributors

airbreather avatar fobermaier avatar xivk avatar dguidi avatar russcam avatar jobbakker avatar bakk avatar bstordrup avatar verdie-g avatar harelm avatar jnystad avatar stijnherreman avatar xfischer avatar mymatthew avatar sl-tomtom avatar steveoh avatar

Forkers

jhertle

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.