Tabnine Logo
CRS.lookupIdentifier
Code IndexAdd Tabnine to your IDE (free)

How to use
lookupIdentifier
method
in
org.geotools.referencing.CRS

Best Java code snippets using org.geotools.referencing.CRS.lookupIdentifier (Showing top 20 results out of 315)

origin: geoserver/geoserver

GeneralEnvelope envelope = reader.getOriginalEnvelope();
GeneralEnvelope wgs84envelope = CoverageStoreUtils.getWGS84LonLatEnvelope(envelope);
final String nativeCrsName = CRS.lookupIdentifier(crs, false);
writer.write(
    "<envelope crs=\""
origin: geotools/geotools

  /**
   * Returns true if the specified CRS can be used directly to perform WMS requests. Natively
   * supported crs will provide the best rendering quality as no client side reprojection is
   * necessary, the image coming from the WMS server will be used as-is
   *
   * @param crs
   * @return
   */
  public boolean isNativelySupported(CoordinateReferenceSystem crs) {
    try {
      String code = CRS.lookupIdentifier(crs, false);
      return code != null && getReader().validSRS.contains(code);
    } catch (Throwable t) {
      return false;
    }
  }
}
origin: geotools/geotools

/**
 * Returns true if the specified CRS can be used directly to perform WMTS requests.
 *
 * <p>Natively supported crs will provide the best rendering quality as no client side
 * reprojection is necessary, the tiles coming from the WMTS server will be used as-is
 *
 * @param crs
 * @return
 */
public boolean isNativelySupported(CoordinateReferenceSystem crs) {
  try {
    String code = CRS.lookupIdentifier(crs, false);
    return code != null && getReader().validSRS.contains(code);
  } catch (Exception t) {
    return false;
  }
}
origin: geotools/geotools

/**
 * Create a properties map for the provided crs.
 *
 * @param crs CoordinateReferenceSystem or null for default
 * @return properties map naming crs identifier
 * @throws IOException
 */
Map<String, Object> createCRS(CoordinateReferenceSystem crs) throws IOException {
  Map<String, Object> obj = new LinkedHashMap<String, Object>();
  obj.put("type", "name");
  Map<String, Object> props = new LinkedHashMap<String, Object>();
  if (crs == null) {
    props.put("name", "EPSG:4326");
  } else {
    try {
      String identifier = CRS.lookupIdentifier(crs, true);
      props.put("name", identifier);
    } catch (FactoryException e) {
      throw (IOException) new IOException("Error looking up crs identifier").initCause(e);
    }
  }
  obj.put("properties", props);
  return obj;
}
origin: geotools/geotools

/**
 * Looks up an EPSG code for the given {@linkplain CoordinateReferenceSystem coordinate
 * reference system}). This is a convenience method for <code>{@linkplain
 * #lookupIdentifier(Citations, IdentifiedObject, boolean) lookupIdentifier}({@linkplain
 * Citations#EPSG}, crs, fullScan)</code> except that code is parsed as an integer.
 *
 * @param crs The coordinate reference system instance, or {@code null}.
 * @return The CRS identifier, or {@code null} if none was found.
 * @throws FactoryException if an error occured while searching for the identifier.
 * @since 2.5
 */
public static Integer lookupEpsgCode(
    final CoordinateReferenceSystem crs, final boolean fullScan) throws FactoryException {
  final String identifier = lookupIdentifier(Citations.EPSG, crs, fullScan);
  if (identifier != null) {
    final int split = identifier.lastIndexOf(GenericName.DEFAULT_SEPARATOR);
    final String code = identifier.substring(split + 1);
    // The above code works even if the separator was not found, since in such case
    // split == -1, which implies a call to substring(0) which returns 'identifier'.
    try {
      return Integer.parseInt(code);
    } catch (NumberFormatException e) {
      throw new FactoryException(
          Errors.format(ErrorKeys.ILLEGAL_IDENTIFIER_$1, identifier), e);
    }
  }
  return null;
}
origin: geotools/geotools

