question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MicrosoftSpatialGeoJsonConverter doesn't support Microsoft.Spatial.GeographyPolygon

See original GitHub issue

True {“type”:“Point”,“coordinates”:[20.1,20]} False

is the LinqPad output for the code below. MicrosoftSpatialGeoJsonConverter seems to be handling Point, why not Polygon?

void Main()
{
	GeographyPoint geographyPoint = GeographyPoint.Create(20, 20.1);
	
	GeographyPolygon geographyPolygon = GeographyFactory.Polygon().Ring(10, 10).LineTo(30, 10).LineTo(30, 30).LineTo(10, 30).LineTo(10, 10).Build();
	
	WriteObject(geographyPoint);
	
	WriteObject(geographyPolygon);
}

void WriteObject(object obj)
{
	MicrosoftSpatialGeoJsonConverter converter = new ();

	converter.CanConvert(obj.GetType()).Dump();
	
	JsonWriterOptions writerOptions = new () { Indented = false, };

	using MemoryStream stream = new ();
	
	using Utf8JsonWriter writer = new (stream, writerOptions);
	
	JsonSerializerOptions options = new (JsonSerializerDefaults.General);

	converter.Write(writer, obj, options);

	writer.Flush();

	string json = Encoding.UTF8.GetString(stream.ToArray());

	json.Dump();
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
jackbondcommented, Oct 5, 2021

Sure, I’ll work on that tonight. Thanks.

0reactions
jackbondcommented, Oct 13, 2021

Great! Thanks so much for the feedback and beta publish.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Returning spatial data in GeoJSON format - Part 2
In this post I will show you how to export other spatial types such as lines or polygons, into equivalent GeoJSON formats. Spatial...
Read more >
Using Microsoft Footprint GeoJSON for spatial analysis ...
I am trying to use the Microsoft Footprint data (available as GeoJSON) for spatial analysis to roughly identify buildings over a certain size ......
Read more >
System.Text.Json support for Microsoft.Spatial library for .NET
Spatial package contains classes and methods that support geographic operations. This library contains converters dependent on System.Text.
Read more >
convert geoJson data to sql server spatial data type (GIS)
I'm trying to store the json data related to the polygons in my ms sql server using spatial data. Since I've never parsed...
Read more >
Converting GeoJSON to DbGeometry - bing maps
Note that DbGeometery will not support spatially accurate calculations. Consider storing the data as a DbGeograpgy instead using geography:: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found