@Test public void TestProj() { String srs = "EPSG:4326"; JSONObj obj = new JSONObj(); IO.proj(obj, Proj.get().crs(srs), srs); assertEquals(srs, obj.str("srs")); assertNotNull(obj.get("wkt")); srs = "EPSG:3031"; obj = new JSONObj(); IO.proj(obj, Proj.get().crs(srs), srs); assertEquals(srs, obj.str("srs")); assertNotNull(obj.get("wkt")); }
public static JSONObj proj(JSONObj obj, CoordinateReferenceSystem crs, String srs) { if (srs == null && crs != null) { try { srs = CRS.toSRS(crs); } catch (Exception e) { LOG.log(Level.WARNING, "Unable to determine srs from crs: " + crs, e); } } if (crs != null && crs.getName() != null) { ReferenceIdentifier name = crs.getName(); if (name instanceof GenericName) { obj.put("title", ((GenericName) name).tip().toString()); } else { obj.put("title", name.toString()); } } if (srs != null) { obj.put("srs", srs); } else { obj.put("srs", "UNKNOWN"); } if (crs == null && srs != null) { try { crs = CRS.decode(srs); } catch (Exception e) { LOG.log(Level.WARNING, "Unable to determine crs from srs: " + srs, e); } } if (crs != null) { obj.put("type", crs instanceof ProjectedCRS ? "projected" : crs instanceof GeographicCRS ? "geographic" : "other"); String units = null; try { String unit = crs.getCoordinateSystem().getAxis(0).getUnit().toString(); if ("ft".equals(unit) || "feets".equals(unit)) units = "ft"; } catch (Exception e) { LOG.log(Level.WARNING, "Unable to determine units from crs", e); } if (units == null) { units = crs instanceof ProjectedCRS ? "m" : "degrees"; } obj.put("unit", units); obj.put("wkt", crs.toString()); } return obj; }
IO { public static JSONObj proj(JSONObj obj, CoordinateReferenceSystem crs, String srs) { if (srs == null && crs != null) { try { srs = CRS.toSRS(crs); } catch (Exception e) { LOG.log(Level.WARNING, "Unable to determine srs from crs: " + crs, e); } } if (crs != null && crs.getName() != null) { ReferenceIdentifier name = crs.getName(); if (name instanceof GenericName) { obj.put("title", ((GenericName) name).tip().toString()); } else { obj.put("title", name.toString()); } } if (srs != null) { obj.put("srs", srs); } else { obj.put("srs", "UNKNOWN"); } if (crs == null && srs != null) { try { crs = CRS.decode(srs); } catch (Exception e) { LOG.log(Level.WARNING, "Unable to determine crs from srs: " + srs, e); } } if (crs != null) { obj.put("type", crs instanceof ProjectedCRS ? "projected" : crs instanceof GeographicCRS ? "geographic" : "other"); String units = null; try { String unit = crs.getCoordinateSystem().getAxis(0).getUnit().toString(); if ("ft".equals(unit) || "feets".equals(unit)) units = "ft"; } catch (Exception e) { LOG.log(Level.WARNING, "Unable to determine units from crs", e); } if (units == null) { units = crs instanceof ProjectedCRS ? "m" : "degrees"; } obj.put("unit", units); obj.put("wkt", crs.toString()); } return obj; } }
IO { public static JSONObj proj(JSONObj obj, CoordinateReferenceSystem crs, String srs) { if (srs == null && crs != null) { try { srs = CRS.toSRS(crs); } catch (Exception e) { LOG.log(Level.WARNING, "Unable to determine srs from crs: " + crs, e); } } if (crs != null && crs.getName() != null) { ReferenceIdentifier name = crs.getName(); if (name instanceof GenericName) { obj.put("title", ((GenericName) name).tip().toString()); } else { obj.put("title", name.toString()); } } if (srs != null) { obj.put("srs", srs); } else { obj.put("srs", "UNKNOWN"); } if (crs == null && srs != null) { try { crs = CRS.decode(srs); } catch (Exception e) { LOG.log(Level.WARNING, "Unable to determine crs from srs: " + srs, e); } } if (crs != null) { obj.put("type", crs instanceof ProjectedCRS ? "projected" : crs instanceof GeographicCRS ? "geographic" : "other"); String units = null; try { String unit = crs.getCoordinateSystem().getAxis(0).getUnit().toString(); if ("ft".equals(unit) || "feets".equals(unit)) units = "ft"; } catch (Exception e) { LOG.log(Level.WARNING, "Unable to determine units from crs", e); } if (units == null) { units = crs instanceof ProjectedCRS ? "m" : "degrees"; } obj.put("unit", units); obj.put("wkt", crs.toString()); } return obj; }  }
IO { public static JSONObj proj(JSONObj obj, CoordinateReferenceSystem crs, String srs) { if (srs == null && crs != null) { try { srs = CRS.toSRS(crs); } catch (Exception e) { LOG.log(Level.WARNING, "Unable to determine srs from crs: " + crs, e); } } if (crs != null && crs.getName() != null) { ReferenceIdentifier name = crs.getName(); if (name instanceof GenericName) { obj.put("title", ((GenericName) name).tip().toString()); } else { obj.put("title", name.toString()); } } if (srs != null) { obj.put("srs", srs); } else { obj.put("srs", "UNKNOWN"); } if (crs == null && srs != null) { try { crs = CRS.decode(srs); } catch (Exception e) { LOG.log(Level.WARNING, "Unable to determine crs from srs: " + srs, e); } } if (crs != null) { obj.put("type", crs instanceof ProjectedCRS ? "projected" : crs instanceof GeographicCRS ? "geographic" : "other"); String units = null; try { String unit = crs.getCoordinateSystem().getAxis(0).getUnit().toString(); if ("ft".equals(unit) || "feets".equals(unit)) units = "ft"; } catch (Exception e) { LOG.log(Level.WARNING, "Unable to determine units from crs", e); } if (units == null) { units = crs instanceof ProjectedCRS ? "m" : "degrees"; } obj.put("unit", units); obj.put("wkt", crs.toString()); } return obj; }  static JSONObj proj(JSONObj obj, CoordinateReferenceSystem crs, String srs); static JSONObj bounds(JSONObj obj, org.opengis.geometry.Envelope bbox); static Envelope bounds(JSONObj obj); static CoordinateReferenceSystem crs(JSONObj obj); static String srs(JSONObj obj); static JSONObj workspace(JSONObj obj, WorkspaceInfo workspace, NamespaceInfo namespace, boolean isDefault); static JSONObj layer(JSONObj json, LayerInfo info, HttpServletRequest req); static JSONObj layerDetails(JSONObj obj, PublishedInfo layer, HttpServletRequest req); static JSONObj layerDetails(JSONObj obj, LayerGroupInfo group, HttpServletRequest req); @SuppressWarnings("unchecked") static JSONObj layerDetails(JSONObj obj, LayerInfo layer, HttpServletRequest req); static JSONObj bbox( JSONObj bbox, LayerGroupInfo l ); static JSONObj bbox( JSONObj bbox, ResourceInfo r ); static JSONObj schema( JSONObj schema, FeatureType type, boolean details); static JSONArr feature( JSONArr arr, Feature feature); static JSONArr features( JSONArr arr, FeatureCollection<FeatureType, Feature> features); static JSONObj schemaGrid( JSONObj schema, CoverageInfo info, boolean details ); static JSONObj schemaGrid( JSONObj schema, CoordinateReferenceSystem crs, boolean details); static JSONObj store(JSONObj obj, StoreInfo store, HttpServletRequest req, GeoServer geoServer); static JSONObj storeDetails(JSONObj json, StoreInfo store, HttpServletRequest req, GeoServer geoServer); static JSONObj resource(JSONObj obj, StoreInfo store, String name, GeoServer geoServer); static JSONObj error(JSONObj json, Throwable error); static JSONObj param(JSONObj json, Parameter<?> p); static void param(JSONObj json, Format g); static Object url(HttpServletRequest req, String path, Object ... args); static JSONObj ref(JSONObj obj, Ref ref); }
IO { public static JSONObj proj(JSONObj obj, CoordinateReferenceSystem crs, String srs) { if (srs == null && crs != null) { try { srs = CRS.toSRS(crs); } catch (Exception e) { LOG.log(Level.WARNING, "Unable to determine srs from crs: " + crs, e); } } if (crs != null && crs.getName() != null) { ReferenceIdentifier name = crs.getName(); if (name instanceof GenericName) { obj.put("title", ((GenericName) name).tip().toString()); } else { obj.put("title", name.toString()); } } if (srs != null) { obj.put("srs", srs); } else { obj.put("srs", "UNKNOWN"); } if (crs == null && srs != null) { try { crs = CRS.decode(srs); } catch (Exception e) { LOG.log(Level.WARNING, "Unable to determine crs from srs: " + srs, e); } } if (crs != null) { obj.put("type", crs instanceof ProjectedCRS ? "projected" : crs instanceof GeographicCRS ? "geographic" : "other"); String units = null; try { String unit = crs.getCoordinateSystem().getAxis(0).getUnit().toString(); if ("ft".equals(unit) || "feets".equals(unit)) units = "ft"; } catch (Exception e) { LOG.log(Level.WARNING, "Unable to determine units from crs", e); } if (units == null) { units = crs instanceof ProjectedCRS ? "m" : "degrees"; } obj.put("unit", units); obj.put("wkt", crs.toString()); } return obj; }  static JSONObj proj(JSONObj obj, CoordinateReferenceSystem crs, String srs); static JSONObj bounds(JSONObj obj, org.opengis.geometry.Envelope bbox); static Envelope bounds(JSONObj obj); static CoordinateReferenceSystem crs(JSONObj obj); static String srs(JSONObj obj); static JSONObj workspace(JSONObj obj, WorkspaceInfo workspace, NamespaceInfo namespace, boolean isDefault); static JSONObj layer(JSONObj json, LayerInfo info, HttpServletRequest req); static JSONObj layerDetails(JSONObj obj, PublishedInfo layer, HttpServletRequest req); static JSONObj layerDetails(JSONObj obj, LayerGroupInfo group, HttpServletRequest req); @SuppressWarnings("unchecked") static JSONObj layerDetails(JSONObj obj, LayerInfo layer, HttpServletRequest req); static JSONObj bbox( JSONObj bbox, LayerGroupInfo l ); static JSONObj bbox( JSONObj bbox, ResourceInfo r ); static JSONObj schema( JSONObj schema, FeatureType type, boolean details); static JSONArr feature( JSONArr arr, Feature feature); static JSONArr features( JSONArr arr, FeatureCollection<FeatureType, Feature> features); static JSONObj schemaGrid( JSONObj schema, CoverageInfo info, boolean details ); static JSONObj schemaGrid( JSONObj schema, CoordinateReferenceSystem crs, boolean details); static JSONObj store(JSONObj obj, StoreInfo store, HttpServletRequest req, GeoServer geoServer); static JSONObj storeDetails(JSONObj json, StoreInfo store, HttpServletRequest req, GeoServer geoServer); static JSONObj resource(JSONObj obj, StoreInfo store, String name, GeoServer geoServer); static JSONObj error(JSONObj json, Throwable error); static JSONObj param(JSONObj json, Parameter<?> p); static void param(JSONObj json, Format g); static Object url(HttpServletRequest req, String path, Object ... args); static JSONObj ref(JSONObj obj, Ref ref);  }