if ((nativeCRS.getIdentifiers() != null) && !nativeCRS.getIdentifiers().isEmpty()) { cinfo.getRequestSRS() .add(((Identifier) nativeCRS.getIdentifiers().toArray()[0]).toString()); cinfo.getResponseSRS() .add(((Identifier) nativeCRS.getIdentifiers().toArray()[0]).toString());
if (nativeCRS != null && !nativeCRS.getIdentifiers().isEmpty()) { cinfo.setProjectionPolicy(ProjectionPolicy.REPROJECT_TO_DECLARED);
/** * getCRS * * @return CoordinateReferenceSystem */ protected CoordinateReferenceSystem getCRS() { LOGGER.fine("getCRS Method"); CoordinateReferenceSystem crs = null; try { crs = CRS.decode(config.getCoordsys()); LOGGER.fine("CRS get Identifier" + crs.getIdentifiers()); } catch (Exception e) { LOGGER.severe("Cannot parse Decode CRS from Config File " + e.getMessage()); throw new RuntimeException(e); } LOGGER.fine("Returning CRS Result"); return crs; }
/** * @param crs * @return */ protected Collection<String> extractCRSNames(CoordinateReferenceSystem crs) { Collection<String> identifiers = new ArrayList<String>(); for (ReferenceIdentifier identifier : crs.getIdentifiers()) { String srsName = identifier.toString(); identifiers.add(srsName); if (srsName.startsWith("EPSG:")) { String urn = srsName.replace("EPSG:", "urn:ogc:def:crs:EPSG::"); identifiers.add(urn); } if (srsName.contains("900913")) { identifiers.add("EPSG:3857"); } if (srsName.equalsIgnoreCase("EPSG:3857")) { identifiers.add("urn:ogc:def:crs:EPSG::900913"); } } if (crs == DefaultGeographicCRS.WGS84 || crs == DefaultGeographicCRS.WGS84_3D) { identifiers.add("CRS:84"); } return identifiers; }
/** * Quickly review provided crs checking for an "EPSG:SRID" reference identifier. * * <p> * * @see CRS#lookupEpsgCode(CoordinateReferenceSystem, boolean) for full search * @param crs * @return srid or -1 if not found */ private static int toSRID(CoordinateReferenceSystem crs) { if (crs == null || crs.getIdentifiers() == null) { return -1; // not found } for (Iterator<ReferenceIdentifier> it = crs.getIdentifiers().iterator(); it.hasNext(); ) { ReferenceIdentifier id = it.next(); Citation authority = id.getAuthority(); if (authority != null && authority.getTitle().equals(Citations.EPSG.getTitle())) { try { return Integer.parseInt(id.getCode()); } catch (NumberFormatException nanException) { continue; } } } return -1; }
public static String epsgCode(CoordinateReferenceSystem crs) { if (crs == null) { return null; } for (Iterator i = crs.getIdentifiers().iterator(); i.hasNext(); ) { Identifier id = (Identifier) i.next(); // return "EPSG:" + id.getCode(); if ((id.getAuthority() != null) && id.getAuthority().getTitle().equals(Citations.EPSG.getTitle())) { return id.getCode(); } } return null; }
Iterator iter = crs.getIdentifiers().iterator(); while (iter.hasNext()) { Identifier ident = (Identifier) iter.next();
Set<ReferenceIdentifier> identifiers = crs.getIdentifiers(); if (identifiers.isEmpty()) { } else { for (ReferenceIdentifier identifier : crs.getIdentifiers()) { String srs = identifier.toString(); if (srs.contains("EPSG:") || srs.contains("CRS:")) {
gDescr.getCoordinateReferenceSystem().getIdentifiers()) { PreparedStatement ps1 = cx.prepareStatement(SELECT_SRS_NAME_FROM_ORG); ps1.setString(1, ident.getCodeSpace());
GeometryDescriptor gd = (GeometryDescriptor) type; if (gd.getCoordinateReferenceSystem() != null && gd.getCoordinateReferenceSystem().getIdentifiers() != null) { for (Iterator<ReferenceIdentifier> it = gd.getCoordinateReferenceSystem().getIdentifiers().iterator(); it.hasNext(); ) { ReferenceIdentifier id = it.next();
public NetCDFImageMetadata( String variableName, SampleModel sm, ColorModel cm, CoordinateReferenceSystem crs) { super(true, nativeMetadataFormatName, nativeMetadataFormatClassName, null, null); setDatasetName(variableName); // width and height, tile structure assuming row based setWidth(sm.getWidth()); setHeight(sm.getHeight()); setTileWidth(sm.getWidth()); setTileHeight(1); // color and sample models and information coming from them setColorModel(cm); setSampleModel(sm); setNumBands(sm.getNumBands()); try { if (crs != null) { // attempt to set projection description setProjection(crs.getIdentifiers().iterator().next().toString()); } } catch (Exception e) { LOGGER.log(Level.FINE, "Could not add the projection information into the metadata", e); } } }
/** * Tests the {@code 18001} code. * * @throws FactoryException If the CRS can't be created. */ @Test public void test42101() throws FactoryException { CoordinateReferenceSystem actual, expected; expected = factory.createCoordinateReferenceSystem("42101"); actual = CRS.decode("EPSG:42101"); assertSame(expected, actual); assertTrue(actual instanceof ProjectedCRS); Collection ids = actual.getIdentifiers(); assertTrue(ids.contains(new NamedIdentifier(Citations.EPSG, "42101"))); assertFalse(ids.contains(new NamedIdentifier(Citations.ESRI, "42101"))); } }
Set<ReferenceIdentifier> ids = crs.getIdentifiers(); if (ids == null || ids.isEmpty()) { LOGGER.warning(
indexSchema, DataUtilities.attributeNames(indexSchema), actualCRS); if (actualCRS != null) { Set<ReferenceIdentifier> identifiers = actualCRS.getIdentifiers(); if (identifiers == null || identifiers.isEmpty()) { Integer code = CRS.lookupEpsgCode(actualCRS, true);
/** * Returns the spatial reference id for a given coordinate reference system. * If the coordinate reference system has multiple identifiers one is * randomly selected. * * @param crs * a coordinate reference system. * * @return the spatial reference id for the coordinate reference system or * <tt>0</tt> if the coordinate reference system has no identifiers. */ public static int getSRID(CoordinateReferenceSystem crs) { /* * Randomly get one identifier. */ Identifier identifier = (Identifier) (crs.getIdentifiers().iterator().next()); if (identifier == null) { return 0; } else { return Integer.parseInt(identifier.getCode()); } }
public static String epsgCode(CoordinateReferenceSystem crs) { if (crs == null) { return null; } for (Iterator i = crs.getIdentifiers().iterator(); i.hasNext();) { Identifier id = (Identifier) i.next(); //return "EPSG:" + id.getCode(); if ((id.getAuthority() != null) && id.getAuthority().getTitle().equals(Citations.EPSG.getTitle())) { return id.getCode(); } } return null; }
/** * Gets the {@literal Proj.4} object from the given coordinate reference system. If an existing {@code PJ} * instance is found, returns it. Otherwise if {@code force} is {@code true}, creates a new {@code PJ} * instance from a Proj.4 definition inferred from the given CRS. * This method is the converse of {@link #createCRS(PJ, boolean)}. */ private PJ unwrapOrCreate(final CoordinateReferenceSystem crs, final boolean force) throws FactoryException { for (final Identifier id : crs.getIdentifiers()) { if (id instanceof PJ) { return (PJ) id; } } return force ? unique(new PJ(Proj4.definition(crs))) : null; }
/** * Gets the {@literal Proj.4} object from the given coordinate reference system. If an existing {@code PJ} * instance is found, returns it. Otherwise if {@code force} is {@code true}, creates a new {@code PJ} * instance from a Proj.4 definition inferred from the given CRS. * This method is the converse of {@link #createCRS(PJ, boolean)}. */ private PJ unwrapOrCreate(final CoordinateReferenceSystem crs, final boolean force) throws FactoryException { for (final Identifier id : crs.getIdentifiers()) { if (id instanceof PJ) { return (PJ) id; } } return force ? unique(new PJ(Proj4.definition(crs))) : null; }
private VectorCapabilitiesInfo getVectorCapabilitiesInfo(DataStore store, String typeName) { VectorCapabilitiesInfo vci = new VectorCapabilitiesInfo(); vci.setTypeName(typeName); String[] tt = typeName.split(":", 2); if (tt.length == 2) { vci.setNamespace(tt[0]); vci.setName(tt[1]); } else { vci.setName(typeName); } try { SimpleFeatureType sft = store.getSchema(typeName); vci.setDescription((sft.getDescription() != null ? sft.getDescription().toString() : "")); vci.setCrs(sft.getCoordinateReferenceSystem().getIdentifiers().iterator().next().toString()); vci.setGeometryType((sft.getGeometryDescriptor() != null ? sft.getGeometryDescriptor() .getType().getBinding().getSimpleName() : "?")); } catch (Exception e) { vci.setDescription("[Failed retrieving metadata!]"); LOG.debug("Failed retrieving metadata: ", e); } return vci; }
/** * Tests the {@code 27572} code. * * @throws FactoryException If the CRS can't be created. */ @Test public void test27572() throws FactoryException { final CoordinateReferenceSystem crs = factory.createCoordinateReferenceSystem("27572"); assertTrue(crs instanceof ProjectedCRS); final Collection<Identifier> ids = crs.getIdentifiers(); assertTrue (ids.contains(new ImmutableIdentifier(Citations.EPSG, "EPSG", "27572"))); assertFalse(ids.contains(new ImmutableIdentifier(Citations.ESRI, "EPSG", "27572"))); assertSame("Should be able to trim the authority namespace", crs, factory.createCoordinateReferenceSystem("EPSG:27572")); } }