Tabnine Logo
ReferencedEnvelope3D
Code IndexAdd Tabnine to your IDE (free)

How to use
ReferencedEnvelope3D
in
org.geotools.geometry.jts

Best Java code snippets using org.geotools.geometry.jts.ReferencedEnvelope3D (Showing top 20 results out of 315)

origin: geotools/geotools

/** Returns the specified bounding box as a JTS envelope. */
private static ReferencedEnvelope3D getJTSEnvelope(final BoundingBox3D bbox) {
  if (bbox == null) {
    throw new NullPointerException("Provided bbox envelope was null");
  }
  if (bbox instanceof ReferencedEnvelope3D) {
    return (ReferencedEnvelope3D) bbox;
  }
  return new ReferencedEnvelope3D(bbox);
}
origin: geotools/geotools

/**
 * Computes the intersection of two {@link Envelope}s.
 *
 * @param env the envelope to intersect with
 * @return a new Envelope representing the intersection of the envelopes (this will be the null
 *     envelope if either argument is null, or they do not intersect
 */
public ReferencedEnvelope3D intersection(ReferencedEnvelope3D env) {
  ensureCompatibleReferenceSystem(env);
  if (isNull() || env.isNull() || !intersects(env)) return new ReferencedEnvelope3D();
  double intMinX = getMinX() > env.getMinX() ? getMinX() : env.getMinX();
  double intMinY = getMinY() > env.getMinY() ? getMinY() : env.getMinY();
  double intMinZ = minz > env.minz ? minz : env.minz;
  double intMaxX = getMaxX() < env.getMaxX() ? getMaxX() : env.getMaxX();
  double intMaxY = getMaxY() < env.getMaxY() ? getMaxY() : env.getMaxY();
  double intMaxZ = maxz < env.maxz ? maxz : env.maxz;
  return new ReferencedEnvelope3D(
      intMinX,
      intMaxX,
      intMinY,
      intMaxY,
      intMinZ,
      intMaxZ,
      env.getCoordinateReferenceSystem());
}
origin: geotools/geotools

/**
 * Computes the coordinate of the centre of this envelope (as long as it is non-null
 *
 * @return the centre coordinate of this envelope <code>null</code> if the envelope is null
 */
public Coordinate centre() {
  if (isNull()) return null;
  return new Coordinate(
      (getMinX() + getMaxX()) / 2.0,
      (getMinY() + getMaxY()) / 2.0,
      (getMinZ() + getMaxZ()) / 2.0);
}
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

/**
 * Creates a new envelope from an existing envelope.
 *
 * @param envelope The envelope to initialize from
 * @throws MismatchedDimensionException if the CRS dimension is not valid.
 */
public ReferencedEnvelope3D(final ReferencedEnvelope3D envelope)
    throws MismatchedDimensionException {
  init(envelope);
  crs = envelope.getCoordinateReferenceSystem();
  checkCoordinateReferenceSystemDimension();
}
origin: geotools/geotools

/**
 * Creates a new envelope from an existing JTS envelope.
 *
 * @param envelope The envelope to initialize from.
 * @param crs The coordinate reference system.
 * @throws MismatchedDimensionExceptionif the CRS dimension is not valid.
 */
public ReferencedEnvelope3D(final Envelope envelope, final CoordinateReferenceSystem crs)
    throws MismatchedDimensionException {
  super(envelope, crs);
  if (envelope instanceof ReferencedEnvelope3D) {
    this.minz = ((ReferencedEnvelope3D) envelope).getMinZ();
    this.maxz = ((ReferencedEnvelope3D) envelope).getMaxZ();
  }
}
origin: geotools/geotools

