Codota Logo
CRS.decode
Code IndexAdd Codota to your IDE (free)

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

Best Java code snippets using org.geotools.referencing.CRS.decode (Showing top 20 results out of 1,710)

Refine searchRefine arrow

  • Test.<init>
  • Assert.assertEquals
  • ReferencedEnvelope.<init>
  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Charset c =
  • Codota IconString charsetName;Charset.forName(charsetName)
  • Codota IconCharset.defaultCharset()
  • Codota IconContentType contentType;contentType.getCharset()
  • Smart code suggestions by Codota
}
origin: opentripplanner/OpenTripPlanner

@Override
public BoundingBox getBoundingBox(CoordinateReferenceSystem crs) {
  try {
    Envelope bounds = (Envelope) pedestrianIndex.getRoot().getBounds();
    ReferencedEnvelope refEnv = new ReferencedEnvelope(bounds, CRS.decode("EPSG:4326", true));
    return refEnv.toBounds(crs);
  } catch (Exception e) {
    LOG.error("error transforming graph bounding box to request CRS : {}", crs);
    return null;
  }
}

origin: geoserver/geoserver

/**
 * Test method for {@link CoordinateOperationFactoryUsingWKT#createCoordinateOperation}.
 *
 * @throws TransformException
 */
@Test
public void testCreateOperationFromCustomCodes() throws Exception {
  // Test CRSs
  CoordinateReferenceSystem source = CRS.decode(SOURCE_CRS);
  CoordinateReferenceSystem target = CRS.decode(TARGET_CRS);
  MathTransform mt = CRS.findMathTransform(source, target, true);
  // Test MathTransform
  double[] p = new double[2];
  mt.transform(SRC_TEST_POINT, 0, p, 0, 1);
  assertEquals(p[0], DST_TEST_POINT[0], 1e-8);
  assertEquals(p[1], DST_TEST_POINT[1], 1e-8);
}
origin: geoserver/geoserver

@Test
public void testLatLonBounds() throws Exception {
  ReferencedEnvelope nativeBounds =
      new ReferencedEnvelope(700000, 800000, 4000000, 4100000, null);
  CoordinateReferenceSystem crs = CRS.decode("EPSG:32632", true);
  CatalogBuilder cb = new CatalogBuilder(getCatalog());
  ReferencedEnvelope re = cb.getLatLonBounds(nativeBounds, crs);
  assertEquals(DefaultGeographicCRS.WGS84, re.getCoordinateReferenceSystem());
  assertEquals(11.22, re.getMinX(), 0.01);
  assertEquals(36.1, re.getMinY(), 0.01);
}
origin: geoserver/geoserver

@Test
public void testWgs84BoundsFromCompoundCRS() throws Exception {
  try {
    MapProjection.SKIP_SANITY_CHECKS = true;
    CatalogBuilder cb = new CatalogBuilder(getCatalog());
    ReferencedEnvelope3D bounds =
        new ReferencedEnvelope3D(
            142892, 470783, 16, 142900, 470790, 20, CRS.decode("EPSG:7415"));
    // used to throw an exception here
    ReferencedEnvelope latLonBounds =
        cb.getLatLonBounds(bounds, bounds.getCoordinateReferenceSystem());
    assertTrue(
        CRS.equalsIgnoreMetadata(
            CRS.decode("EPSG:4326"), latLonBounds.getCoordinateReferenceSystem()));
    // System.out.println(latLonBounds);
  } finally {
    MapProjection.SKIP_SANITY_CHECKS = false;
  }
}
origin: geotools/geotools

/**
 * Test custom PADDING is being used when provided as Hint
 *
 * @throws Exception
 */
@Test
public void testPadding() throws Exception {
  CoordinateReferenceSystem wgs84 = CRS.decode("EPSG:4326", true);
  final double envWidth = 30;
  final double envHeight = 30;
  ReferencedEnvelope mapExtent = new ReferencedEnvelope(0, envWidth, 0, envHeight, wgs84);
  Rectangle screenSize = new Rectangle((int) envWidth, (int) envHeight);
  checkPadding(screenSize, mapExtent, 4);
  checkPadding(screenSize, mapExtent, 12);
}
origin: geoserver/geoserver

