Comments (6)
@airbreather @FObermaier anyone? Seems like a straight forward case, I'm not sure what I'm missing... :-(
from nettopologysuite.io.geojson.
Ok, Found the bug and found the solution.
It's a one line change:
Missing the following line in CoordinateConverter.CanConvert
:
typeof(Coordinate).IsAssignableFrom(objectType) ||
So the function should look as follows:
public override bool CanConvert(Type objectType)
{
return objectType == typeof(Coordinate) ||
objectType == typeof(Coordinate[]) ||
objectType == typeof(List<Coordinate[]>) ||
objectType == typeof(List<List<Coordinate[]>>) ||
typeof(Coordinate).IsAssignableFrom(objectType) ||
typeof(IEnumerable<Coordinate>).IsAssignableFrom(objectType) ||
typeof(IEnumerable<IEnumerable<Coordinate>>).IsAssignableFrom(objectType) ||
typeof(IEnumerable<IEnumerable<IEnumerable<Coordinate>>>).IsAssignableFrom(objectType);
}
Let me know if you need a PR for this.
I'm in the middle of the migration and it would help me a lot if you can add this and create a new Nuget Package.
Relevant test:
[Test, GeoJsonIssueNumber(41)]
public void Test3DPointSerialization()
{
var featureCollection = new FeatureCollection { new Feature(new Point(1, 2, 3), new AttributesTable()) };
var writer = new StringWriter();
var jsonWriter = new JsonTextWriter(writer);
var serializer = GeoJsonSerializer.Create(new GeometryFactory(), 3);
serializer.Serialize(jsonWriter, featureCollection);
string json = writer.ToString();
Assert.That(json, Is.EqualTo("{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[1.0,2.0,3.0]},\"properties\":{}}]}"));
}
from nettopologysuite.io.geojson.
I have created the relevant pull request (#43), easier than writing what you should change :-)
Can this please please be merged and with a new NuGet package release? I really need this...
from nettopologysuite.io.geojson.
I have found a workaround to use the following patch until a new version will be released.
public class CoordinateConverterPatch : CoordinateConverter
{
public CoordinateConverterPatch() : base() { }
public CoordinateConverterPatch(PrecisionModel precisionModel, int dimension) : base(precisionModel, dimension) { }
public override bool CanConvert(Type objectType)
{
return base.CanConvert(objectType) || typeof(CoordinateZ) == objectType;
}
}
Which can be added to the JsonSerializer converters.
Keep me posted on the new NuGet.
from nettopologysuite.io.geojson.
@HarelM thanks for reporting this and for doing all the work to find a fix for it. Note that you do need to use one of the GeoJsonSerializer.Create
overloads that accepts the dimension
parameter, since the default dimension is 2.
2.0.1 is now available on NuGet with this fix.
from nettopologysuite.io.geojson.
Glad I could help, you guys are doing a great job!
from nettopologysuite.io.geojson.
Related Issues (20)
- Geometry modified bug in GeoJsonWriter() HOT 2
- Missing assembly reference at GeoJsonConverterFactory HOT 3
- Exception when deserializing a feature with nested object in properties (I think) HOT 12
- Can't modify STJ's Attribute Table HOT 13
- GeoJSON4STJ ignores PrecisionModel HOT 5
- Allow migrating from id inside properties to top level id (in STJ) HOT 2
- BBox not serialized as expected HOT 4
- when use httpclient GetFromJsonAsync<T> , GeoJsonConverter did not work. HOT 1
- Not able to serialize using library GeoJSON4STJ HOT 2
- Skipping invalid geometries during deserialization
- serializer produces noncompliant GeoJSON feature when geometry or properties is null HOT 1
- Publish a new version HOT 12
- Serialization swaps Polygon coordinates HOT 6
- Serializer ignores the PrecisionModel of geometries (STJ) HOT 1
- Serializer ignores SRID HOT 3
- NettopologySuite.IO.GeoJSON.dll is not digitally signed when delivered HOT 4
- Add additional TFM to eliminate explicit dependency
- Exception thrown when trying to deserialize a Feature, FeatureCollection, or Geometry with unrecognized properties during a partial read
- MultiPolygon "coordinates" member should support empty Polygon arrays inside of it.
- Serializing GeoJSON does not include CRS HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nettopologysuite.io.geojson.