congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
CRS.lookupEpsgCode
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: geoserver/geoserver

@Override
public String toString(Object obj) {
  CoordinateReferenceSystem crs = (CoordinateReferenceSystem) obj;
  try {
    Integer epsg = CRS.lookupEpsgCode(crs, false);
    if (epsg != null) {
      return "EPSG:" + epsg;
    }
  } catch (FactoryException e) {
    XStreamPersister.LOGGER.warning(
        "Could not determine epsg code of crs, encoding as WKT");
  }
  return new CRSConverter().toString(crs);
}
origin: geoserver/geoserver

  Integer code = CRS.lookupEpsgCode(crs, extensive);
  if (code != null) ftinfo.setSRS("EPSG:" + code);
} catch (FactoryException e) {
origin: geoserver/geoserver

Integer code = CRS.lookupEpsgCode(nativeCRS, false);
if (code != null) {
  cinfo.setSRS("EPSG:" + code);
origin: geoserver/geoserver

@Test
public void testReprojectLayerGroup()
    throws NoSuchAuthorityCodeException, FactoryException, Exception {
  Catalog catalog = getCatalog();
  CatalogBuilder cb = new CatalogBuilder(catalog);
  LayerGroupInfo lg = catalog.getFactory().createLayerGroup();
  LayerInfo l = catalog.getLayerByName(getLayerId(MockData.ROAD_SEGMENTS));
  lg.getLayers().add(l);
  lg.getStyles().add(null);
  lg.setName("test-reproject");
  // EPSG:4901 "equivalent" but different uom
  String wkt =
      "GEOGCS[\"GCS_ATF_Paris\",DATUM[\"D_ATF\",SPHEROID[\"Plessis_1817\",6376523.0,308.64]],PRIMEM[\"Paris\",2.337229166666667],UNIT[\"Grad\",0.01570796326794897]]";
  CoordinateReferenceSystem lCrs = CRS.parseWKT(wkt);
  ((FeatureTypeInfo) l.getResource()).setSRS(null);
  ((FeatureTypeInfo) l.getResource()).setNativeCRS(lCrs);
  assertNull(CRS.lookupEpsgCode(lCrs, false));
  // Use the real thing now
  CoordinateReferenceSystem lgCrs = CRS.decode("EPSG:4901");
  assertNotNull(CRS.lookupEpsgCode(lgCrs, false));
  // Reproject our layer group to EPSG:4901. We expect it to have an EPSG code.
  cb.calculateLayerGroupBounds(lg, lgCrs);
  assertNotNull(CRS.lookupEpsgCode(lg.getBounds().getCoordinateReferenceSystem(), false));
}
origin: geoserver/geoserver

Integer code = CRS.lookupEpsgCode(nativeCRS, false);
if (code != null) {
  cinfo.setSRS("EPSG:" + code);
origin: geotools/geotools

static Integer findSRID(GridCoverage2D raster) throws Exception {
  return CRS.lookupEpsgCode(raster.getCoordinateReferenceSystem(), true);
}
origin: geotools/geotools

static Integer findSRID(ReferencedEnvelope e) throws Exception {
  return CRS.lookupEpsgCode(e.getCoordinateReferenceSystem(), true);
}
origin: geotools/geotools

  static DBObject encodeCRSToGeoJSON(CoordinateReferenceSystem crs) {
    if (crs == null) {
      return null;
    }
    Integer epsgCode = null;
    try {
      epsgCode = CRS.lookupEpsgCode(crs, true);
    } catch (FactoryException ignore) {
    }
    if (epsgCode == null) {
      return null;
    }
    DBObject crsDBO = new BasicDBObject(KEY_type, VALUE_name);
    crsDBO.put(
        KEY_properties, new BasicDBObject(KEY_name, PREFIX_URN_OGC + "EPSG:" + epsgCode));
    return crsDBO;
  }
}
origin: geotools/geotools

/**
 * Computes the declared SRS of a layer based on the layer schema and the EPSG forcing flag
 *
 * @param schema
 * @return
 * @throws FactoryException
 * @throws NoSuchAuthorityCodeException
 */
private CoordinateReferenceSystem getDeclaredSRS(FeatureType schema) throws FactoryException {
  // compute the default SRS of the feature source
  CoordinateReferenceSystem declaredCRS = schema.getCoordinateReferenceSystem();
  if (isEPSGAxisOrderForced()) {
    Integer code = CRS.lookupEpsgCode(declaredCRS, false);
    if (code != null) {
      declaredCRS = CRS.decode("urn:ogc:def:crs:EPSG::" + code);
    }
  }
  return declaredCRS;
}
origin: geotools/geotools

private static org.opengis.geometry.Envelope getCRSEnvelope(CoordinateReferenceSystem targetCRS)
    throws FactoryException, NoSuchAuthorityCodeException {
  if (targetCRS.getDomainOfValidity() == null) {
    Integer code = CRS.lookupEpsgCode(targetCRS, true);
    if (code != null) {
      CRS.decode("EPSG:" + code, CRS.getAxisOrder(targetCRS) != AxisOrder.NORTH_EAST);
    }
  }
  org.opengis.geometry.Envelope envelope = CRS.getEnvelope(targetCRS);
  return envelope;
}
origin: geotools/geotools

Integer epsgCode = CRS.lookupEpsgCode(crs, false);
if (epsgCode == null) {
  throw new IllegalArgumentException(
origin: geotools/geotools

static Integer findSRID(SimpleFeatureType schema) throws Exception {
  CoordinateReferenceSystem crs = schema.getCoordinateReferenceSystem();
  if (crs == null) {
    GeometryDescriptor gd = findGeometryDescriptor(schema);
    crs = gd.getCoordinateReferenceSystem();
  }
  return crs != null ? CRS.lookupEpsgCode(crs, true) : null;
}
origin: geotools/geotools

@Test
public void testLookup() throws NoSuchAuthorityCodeException, FactoryException {
  CoordinateReferenceSystem crs = CRS.decode("EPSG:" + CODE);
  assertEquals(Integer.valueOf(CODE), CRS.lookupEpsgCode(crs, true));
  assertEquals(Integer.valueOf(CODE), CRS.lookupEpsgCode(crs, false));
}
origin: geotools/geotools

CoordinateReferenceSystem crs = (CoordinateReferenceSystem) g.getUserData();
try {
  Integer code = CRS.lookupEpsgCode(crs, false);
  if (code != null) {
    ai.addAttribute("", "srsName", "", "anyURI", "EPSG:" + code);
origin: geotools/geotools

  gc.setSRID(CRS.lookupEpsgCode(crs, true));
} catch (FactoryException e) {
origin: geotools/geotools

/** Encodes the given geometry with no srsName attribute and forcing 2D */
public void encode(Geometry geometry) {
  String srsName = null;
  // see if we have a EPSG CRS attached to the geometry
  if (geometry.getUserData() instanceof CoordinateReferenceSystem) {
    try {
      CoordinateReferenceSystem crs =
          (CoordinateReferenceSystem) geometry.getUserData();
      Integer code = CRS.lookupEpsgCode(crs, false);
      if (code != null) {
        if (AxisOrder.NORTH_EAST.equals(CRS.getAxisOrder(crs))) {
          srsName = "urn:ogc:def:crs:EPSG::" + code;
        } else {
          srsName = "EPSG:" + code;
        }
      }
    } catch (Exception e) {
      LOGGER.fine("Failed to encode the CoordinateReferenceSystem into a srsName");
    }
  }
  encode(geometry, srsName);
}
origin: geotools/geotools

/**
 * Looks up the geometry srs by trying a number of heuristics. Returns -1 if all attempts at
 * guessing the srid failed.
 */
protected int getGeometrySRID(Geometry g, AttributeDescriptor descriptor) throws IOException {
  int srid = getDescriptorSRID(descriptor);
  if (g == null) {
    return srid;
  }
  // check for srid in the jts geometry then
  if (srid <= 0 && g.getSRID() > 0) {
    srid = g.getSRID();
  }
  // check if the geometry has anything
  if (srid <= 0 && g.getUserData() instanceof CoordinateReferenceSystem) {
    // check for crs object
    CoordinateReferenceSystem crs = (CoordinateReferenceSystem) g.getUserData();
    try {
      Integer candidate = CRS.lookupEpsgCode(crs, false);
      if (candidate != null) srid = candidate;
    } catch (Exception e) {
      // ok, we tried...
    }
  }
  return srid;
}
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

public void testSchema() throws Exception {
  SimpleFeatureType schema = dataStore.getSchema(tname(getLine3d()));
  CoordinateReferenceSystem crs =
      schema.getGeometryDescriptor().getCoordinateReferenceSystem();
  assertEquals(Integer.valueOf(getEpsgCode()), CRS.lookupEpsgCode(crs, false));
  assertEquals(
      getNativeSRID(),
      schema.getGeometryDescriptor().getUserData().get(JDBCDataStore.JDBC_NATIVE_SRID));
  assertEquals(
      3, schema.getGeometryDescriptor().getUserData().get(Hints.COORDINATE_DIMENSION));
}
origin: geotools/geotools

public void testSchema() throws Exception {
  if (!isGeographySupportAvailable()) {
    return;
  }
  SimpleFeatureType ft = dataStore.getFeatureSource(tname("geopoint")).getSchema();
  assertNotNull(ft);
  assertTrue(ft.getDescriptor(aname("geo")) instanceof GeometryDescriptor);
  assertEquals(Point.class, ft.getDescriptor("geo").getType().getBinding());
  int epsg =
      CRS.lookupEpsgCode(
          ((GeometryDescriptor) ft.getDescriptor(aname("geo")))
              .getCoordinateReferenceSystem(),
          false);
  assertEquals(4326, epsg);
}
org.geotools.referencingCRSlookupEpsgCode

Javadoc

Looks up an EPSG code for the given CoordinateReferenceSystem). This is a convenience method for #lookupIdentifier(Citations,IdentifiedObject,boolean)( Citations#EPSG, crs, fullScan) except that code is parsed as an integer.

Popular methods of CRS

  • decode
  • findMathTransform
  • equalsIgnoreMetadata
  • parseWKT
  • transform
  • getAxisOrder
  • lookupIdentifier
  • toSRS
  • getHorizontalCRS
  • getEnvelope
  • getCoordinateOperationFactory
  • getAuthorityFactory
  • getCoordinateOperationFactory,
  • getAuthorityFactory,
  • getMapProjection,
  • getSupportedCodes,
  • getGeographicBoundingBox,
  • reset,
  • getEllipsoid,
  • getProjectedCRS,
  • getTemporalCRS

Popular in Java

  • Reading from database using SQL prepared statement
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • requestLocationUpdates (LocationManager)
  • notifyDataSetChanged (ArrayAdapter)
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • From CI to AI: The AI layer in your organization
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