void assertWMSLayer(WMSLayerInfo wmsLayer) throws Exception {
  assertEquals("states", wmsLayer.getName());
  assertEquals("topp:states", wmsLayer.getNativeName());
  assertEquals("EPSG:4326", wmsLayer.getSRS());
  assertEquals("USA Population", wmsLayer.getTitle());
  assertEquals("2000 census data for United States.", wmsLayer.getAbstract());
  assertEquals(CRS.decode("EPSG:4326"), wmsLayer.getNativeCRS());
  assertNotNull(wmsLayer.getNativeBoundingBox());
  assertNotNull(wmsLayer.getLatLonBoundingBox());
  assertFalse(wmsLayer.getKeywords().isEmpty());
}
origin: geoserver/geoserver

/**
 * Test method for {@link CoordinateOperationFactoryUsingWKT#createCoordinateOperation}.
 *
 * @throws TransformException
 */
@Test
public void testOverrideEPSGOperation() throws Exception {
  // Test CRSs
  CoordinateReferenceSystem source = CRS.decode("EPSG:4269");
  CoordinateReferenceSystem target = CRS.decode("EPSG:4326");
  MathTransform mt = CRS.findMathTransform(source, target, true);
  // Test MathTransform
  double[] p = new double[2];
  mt.transform(SRC_TEST_POINT, 0, p, 0, 1);
  assertEquals(p[0], DST_TEST_POINT[0], 1e-8);
  assertEquals(p[1], DST_TEST_POINT[1], 1e-8);
}
origin: geoserver/geoserver

@Test
public void testUseCRSBounds() throws NoSuchAuthorityCodeException, FactoryException {
  // this test is almost trivial since the code itself is trivial
  CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326");
  LayerGroupHelper helper = new LayerGroupHelper(nested);
  helper.calculateBoundsFromCRS(targetCRS);
  // layer group bounds should now match target CRS bounds
  assertEquals(nested.getBounds(), new ReferencedEnvelope(CRS.getEnvelope(targetCRS)));
  // null CRS should get null bounds
  helper.calculateBoundsFromCRS(null);
  assertEquals(nested.getBounds(), null);
}
origin: geoserver/geoserver

@Test
public void testCRSConverterInvalidWKT() throws Exception {
  CoordinateReferenceSystem crs = CRS.decode("EPSG:3575");
  try {
    ((Formattable) crs).toWKT(2, true);
    fail("expected exception");
  } catch (UnformattableObjectException e) {
  }
  String wkt = null;
  try {
    wkt = new CRSConverter().toString(crs);
  } catch (UnformattableObjectException e) {
    fail("Should have thrown exception");
  }
  CoordinateReferenceSystem crs2 =
      (CoordinateReferenceSystem) new CRSConverter().fromString(wkt);
  assertTrue(CRS.equalsIgnoreMetadata(crs, crs2));
}
origin: geotools/geotools

@Test
public void testOutsideDefinitionArea() throws Exception {
  // setup a request that is outside of the coverage
  CoordinateReferenceSystem crs = CRS.decode("EPSG:3031", true);
  ReferencedEnvelope mapExtent =
      new ReferencedEnvelope(-1250000, 0, -13750000, -12500000, crs);
  // System.out.println(mapExtent.transform(DefaultGeographicCRS.WGS84, true));
  GridCoverageReaderHelper helper =
      new GridCoverageReaderHelper(
          reader,
          new Rectangle(400, 200),
          mapExtent,
          Interpolation.getInstance(Interpolation.INTERP_NEAREST));
  // read, nothing should come out
  ProjectionHandler handler =
      ProjectionHandlerFinder.getHandler(
          mapExtent, reader.getCoordinateReferenceSystem(), true);
  List<GridCoverage2D> coverages = helper.readCoverages(null, handler);
  assertTrue(coverages.isEmpty());
}
origin: geotools/geotools