@Test
public void testEverything() {
  ReferencedEnvelope3D everything = ReferencedEnvelope3D.EVERYTHING;
  ReferencedEnvelope3D world = new ReferencedEnvelope3D(ReferencedEnvelope3D.EVERYTHING);
  assertEquals(world.getDimension(), 3);
  assertFalse("This is not an empty 3d envelope", everything.isEmpty());
  assertTrue("This is a null 3d envelope", everything.isNull());
  Coordinate center = everything.centre();
  assertNotNull(center);
  double volume = everything.getVolume();
  assertTrue("volume=" + volume, Double.isInfinite(volume));
  volume = world.getVolume();
  assertTrue("volume=" + volume, Double.isInfinite(volume));
  double area = everything.getArea();
  assertTrue("area=" + area, Double.isInfinite(area));
  area = world.getArea();
  assertTrue("area=" + area, Double.isInfinite(area));
    everything.setBounds(new ReferencedEnvelope3D());
    fail("Expected IllegalStateException");
  } catch (IllegalStateException expected) {
  everything.setToNull();
  everything.translate(1.0, 1.0, 1.0);
origin: geotools/geotools

@Test
public void empty() {
  // ensure empty can grab a default CRS when starting from nothing
  ReferencedEnvelope3D bbox = new ReferencedEnvelope3D(); // this is empty
  assertNull(bbox.getCoordinateReferenceSystem());
  ReferencedEnvelope3D australia = new ReferencedEnvelope3D(DefaultGeographicCRS.WGS84_3D);
  australia.include(40, 110, 0);
  australia.include(10, 150, 10);
  bbox.include(australia);
  assertEquals(australia.getCoordinateReferenceSystem(), bbox.getCoordinateReferenceSystem());
  assertEquals(0, bbox.getMinZ(), 0d);
  assertEquals(10, bbox.getMaxZ(), 0d);
}
origin: geotools/geotools

  if (isEmpty()) {
    return new ReferencedEnvelope3D(targetCRS);
  } else {
if (getDimension() != targetCRS.getCoordinateSystem().getDimension()) {
  if (lenient) {
    return JTS.transformTo2D(this, targetCRS, lenient, numPointsForTransformation);
            ErrorKeys.MISMATCHED_DIMENSION_$3,
            crs.getName().getCode(),
            Integer.valueOf(getDimension()),
            Integer.valueOf(targetCRS.getCoordinateSystem().getDimension())));
final ReferencedEnvelope3D target = new ReferencedEnvelope3D(transformed);
final MathTransform transform = operation.getMathTransform();
JTS.transform(this, target, transform, numPointsForTransformation);
target.expandToInclude(0, 0, this.minz);
target.expandToInclude(0, 0, this.maxz);
origin: geotools/geotools

@Test
public void testIntersectXYZ() {
  ReferencedEnvelope3D envelope = new ReferencedEnvelope3D();
  assertTrue(envelope.isNull());
  assertFalse(envelope.intersects(1.0, 2.0, 3.0));
  double z_ave = (z_min + z_max) / 2.0;
  envelope.init(x_min, x_max, y_min, y_max, z_min, z_max);
  assertTrue(envelope.intersects(x_ave, y_ave, z_ave));
  assertTrue(envelope.intersects(x_min, y_min, z_min));
  assertTrue(envelope.intersects(x_max, y_max, z_max));
  assertFalse(envelope.intersects(-x_ave, -y_ave, -z_ave));
  assertFalse(envelope.intersects(x_min - delta, y_ave, z_ave));
  assertFalse(envelope.intersects(x_max + delta, y_ave, z_ave));
  assertFalse(envelope.intersects(x_ave, y_min - delta, z_ave));
  assertFalse(envelope.intersects(x_ave, y_max + delta, z_ave));
  assertFalse(envelope.intersects(x_ave, y_ave, z_min - delta));
  assertFalse(envelope.intersects(x_ave, y_ave, z_max + delta));
origin: geotools/geotools

public ReferencedEnvelope3D get3DEnvelope(Geometry geom) {
  Coordinate[] coordinates = geom.getCoordinates();
  ReferencedEnvelope3D env = new ReferencedEnvelope3D();
  for (Coordinate coordinate : coordinates) {
    env.expandToInclude(coordinate);
  }
  return env;
}
origin: geotools/geotools

@Test
public void include() throws Exception {
  ReferencedEnvelope3D australia = new ReferencedEnvelope3D(DefaultGeographicCRS.WGS84_3D);
  australia.include(40, 110, 0);
  australia.include(10, 150, 10);
  ReferencedEnvelope3D newZealand =
      new ReferencedEnvelope3D(DefaultEngineeringCRS.CARTESIAN_3D);
  newZealand.include(50, 165, 0);
  newZealand.include(33, 180, 5);
  try {
    australia.expandToInclude(newZealand);
    fail("Expected a mismatch of CoordinateReferenceSystem");
  } catch (MismatchedReferenceSystemException t) {
    // expected
  }
  try {
    australia.include(newZealand);
    fail("Expected a mismatch of CoordinateReferenceSystem");
  } catch (MismatchedReferenceSystemException t) {
    // expected
  }
}
origin: geotools/geotools

@Test
public void intersection() throws Exception {
  ReferencedEnvelope3D australia = new ReferencedEnvelope3D(DefaultGeographicCRS.WGS84_3D);
  australia.include(40, 110, 0);
  australia.include(10, 150, 10);
  ReferencedEnvelope3D newZealand =
      new ReferencedEnvelope3D(DefaultEngineeringCRS.CARTESIAN_3D);
  newZealand.include(50, 165, 0);
  newZealand.include(33, 180, 5);
  try {
    australia.intersection(newZealand);
    fail("Expected a mismatch of CoordinateReferenceSystem");
  } catch (MismatchedReferenceSystemException t) {
    // expected
  }
}
origin: geotools/geotools

@Test
public void testDistanceWhenMinZOfThisIsGreaterThanMaxZOfOther() {
  CoordinateReferenceSystem crs = DefaultEngineeringCRS.CARTESIAN_3D;
  ReferencedEnvelope3D a = new ReferencedEnvelope3D(2.0, 3.0, 2.0, 3.0, 2.0, 3.0, crs);
  ReferencedEnvelope3D b = new ReferencedEnvelope3D(0.0, 1.0, 0.0, 1.0, 0.0, 0.5, crs);
  assertEquals(Math.sqrt(1 * 1 + 1 * 1 + 1.5 * 1.5), a.distance(b), 0.00001);
}
origin: geotools/geotools

/**
 * Enlarges this <code>Envelope</code> so that it contains the <code>other</code> Envelope. Has
 * no effect if <code>other</code> is wholly on or within the envelope.
 *
 * @param other the <code>Envelope</code> to expand to include
 */
public void expandToInclude(ReferencedEnvelope3D other) {
  ensureCompatibleReferenceSystem(other);
  if (other.isNull()) {
    return;
  }
  if (isNull()) {
    super.expandToInclude(other);
    minz = other.getMinZ();
    maxz = other.getMaxZ();
  } else {
    super.expandToInclude(other);
    if (other.minz < minz) {
      minz = other.minz;
    }
    if (other.maxz > maxz) {
      maxz = other.maxz;
    }
  }
}
origin: geotools/geotools

/**
 * Tests if the <code>Envelope other</code> lies wholely inside this <code>Envelope</code>
 * (inclusive of the boundary).
 *
 * @param other the <code>Envelope</code> to check
 * @return true if this <code>Envelope</code> covers the <code>other</code>
 */
public boolean covers(ReferencedEnvelope3D other) {
  if (isNull() || other.isNull()) {
    return false;
  }
  return super.covers(other) && other.getMinZ() >= minz && other.getMaxZ() <= maxz;
}
origin: geotools/geotools

public Expression getExpression2() {
  // in this case, the 3D BBOX falls back to regular 2D bbox behaviour (until there is more
  // support for 3D geometries)
  // 3DBBOX must be run as a post-filter in order to support the third coordinate.
  Coordinate[] coords = new Coordinate[5];
  coords[0] = new Coordinate(envelope.getMinX(), envelope.getMinY());
  coords[1] = new Coordinate(envelope.getMinX(), envelope.getMaxY());
  coords[2] = new Coordinate(envelope.getMaxX(), envelope.getMaxY());
  coords[3] = new Coordinate(envelope.getMaxX(), envelope.getMinY());
  coords[4] = new Coordinate(envelope.getMinX(), envelope.getMinY());
  LinearRing ring = null;
  GeometryFactory gfac = new GeometryFactory();
  try {
    ring = gfac.createLinearRing(coords);
  } catch (TopologyException tex) {
    throw new IllegalFilterException(tex.toString());
  }
  Polygon polygon = gfac.createPolygon(ring, null);
  if (envelope instanceof ReferencedEnvelope3D) {
    ReferencedEnvelope3D refEnv = (ReferencedEnvelope3D) envelope;
    polygon.setUserData(refEnv.getCoordinateReferenceSystem());
  }
  return factory.literal(polygon);
}
origin: geotools/geotools

/** Returns the minimal ordinate along the specified dimension. */
public double getMinimum(final int dimension) {
  switch (dimension) {
    case 0:
      return getMinX();
    case 1:
      return getMinY();
    case 2:
      return getMinZ();
    default:
      throw new IndexOutOfBoundsException(String.valueOf(dimension));
  }
}
origin: geotools/geotools

eps *= 0.5 * (getWidth() + getHeight());
delta[0] = getMinimum(0) - other.getMinimum(0);
delta[1] = getMaximum(0) - other.getMaximum(0);
delta[2] = getMinimum(1) - other.getMinimum(1);
delta[3] = getMaximum(1) - other.getMaximum(1);
delta[4] = getMinimum(2) - other.getMinimum(2);
delta[5] = getMaximum(2) - other.getMaximum(2);
origin: geotools/geotools

/** Returns the maximal ordinate along the specified dimension. */
public double getMaximum(final int dimension) {
  switch (dimension) {
    case 0:
      return getMaxX();
    case 1:
      return getMaxY();
    case 2:
      return getMaxZ();
    default:
      throw new IndexOutOfBoundsException(String.valueOf(dimension));
  }
}
org.geotools.geometry.jtsReferencedEnvelope3D

Javadoc

A 3D envelope associated with a CoordinateReferenceSystem. In addition, this JTS envelope also implements the GeoAPI org.opengis.geometry.Envelope interface for interoperability with GeoAPI.

Most used methods

  • <init>
  • getCoordinateReferenceSystem
  • getMaxZ
  • getMinZ
  • expandToInclude
  • getDimension
    Returns the number of dimensions.
  • getMaximum
    Returns the maximal ordinate along the specified dimension.
  • getMinimum
    Returns the minimal ordinate along the specified dimension.
  • init
    Sets this envelope to the specified bounding box.
  • intersects
    Check if this bounding box intersects the provided bounds.
  • isEmpty
    Returns true if lengths along all dimension are zero.
  • isNull
  • isEmpty,
  • isNull,
  • setToNull,
  • centre,
  • checkCoordinateReferenceSystemDimension,
  • contains,
  • covers,
  • distance,
  • ensureCompatibleReferenceSystem,
  • equals

Popular in Java

  • Reactive rest calls using spring rest template
  • onCreateOptionsMenu (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getResourceAsStream (ClassLoader)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top plugins for WebStorm
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