String srs = null;
try {
  srs = CRS.lookupIdentifier(getCoordinateReferenceSystem(), false);
} catch (FactoryException e) {
  java.util.logging.Logger.getGlobal().log(java.util.logging.Level.INFO, "", e);
origin: geotools/geotools

/**
 * GEOT-1702, make sure looking up for an existing code does not result in a {@link
 * StackOverflowException}.
 *
 * @throws FactoryException If the CRS can't be created.
 */
@Test
public void testLookupSuccessfull() throws FactoryException {
  CoordinateReferenceSystem crs = CRS.decode("EPSG:42101");
  String code = CRS.lookupIdentifier(crs, true);
  assertEquals("EPSG:42101", code);
}
origin: geotools/geotools

/**
 * GEOT-1702, make sure looking up for a non existing code does not result in a {@link
 * StackOverflowException}.
 *
 * @throws FactoryException If the CRS can't be created.
 */
@Test
public void testLookupFailing() throws FactoryException {
  CoordinateReferenceSystem crs = CRS.parseWKT(WKT.MERCATOR_GOOGLE);
  assertNull(CRS.lookupIdentifier(crs, true));
}
origin: geotools/geotools

/**
 *
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated modifiable
 */
public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
  SpatialSubsetType spatialSubset = Wcs10Factory.eINSTANCE.createSpatialSubsetType();
  List<Node> envelopes = node.getChildren("Envelope");
  for (Node envelopeNode : envelopes) {
    ReferencedEnvelope envelope = (ReferencedEnvelope) envelopeNode.getValue();
    EnvelopeType env = Gml4wcsFactory.eINSTANCE.createEnvelopeType();
    env.setSrsName(CRS.lookupIdentifier(envelope.getCoordinateReferenceSystem(), true));
    DirectPositionType pos1 = Gml4wcsFactory.eINSTANCE.createDirectPositionType();
    DirectPositionType pos2 = Gml4wcsFactory.eINSTANCE.createDirectPositionType();
    pos1.setDimension(BigInteger.valueOf(2));
    pos2.setDimension(BigInteger.valueOf(2));
    pos1.setValue(Arrays.asList(envelope.getMinX(), envelope.getMinY()));
    pos2.setValue(Arrays.asList(envelope.getMaxX(), envelope.getMaxY()));
    env.getPos().add(pos1);
    env.getPos().add(pos2);
    spatialSubset.getEnvelope().add(envelope);
  }
  List<Node> gridsNode = node.getChildren("Grid");
  for (Node grid : gridsNode) spatialSubset.getGrid().add(grid.getValue());
  return spatialSubset;
}
origin: geotools/geotools

  return CRS.lookupIdentifier(envelope.getCoordinateReferenceSystem(), true);
} catch (FactoryException e) {
  return null;
origin: geotools/geotools

} else {
  code = CRS.lookupIdentifier(bbox.getCoordinateReferenceSystem(), false);
origin: org.geoserver.extension/wps-core

/**
 * Encodes the internal object representation of a parameter as a string.
 */
public String encode(Object value) throws Exception {
  if (value == null) {
    return null;
  }
  return CRS.lookupIdentifier(((CoordinateReferenceSystem) value), true);
}
origin: org.geoserver.extension/gs-wps-core

  /** Encodes the internal object representation of a parameter as a string. */
  public String encode(Object value) throws Exception {
    if (value == null) {
      return null;
    }
    return CRS.lookupIdentifier(((CoordinateReferenceSystem) value), true);
  }
}
origin: geotools/geotools

/** Tests {@link CRS#lookupIdentifier}. */
public void testFind() throws FactoryException {
  CoordinateReferenceSystem crs = getED50("ED50");
  assertEquals(
      "Should find without scan thanks to the name.",
      "EPSG:4230",
      CRS.lookupIdentifier(crs, false));
  assertEquals(Integer.valueOf(4230), CRS.lookupEpsgCode(crs, false));
  crs = getED50("ED50 with unknown name");
  if (supportsED50QuickScan()) {
    assertEquals(
        "With scan allowed, should find the CRS.",
        "EPSG:4230",
        CRS.lookupIdentifier(crs, false));
    assertEquals(Integer.valueOf(4230), CRS.lookupEpsgCode(crs, false));
  } else {
    assertNull("Should not find the CRS without a scan.", CRS.lookupIdentifier(crs, false));
    assertEquals(null, CRS.lookupEpsgCode(crs, false));
  }
  assertEquals(
      "With scan allowed, should find the CRS.",
      "EPSG:4230",
      CRS.lookupIdentifier(crs, true));
  assertEquals(Integer.valueOf(4230), CRS.lookupEpsgCode(crs, true));
}
origin: geotools/geotools

code = CRS.lookupIdentifier(bbox.getCoordinateReferenceSystem(), false);
origin: geotools/geotools

