locationtech / locationtech/jts

Add reading Feature properties to GeoJsonReader

Open
#933 0 comments 10 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.