@BeforeClass
public static void setupCRS() throws FactoryException {
  CRS.reset("all");
  Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);
  // the following is only to make the test work in Eclipse, where the test
  // classpath is tainted by the test classpath of dependent modules (whilst in Maven it's
  // not)
  Set<CRSAuthorityFactory> factories =
      ReferencingFactoryFinder.getCRSAuthorityFactories(null);
  for (CRSAuthorityFactory factory : factories) {
    if (factory.getClass().getSimpleName().equals("EPSGCRSAuthorityFactory")) {
      ReferencingFactoryFinder.removeAuthorityFactory(factory);
    }
  }
  assertEquals(
      AxisOrder.NORTH_EAST, CRS.getAxisOrder(CRS.decode("urn:ogc:def:crs:EPSG::4326")));
}
origin: opentripplanner/OpenTripPlanner

@Override
public void createIndividuals() {
  try {
    coverageCRS = CRS.decode(crsCode, true);
  } catch (Exception e) {
    LOG.error("error decoding coordinate reference system code.", e);
    return;
  }
  if (boundsFromGraph) {
    // autowire graph service or pass in
  }
  gridEnvelope = new GridEnvelope2D(0, 0, cols, rows);
  refEnvelope = new ReferencedEnvelope(left, right, bottom, top, coverageCRS);
  gridGeometry = new GridGeometry2D(gridEnvelope, refEnvelope);
  super.createIndividuals0();
}
origin: geoserver/geoserver

/**
 * Check we are actually using the EPSG database for anything not in override
 *
 * @throws TransformException
 */
@Test
public void testFallbackOnEPSGDatabaseStd() throws Exception {
  // Test CRSs
  CoordinateReferenceSystem source = CRS.decode("EPSG:3002");
  CoordinateReferenceSystem target = CRS.decode("EPSG:4326");
  CoordinateOperation co =
      CRS.getCoordinateOperationFactory(true).createOperation(source, target);
  ConcatenatedOperation cco = (ConcatenatedOperation) co;
  // the EPSG one only has two steps, the non EPSG one 4
  assertEquals(2, cco.getOperations().size());
}
origin: geoserver/geoserver

@Test
public void testGetBoundsFromCRS() throws Exception {
  Catalog cat = getCatalog();
  CatalogBuilder cb = new CatalogBuilder(cat);
  cb.setStore(cat.getDataStoreByName(MockData.LINES.getPrefix()));
  FeatureTypeInfo fti = cb.buildFeatureType(toName(MockData.LINES));
  CoordinateReferenceSystem resourceCRS = fti.getCRS();
  assertNotNull(resourceCRS);
  // make sure the srs is as expected, otherwise the rest of the tests don't make sense
  assertEquals("EPSG:32615", fti.getSRS());
  ReferencedEnvelope crsBounds = cb.getBoundsFromCRS(fti);
  assertNotNull(crsBounds);
  CoordinateReferenceSystem exptectedCRS = CRS.decode("EPSG:32615");
  assertEquals(new ReferencedEnvelope(CRS.getEnvelope(exptectedCRS)), crsBounds);
  // if we change the srs when there's no reproject policy, should still be the same bounding
  // box
  fti.setSRS("EPSG:4326");
  fti.setProjectionPolicy(ProjectionPolicy.NONE);
  crsBounds = cb.getBoundsFromCRS(fti);
  assertEquals(new ReferencedEnvelope(CRS.getEnvelope(exptectedCRS)), crsBounds);
  // if we use reproject policy, bounds should now be different
  fti.setProjectionPolicy(ProjectionPolicy.FORCE_DECLARED);
  crsBounds = cb.getBoundsFromCRS(fti);
  assertNotEquals(new ReferencedEnvelope(CRS.getEnvelope(exptectedCRS)), crsBounds);
  // should now be 4326 bounds
  CoordinateReferenceSystem crs4326 = CRS.decode("EPSG:4326");
  assertEquals(new ReferencedEnvelope(CRS.getEnvelope(crs4326)), crsBounds);
  fti.setProjectionPolicy(ProjectionPolicy.REPROJECT_TO_DECLARED);
  assertEquals(new ReferencedEnvelope(CRS.getEnvelope(crs4326)), crsBounds);
}
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: geotools/geotools

