Skip to content
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

Add reading Feature properties to GeoJsonReader #933

Open
mipastgt opened this issue Nov 18, 2022 · 1 comment
Open

Add reading Feature properties to GeoJsonReader #933

mipastgt opened this issue Nov 18, 2022 · 1 comment

Comments

@mipastgt
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@mipastgt and others