-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No support for Feature & FeatureCollection in GeoJson #419
Comments
The problem is that JTS has no notion of attributes. So it's not clear how these would be provided to the GeoJSON I/O classes, or in fact whether to do this. The GeoJSON IO classes were really provided to be embedded in other JSON frameworks which needed to handled geometry. |
If I parse the Feature & FeatureCollection, will it be possible to hand the inner geometry type to JTS as a string and get a Geometry back, or should I construct everything manually? Or is there some other approach? |
Yes, that is the target use case for the GeoJSONReader.
I will check with the original author of these classes to see what his architecture was. |
The GeoJSONReader class is designed to be used in the context of JSON frameworks which allow custom deserializers to be defined. E.g. the Jackson API. Here's a (partial) code snippet which shows how it can be used in Jackson: import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.ObjectCodec;
import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.JsonDeserializer;
public class GeoJsonJacksonDeserializer extends JsonDeserializer<Geometry>
{
public Geometry deserialize(JsonParser jsonParser, DeserializationContext context)
{
ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);
String geoJson = node.toString();
GeoJsonReader geoJsonReader = new GeoJsonReader();
Reader reader = new StringReader(geoJson);
Geometry result = geoJsonReader.read(reader); |
@dr-jts Would it be a fair compromise to reduce GeoJSON's |
@danishnawab yes, that seems like a reasonable extension. A PR for review is welcome. |
@dr-jts Is there a specific reason not to include a dedicated Jackson module such as e.g. this one into jts-io-common? If not, would there be interest in a PR for such an addition? |
Hi
Feature & FeatureCollection is part of GeoJson spec for quite some time, and yet to be implemented in JTS (nor in Spatial4J).
Do you plan on releasing an implementation for it ?
The text was updated successfully, but these errors were encountered: