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

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

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

origin: geoserver/geoserver

/**
 * Computes the geographic bounds of a {@link ResourceInfo} by reprojecting the available native
 * bounds
 *
 * @param rinfo
 * @return the geographic bounds, or null if the native bounds are not available
 * @throws IOException
 */
public ReferencedEnvelope getLatLonBounds(
    ReferencedEnvelope nativeBounds, CoordinateReferenceSystem declaredCRS)
    throws IOException {
  if (nativeBounds != null && declaredCRS != null) {
    // make sure we use the declared CRS, not the native one, the may differ
    if (!CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, declaredCRS)) {
      // transform
      try {
        ReferencedEnvelope bounds =
            new ReferencedEnvelope(nativeBounds, CRS.getHorizontalCRS(declaredCRS));
        return bounds.transform(DefaultGeographicCRS.WGS84, true);
      } catch (Exception e) {
        throw (IOException) new IOException("transform error").initCause(e);
      }
    } else {
      return new ReferencedEnvelope(nativeBounds, DefaultGeographicCRS.WGS84);
    }
  }
  return null;
}
origin: geotools/geotools

private void checkReprojection() throws FactoryException {
  geometryCRS = CRS.getHorizontalCRS(sourceCRS);
  CoordinateReferenceSystem renderingCRS = renderingEnvelope.getCoordinateReferenceSystem();
  try {
    noReprojection = !CRS.isTransformationRequired(geometryCRS, renderingCRS);
  } catch (Exception e) {
    LOGGER.log(
        Level.FINE,
        "Failed to determine is reprojection is required, assumming it is",
        e);
    noReprojection = false;
  }
}
origin: geoserver/geoserver

SingleCRS horizontalCRS = CRS.getHorizontalCRS(crs);
Unit targetUnit;
if (horizontalCRS != null) {
origin: geotools/geotools

/** Tests {@link CRS#getHorizontalCRS} from a compound CRS. */
public void testHorizontalFromCompound() throws FactoryException {
  // retrives "NTF (Paris) / France II + NGF Lallemand"
  CoordinateReferenceSystem compound = CRS.decode("EPSG:7401");
  CoordinateReferenceSystem horizontal = CRS.getHorizontalCRS(compound);
  // compares with "NTF (Paris) / France II"
  assertEquals(CRS.decode("EPSG:27582"), horizontal);
}
origin: geotools/geotools

/**
 * Initializes a projection handler
 *
 * @param sourceCRS The source CRS
 * @param validAreaBounds The valid area (used to cut geometries that go beyond it)
 * @param renderingEnvelope The target rendering area and target CRS
 * @throws FactoryException
 */
public ProjectionHandler(
    CoordinateReferenceSystem sourceCRS,
    Envelope validAreaBounds,
    ReferencedEnvelope renderingEnvelope)
    throws FactoryException {
  this.renderingEnvelope = renderingEnvelope;
  this.sourceCRS = CRS.getHorizontalCRS(sourceCRS);
  this.targetCRS = renderingEnvelope.getCoordinateReferenceSystem();
  this.validAreaBounds =
      validAreaBounds != null
          ? new ReferencedEnvelope(validAreaBounds, DefaultGeographicCRS.WGS84)
          : null;
  this.validArea = null;
  this.validaAreaTester = null;
  // query across dateline only in case of reprojection, Oracle won't use the spatial index
  // with two or-ed bboxes and fixing the issue at the store level requires more
  // time/resources than we presently have
  this.queryAcrossDateline =
      !CRS.equalsIgnoreMetadata(
          sourceCRS, renderingEnvelope.getCoordinateReferenceSystem());
  checkReprojection();
}
origin: geotools/geotools

@Test
public void testGetHorizontalCrs() {
  assertEquals(
      DefaultEngineeringCRS.GENERIC_2D,
      CRS.getHorizontalCRS(DefaultEngineeringCRS.GENERIC_2D));
}
origin: geotools/geotools

CoordinateReferenceSystem crs = CRS.getHorizontalCRS(CRS.decode("EPSG:" + currentSRID));
double distanceMeters = getDistanceInMeters(operator);
if (crs instanceof GeographicCRS) {
origin: geotools/geotools

@Test
public void testWrappingOn3DCRS() throws Exception {
  CoordinateReferenceSystem crs = CRS.decode("EPSG:4939", true);
  SingleCRS hcrs = CRS.getHorizontalCRS(crs);
  ReferencedEnvelope wgs84Envelope = new ReferencedEnvelope(-190, 60, -90, 45, hcrs);
  ProjectionHandler handler = ProjectionHandlerFinder.getHandler(wgs84Envelope, crs, true);
  assertNull(handler.validAreaBounds);
  List<ReferencedEnvelope> envelopes = handler.getQueryEnvelopes();
  assertEquals(2, envelopes.size());
  ReferencedEnvelope expected = new ReferencedEnvelope(170, 180, -90, 45, hcrs);
  assertTrue(envelopes.remove(wgs84Envelope));
  assertEquals(expected, envelopes.get(0));
}
origin: geotools/geotools

  transformTo2D =
      CRS.findMathTransform(
          requestedEnvelopeCRS2D, CRS.getHorizontalCRS(requestedEnvelopeCRS2D));
  requestedEnvelopeCRS2D = CRS.getHorizontalCRS(requestedEnvelopeCRS2D);
} else transformTo2D = IdentityTransform.create(2);
origin: geotools/geotools

coverageCRS2D = CRS.getHorizontalCRS(coverageCRS);
assert coverageCRS2D.getCoordinateSystem().getDimension() == 2;
if (coverageCRS.getCoordinateSystem().getDimension() != 2) {
origin: geotools/geotools

final Rectangle2D rect = gridCoverageReader.getOriginalEnvelope().toRectangle2D();
final CoordinateReferenceSystem sourceCrs =
    CRS.getHorizontalCRS(gridCoverageReader.getCoordinateReferenceSystem());
if (sourceCrs == null)
  throw new UnsupportedOperationException(
origin: geotools/geotools

    CRS.getHorizontalCRS(envelope.getCoordinateReferenceSystem());
if (envelopeCrs2D != null && !CRS.equalsIgnoreMetadata(crs, envelopeCrs2D)) {
  CoordinateOperationFactory operationFactory =
origin: geotools/geotools

coverageCRS2D = CRS.getHorizontalCRS(coverageCRS);
assert coverageCRS2D.getCoordinateSystem().getDimension() == 2;
if (coverageCRS.getCoordinateSystem().getDimension() != 2) {
origin: geotools/geotools

public Object visit(BBOX filter, Object extraData) {
  // if no srs is specified we can't transform anyways
  String srs = filter.getSRS();
  if (srs != null && !"".equals(srs.trim())) return super.visit(filter, extraData);
  if (defaultCrs == null
      || filter.getBounds() == null
      || defaultCrs.getCoordinateSystem().getDimension()
          == filter.getBounds().getDimension()) {
    return getFactory(extraData)
        .bbox(
            filter.getExpression1(),
            ReferencedEnvelope.create(filter.getBounds(), defaultCrs));
  } else {
    try {
      SingleCRS horizontalCRS = CRS.getHorizontalCRS(defaultCrs);
      ReferencedEnvelope bounds =
          ReferencedEnvelope.create(filter.getBounds(), horizontalCRS);
      return getFactory(extraData).bbox(filter.getExpression1(), bounds);
    } catch (Exception e) {
      throw new RuntimeException("Could not decode srs '" + srs + "'", e);
    }
  }
}
origin: geotools/geotools

@Test
public void force3DCRS2DEnvelope() throws Exception {
  CoordinateReferenceSystem crs = CRS.decode("EPSG:4939", true);
  CoordinateReferenceSystem hcrs = CRS.getHorizontalCRS(crs);
  BBOX bbox = ff.bbox("the_geom", -180, -90, 180, 90, null);
  DefaultCRSFilterVisitor visitor = new DefaultCRSFilterVisitor(ff, crs);
  BBOX filtered = (BBOX) bbox.accept(visitor, null);
  Literal box = (Literal) filtered.getExpression2();
  Geometry g = (Geometry) box.evaluate(null);
  assertEquals(hcrs, g.getUserData());
}
origin: geotools/geotools

/** Tests {@link CRS#getHorizontalCRS} from a Geographic 3D CR. */
public void testHorizontalFromGeodetic() throws FactoryException {
  // retrives "WGS 84 (geographic 3D)"
  CoordinateReferenceSystem compound = CRS.decode("EPSG:4327");
  CoordinateReferenceSystem horizontal = CRS.getHorizontalCRS(compound);
  // the horizonal version is basically 4326, but it won't compare positively
  // with 4326, not even using CRS.equalsIgnoreMetadata(), so we check the axis directly
  CoordinateSystem cs = horizontal.getCoordinateSystem();
  assertEquals(2, cs.getDimension());
  assertEquals(AxisDirection.NORTH, cs.getAxis(0).getDirection());
  assertEquals(AxisDirection.EAST, cs.getAxis(1).getDirection());
}
origin: geotools/geotools

  returnedCRS = CRS.getHorizontalCRS(coverage.getCoordinateReferenceSystem());
if (returnedCRS == null)
  throw new TransformException(
origin: geotools/geotools

  @Test
  public void force3DCRS3DEnvelope() throws Exception {
    CoordinateReferenceSystem crs = CRS.decode("EPSG:4939", true);
    CoordinateReferenceSystem hcrs = CRS.getHorizontalCRS(crs);
    BBOX bbox =
        ff.bbox(
            ff.property("the_geom"),
            new ReferencedEnvelope3D(-180, 180, -90, 90, 0, 100, null));
    DefaultCRSFilterVisitor visitor = new DefaultCRSFilterVisitor(ff, crs);
    BBOX filtered = (BBOX) bbox.accept(visitor, null);
    Literal box = (Literal) filtered.getExpression2();
    Geometry g = (Geometry) box.evaluate(null);
    assertEquals(crs, g.getUserData());
  }
}
origin: geotools/geotools

coverageCRS2D = CRS.getHorizontalCRS(coverageCRS);
assert coverageCRS2D.getCoordinateSystem().getDimension() == 2;
if (coverageCRS.getCoordinateSystem().getDimension() != 2) {
origin: geotools/geotools

/**
 * Make sure we can properly retrieve the bounds of 3d layers
 *
 * @throws Exception
 */
public void testBounds() throws Exception {
  ReferencedEnvelope env = dataStore.getFeatureSource(tname(getLine3d())).getBounds();
  // check we got the right 2d component
  Envelope expected = new Envelope(1, 5, 0, 4);
  assertEquals(expected, env);
  // check the srs the expected one
  assertEquals(CRS.getHorizontalCRS(crs), env.getCoordinateReferenceSystem());
}
org.geotools.referencingCRSgetHorizontalCRS

Javadoc

Returns the first horizontal coordinate reference system found in the given CRS, or null if there is none. A horizontal CRS is usually a two-dimensional GeographicCRS or ProjectedCRS CRS.

Popular methods of CRS

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

Popular in Java

  • Start an intent from android
  • getApplicationContext (Context)
  • getContentResolver (Context)
  • onCreateOptionsMenu (Activity)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Top 12 Jupyter Notebook extensions
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