locationtech / locationtech/jts
Add reading Feature properties to GeoJsonReader
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.2k
- Forks
- 475
- Avg merge
- 14d 10h
- Merged PRs (30d)
- 1
Description
The current GeoJsonReader can import a whole FeatureCollection but it is difficult to later identify each Feature by its geometry. I think it would be very helpful to add the properties of a Feature as user data to the Feature geometry. For my own purposes I had to modify just one method in the current GeoJsonReader to achieve that.
private Geometry createFeature(Map<String, Object> geometryMap, GeometryFactory geometryFactory)
throws ParseException {
try {
@SuppressWarnings("unchecked")
Map<String, Object> innerGeometryMap = (Map<String, Object>) geometryMap.get(GeoJsonConstants.NAME_GEOMETRY);
@SuppressWarnings("unchecked")
Map<String, Object> properties = (Map<String, Object>) geometryMap.get(GeoJsonConstants.NAME_PROPERTIES);
Geometry geometry = create(innerGeometryMap, geometryFactory);
geometry.setUserData(properties);
return geometry;
} catch (RuntimeException e) {
throw new ParseException("Could not parse Feature from GeoJson string.", e);
}
}
It would be nice if this could be added to the official GeoJsonReader.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in GeoJsonReader at the createFeature method shown in the issue and inspect how Feature geometry is created from its properties. Done means imported Feature geometries retain their Feature properties as user data, with behavior verified against the existing GeoJsonReader coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- data
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100