@Test
public void testCutGeometryLambertConformal() throws Exception {
  // get a lambert conformal conic with
  ReferencedEnvelope wgs84South = new ReferencedEnvelope(-180, -90, -40, 0, WGS84);
  ReferencedEnvelope laeSouth = wgs84South.transform(CRS.decode("EPSG:2194"), true);
  ProjectionHandler handler = ProjectionHandlerFinder.getHandler(laeSouth, WGS84, true);
  // a Geometry that crosses the opposite of the central meridian
  Polygon geometry = JTS.toGeometry(new Envelope(5, 15, 0, 10));
  Geometry preProcessed = handler.preProcess(geometry);
  assertTrue(
      "Should have sliced the geometry in two parts",
      preProcessed instanceof MultiPolygon);
}
origin: geoserver/geoserver

CoordinateReferenceSystem crs = srs != null ? CRS.decode(srs) : null;
baseMap.put("baseMapEnvelope", new ReferencedEnvelope(x1, x2, y1, y2, crs));
origin: geoserver/geoserver

  /** See if we can use the stgeorge grid shift files as the ESPG db would like us to */
  @Test
  public void testNadCon() throws Exception {
    CoordinateReferenceSystem crs4138 = CRS.decode("EPSG:4138");
    CoordinateReferenceSystem crs4326 = CRS.decode("EPSG:4326");
    MathTransform mt = CRS.findMathTransform(crs4138, crs4326);

    assertTrue(mt.toWKT().contains("NADCON"));

    double[] src = new double[] {-169.625, 56.575};
    double[] expected = new double[] {-169.62744, 56.576034};
    double[] p = new double[2];
    mt.transform(src, 0, p, 0, 1);
    assertEquals(expected[0], p[0], 1e-6);
    assertEquals(expected[1], p[1], 1e-6);
  }
}
origin: geotools/geotools

@Test
public void testQueryEnvelopeOnInvalidArea2() throws Exception {
  // and Envelope that does not make sense for EPSG:3003, too far away from central meridian
  ReferencedEnvelope re =
      new ReferencedEnvelope(-130, -120, -40, 30, DefaultGeographicCRS.WGS84);
  ReferencedEnvelope re3857 = re.transform(CRS.decode("EPSG:3857", true), true);
  ProjectionHandler ph =
      ProjectionHandlerFinder.getHandler(re3857, CRS.decode("EPSG:3003", true), true);
  List<ReferencedEnvelope> queryEnvelopes = ph.getQueryEnvelopes();
  assertEquals(0, queryEnvelopes.size());
}
origin: geotools/geotools

/** Tests simple decode. */
@Test
public void testDecode() throws FactoryException {
  assertSame(WGS84, CRS.decode("WGS84(DD)"));
}
org.geotools.referencingCRSdecode

Javadoc

Return a Coordinate Reference System for the specified code. Note that the code needs to mention the authority. Examples:
 
EPSG:1234 
AUTO:42001, ..., ..., ... 
If there is more than one factory implementation for the same authority, then all additional factories are org.geotools.referencing.factory.FallbackAuthorityFactory to be used only when the first acceptable factory failed to create the requested CRS object.

CRS objects created by previous calls to this method are org.geotools.referencing.factory.BufferedAuthorityFactory using java.lang.ref.WeakReference. Subsequent calls to this method with the same authority code should be fast, unless the CRS object has been garbage collected.

Popular methods of CRS

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

Popular in Java

  • Finding current android device location
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • BufferedReader (java.io)
    Reads text from a character-input stream, buffering characters so as to provide for the efficient re
  • InetAddress (java.net)
    This class represents an Internet Protocol (IP) address. An IP address is either a 32-bit or 128-bit
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now