/** Sets the CRS. */
private void setCRS() {
  if (mapPane != null && mapPane.getMapContent() != null) {
    String initial = null;
    CoordinateReferenceSystem crs = mapPane.getMapContent().getCoordinateReferenceSystem();
    if (crs != null) {
      try {
        initial = CRS.lookupIdentifier(Citations.EPSG, crs, false);
      } catch (Exception ex) {
        // do nothing
      }
    }
    CoordinateReferenceSystem newCRS = JCRSChooser.showDialog(null, initial, "EPSG");
    if (newCRS != null && (crs == null || !CRS.equalsIgnoreMetadata(crs, newCRS))) {
      try {
        mapPane.getMapContent().getViewport().setCoordinateReferenceSystem(newCRS);
      } catch (Exception ex) {
        JExceptionReporter.showDialog(ex, "Failed to set the requested CRS");
      }
    }
  }
}
origin: org.geoserver/wcs1_1

private String urnIdentifier(final CoordinateReferenceSystem crs) throws FactoryException {
  String authorityAndCode = CRS.lookupIdentifier(crs, false);
  String code = authorityAndCode.substring(authorityAndCode.lastIndexOf(":") + 1);
  // we don't specify the version, but we still need to put a space
  // for it in the urn form, that's why we have :: before the code
  return "urn:ogc:def:crs:EPSG::" + code;
}
origin: org.geoserver/gs-wcs1_0

private String urnIdentifier(final CoordinateReferenceSystem crs) throws FactoryException {
  String authorityAndCode = CRS.lookupIdentifier(crs, false);
  String code = authorityAndCode.substring(authorityAndCode.lastIndexOf(":") + 1);
  // we don't specify the version, but we still need to put a space
  // for it in the urn form, that's why we have :: before the code
  return "urn:ogc:def:crs:EPSG::" + code;
}
origin: org.geoserver/gs-wcs1_1

protected String urnIdentifier(final CoordinateReferenceSystem crs)
    throws FactoryException {
  String authorityAndCode = CRS.lookupIdentifier(crs, false);
  String code = authorityAndCode.substring(authorityAndCode.lastIndexOf(":") + 1);
  // we don't specify the version, but we still need to put a space
  // for it in the urn form, that's why we have :: before the code
  return "urn:ogc:def:crs:EPSG::" + code;
}
origin: org.geoserver.importer/importer-core

public SimpleFeatureType apply(ImportTask task, DataStore dataStore,
    SimpleFeatureType featureType) throws Exception {
  //update the layer metadata
  ResourceInfo r = task.getLayer().getResource();
  r.setNativeCRS(target);
  r.setSRS(CRS.lookupIdentifier(target, true));
  if (r.getNativeBoundingBox() != null) {
    r.setNativeBoundingBox(r.getNativeBoundingBox().transform(target, true));
  }
  //retype the schema
  return SimpleFeatureTypeBuilder.retype(featureType, target);
}
org.geotools.referencingCRSlookupIdentifier

Javadoc

Looks up an identifier of the specified authority for the given CoordinateReferenceSystem). This method is similar to #lookupIdentifier(IdentifiedObject,boolean)(object, fullScan) except that the search is performed only among the factories of the given authority.

If the CRS does not have an ReferenceIdentifier which corresponds to the Citations#EPSG authority, then:

  • if fullScan is true, then this method scans the factories in search for an object #equalsIgnoreMetadata, to the given object. If one is found, its identifier is returned.
  • Otherwise (if fullScan is false or if no identifier was found in the previous step), this method returns null.

Popular methods of CRS

  • decode
  • findMathTransform
  • equalsIgnoreMetadata
  • parseWKT
  • lookupEpsgCode
  • transform
    Implementation of #transform(MathTransform,Envelope) with the opportunity to save the projected cent
  • getAxisOrder
  • toSRS
  • getHorizontalCRS
  • getEnvelope
  • getCoordinateOperationFactory
  • getAuthorityFactory
  • getCoordinateOperationFactory,
  • getAuthorityFactory,
  • getMapProjection,
  • getSupportedCodes,
  • getGeographicBoundingBox,
  • reset,
  • getEllipsoid,
  • getProjectedCRS,
  • getTemporalCRS

Popular in Java

  • Creating JSON documents from java classes using gson
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getExternalFilesDir (Context)
  • getSupportFragmentManager (FragmentActivity)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • JTextField (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now