private static Crs createCrsForEpsgCode(int epsgCode) { Crs crs = new Crs(); crs.setType(CrsType.name); String crsURN = CRS_URN_BASE_EPSG + epsgCode; crs.setProperties(Collections.unmodifiableMap(Stream.of(new SimpleEntry<>("name", crsURN)) .collect(Collectors.toMap(Entry::getKey, Entry::getValue)))); return crs; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; GeoJsonObject that = (GeoJsonObject)o; if (crs != null ? !crs.equals(that.crs) : that.crs != null) return false; return Arrays.equals(bbox, that.bbox); }
@Override public int hashCode() { int result = crs != null ? crs.hashCode() : 0; result = 31 * result + (bbox != null ? Arrays.hashCode(bbox) : 0); return result; }
public static MultiPolygon toJts(org.geojson.MultiPolygon mPoly) { String geoJsonCrs = mPoly.getCrs().getProperties().get(org.geojson.jackson.CrsType.name.name()).toString(); GeometryFactory gf = new GeometryFactory(new PrecisionModel(), Integer.parseInt(geoJsonCrs.substring(CRS_URN_BASE_EPSG.length()))); List<Polygon> polys = new ArrayList<>(); for (List<List<LngLatAlt>> polygonsCoordinates:mPoly.getCoordinates()) { List<LngLatAlt> extRing = polygonsCoordinates.get(0); polys.add(toJts(extRing, gf)); } return gf.createMultiPolygon(polys.toArray(new Polygon[polys.size()])); }
public static Polygon toJts(org.geojson.Polygon polygon) { if (polygon.getInteriorRings().size() > 0) { throw new UnsupportedOperationException("Only polygons without holes are supported!"); } String geoJsonCrs = polygon.getCrs().getProperties().get(org.geojson.jackson.CrsType.name.name()).toString(); GeometryFactory gf = new GeometryFactory(new PrecisionModel(), Integer.parseInt(geoJsonCrs.substring(CRS_URN_BASE_EPSG.length()))); return toJts(polygon.getExteriorRing(), gf); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; GeoJsonObject that = (GeoJsonObject)o; if (crs != null ? !crs.equals(that.crs) : that.crs != null) return false; return Arrays.equals(bbox, that.bbox); }
@Override public int hashCode() { int result = crs != null ? crs.hashCode() : 0; result = 31 * result + (bbox != null ? Arrays.hashCode(bbox) : 0); return result; }