Tabnine Logo
Geometry.getDimension
Code IndexAdd Tabnine to your IDE (free)

How to use
getDimension
method
in
com.vividsolutions.jts.geom.Geometry

Best Java code snippets using com.vividsolutions.jts.geom.Geometry.getDimension (Showing top 20 results out of 315)

origin: com.vividsolutions/jts

public int getDimension() {
 int dimension = Dimension.FALSE;
 for (int i = 0; i < geometries.length; i++) {
  dimension = Math.max(dimension, geometries[i].getDimension());
 }
 return dimension;
}
origin: com.vividsolutions/jts

 private static int resultDimension(int opCode, Geometry g0, Geometry g1)
 {
   int dim0 = g0.getDimension();
   int dim1 = g1.getDimension();
   
   int resultDimension = -1;
   switch (opCode) {
   case INTERSECTION: 
     resultDimension = Math.min(dim0, dim1);
     break;
   case UNION: 
     resultDimension = Math.max(dim0, dim1);
     break;
   case DIFFERENCE: 
     resultDimension = dim0;
     break;
   case SYMDIFFERENCE: 
    /**
     * This result is chosen because
     * <pre>
     * SymDiff = Union(Diff(A, B), Diff(B, A)
     * </pre>
     * and Union has the dimension of the highest-dimension argument.
     */
     resultDimension = Math.max(dim0, dim1);
     break;
   }
   return resultDimension;
 }
}
origin: com.vividsolutions/jts

/**
 * Finds the index of the "most polygonal" input geometry.
 * This optimizes the computation of the best-fit plane, 
 * since it is cached only for the left-hand geometry.
 * 
 * @return the index of the most polygonal geometry
 */
private int mostPolygonalIndex() {
  int dim0 = geom[0].getDimension();
  int dim1 = geom[1].getDimension();
  if (dim0 >= 2 && dim1 >= 2) {
    if (geom[0].getNumPoints() > geom[1].getNumPoints())
      return 0;
    return 1;
  }
  // no more than one is dim 2
  if (dim0 >= 2) return 0;
  if (dim1 >= 2) return 1;
  // both dim <= 1 - don't flip
  return 0;
}
origin: com.vividsolutions/jts

private void checkExpectedEmpty()
{
  // can't check areal features
  if (input.getDimension() >= 2) return;
  // can't check positive distances
  if (distance > 0.0) return;
    
  // at this point can expect an empty result
  if (! result.isEmpty()) {
    isValid = false;
    errorMsg = "Result is non-empty";
  errorIndicator = result;
  }
 report("ExpectedEmpty");
}
 
origin: com.vividsolutions/jts

if (geom.getDimension() == 1) return false;
if (geom.getDimension() == 2
    && prepLine.isAnyTargetComponentInTest(geom)) return true;
if (geom.getDimension() == 0)
  return isAnyTestPointInTarget(geom);
origin: com.vividsolutions/jts

/**
 * Tests whether this geometry overlaps the
 * specified geometry.
 * <p>
 * The <code>overlaps</code> predicate has the following equivalent definitions:
 * <ul>
 * <li>The geometries have at least one point each not shared by the other
 * (or equivalently neither covers the other),
 * they have the same dimension,
 * and the intersection of the interiors of the two geometries has
 * the same dimension as the geometries themselves.
 * <li>The DE-9IM Intersection Matrix for the two geometries matches
 *   <code>[T*T***T**]</code> (for two points or two surfaces)
 *   or <code>[1*T***T**]</code> (for two curves)
 * </ul>
 * If the geometries are of different dimension this predicate returns <code>false</code>.
 *
 *@param  g  the <code>Geometry</code> with which to compare this <code>Geometry</code>
 *@return        <code>true</code> if the two <code>Geometry</code>s overlap.
 */
public boolean overlaps(Geometry g) {
 // short-circuit test
 if (! getEnvelopeInternal().intersects(g.getEnvelopeInternal()))
  return false;
 return relate(g).isOverlaps(getDimension(), g.getDimension());
}
origin: com.vividsolutions/jts

/**
 * Tests whether this geometry touches the
 * argument geometry.
 * <p>
 * The <code>touches</code> predicate has the following equivalent definitions:
 * <ul>
 * <li>The geometries have at least one point in common, but their interiors do not intersect.
 * <li>The DE-9IM Intersection Matrix for the two geometries matches
 * at least one of the following patterns
 *  <ul>
 *   <li><code>[FT*******]</code>
 *   <li><code>[F**T*****]</code>
 *   <li><code>[F***T****]</code>
 *  </ul>
 * </ul>
 * If both geometries have dimension 0, this predicate returns <code>false</code>.
 * 
 *
 *@param  g  the <code>Geometry</code> with which to compare this <code>Geometry</code>
 *@return        <code>true</code> if the two <code>Geometry</code>s touch;
 *      Returns <code>false</code> if both <code>Geometry</code>s are points
 */
public boolean touches(Geometry g) {
 // short-circuit test
 if (! getEnvelopeInternal().intersects(g.getEnvelopeInternal()))
  return false;
 return relate(g).isTouches(getDimension(), g.getDimension());
}
origin: com.vividsolutions/jts

/**
 * Tests whether this geometry crosses the
 * argument geometry.
 * <p>
 * The <code>crosses</code> predicate has the following equivalent definitions:
 * <ul>
 * <li>The geometries have some but not all interior points in common.
 * <li>The DE-9IM Intersection Matrix for the two geometries matches
 * one of the following patterns:
 *   <ul>
 *    <li><code>[T*T******]</code> (for P/L, P/A, and L/A situations)
 *    <li><code>[T*****T**]</code> (for L/P, A/P, and A/L situations)
 *    <li><code>[0********]</code> (for L/L situations)
 *   </ul>
 * </ul>
 * For any other combination of dimensions this predicate returns <code>false</code>.
 * <p>
 * The SFS defined this predicate only for P/L, P/A, L/L, and L/A situations.
 * In order to make the relation symmetric,
 * JTS extends the definition to apply to L/P, A/P and A/L situations as well.
 *
 *@param  g  the <code>Geometry</code> with which to compare this <code>Geometry</code>
 *@return        <code>true</code> if the two <code>Geometry</code>s cross.
 */
public boolean crosses(Geometry g) {
 // short-circuit test
 if (! getEnvelopeInternal().intersects(g.getEnvelopeInternal()))
  return false;
 return relate(g).isCrosses(getDimension(), g.getDimension());
}
origin: com.vividsolutions/jts

return relate(g).isEquals(getDimension(), g.getDimension());
origin: com.vividsolutions/jts

/**
 * If the Geometries are disjoint, we need to enter their dimension and
 * boundary dimension in the Ext rows in the IM
 */
private void computeDisjointIM(IntersectionMatrix im)
{
 Geometry ga = arg[0].getGeometry();
 if (! ga.isEmpty()) {
  im.set(Location.INTERIOR, Location.EXTERIOR, ga.getDimension());
  im.set(Location.BOUNDARY, Location.EXTERIOR, ga.getBoundaryDimension());
 }
 Geometry gb = arg[1].getGeometry();
 if (! gb.isEmpty()) {
  im.set(Location.EXTERIOR, Location.INTERIOR, gb.getDimension());
  im.set(Location.EXTERIOR, Location.BOUNDARY, gb.getBoundaryDimension());
 }
}
origin: com.vividsolutions/jts

if (geom.getDimension() == 2) {
origin: com.vividsolutions/jts

 /**
  * Label an isolated edge of a graph with its relationship to the target geometry.
  * If the target has dim 2 or 1, the edge can either be in the interior or the exterior.
  * If the target has dim 0, the edge must be in the exterior
  */
 private void labelIsolatedEdge(Edge e, int targetIndex, Geometry target)
 {
  // this won't work for GeometryCollections with both dim 2 and 1 geoms
  if ( target.getDimension() > 0) {
  // since edge is not in boundary, may not need the full generality of PointLocator?
  // Possibly should use ptInArea locator instead?  We probably know here
  // that the edge does not touch the bdy of the target Geometry
   int loc = ptLocator.locate(e.getCoordinate(), target);
   e.getLabel().setAllLocations(targetIndex, loc);
  }
  else {
   e.getLabel().setAllLocations(targetIndex, Location.EXTERIOR);
  }
//System.out.println(e.getLabel());
 }
 
origin: com.vividsolutions/jts

private Geometry reducePointwise(Geometry geom)
{
 GeometryEditor geomEdit;
 if (changePrecisionModel) {
   GeometryFactory newFactory = createFactory(geom.getFactory(), targetPM);
  geomEdit = new GeometryEditor(newFactory);
 }
 else
  // don't change geometry factory
  geomEdit = new GeometryEditor();
 /**
  * For polygonal geometries, collapses are always removed, in order
  * to produce correct topology
  */
 boolean finalRemoveCollapsed = removeCollapsed;
 if (geom.getDimension() >= 2)
   finalRemoveCollapsed = true;
 
 Geometry reduceGeom = geomEdit.edit(geom, 
     new PrecisionReducerCoordinateOperation(targetPM, finalRemoveCollapsed));
 
 return reduceGeom;
}
 
origin: com.vividsolutions/jts

/**
 * Computes an interior point of this <code>Geometry</code>.
 * An interior point is guaranteed to lie in the interior of the Geometry,
 * if it possible to calculate such a point exactly. Otherwise,
 * the point may lie on the boundary of the geometry.
 * <p>
 * The interior point of an empty geometry is <code>POINT EMPTY</code>.
 *
 * @return a {@link Point} which is in the interior of this Geometry
 */
public Point getInteriorPoint()
{
 if (isEmpty()) 
  return factory.createPoint((Coordinate) null);
 Coordinate interiorPt = null;
 int dim = getDimension();
 if (dim == 0) {
  InteriorPointPoint intPt = new InteriorPointPoint(this);
  interiorPt = intPt.getInteriorPoint();
 }
 else if (dim == 1) {
  InteriorPointLine intPt = new InteriorPointLine(this);
  interiorPt = intPt.getInteriorPoint();
 }
 else {
  InteriorPointArea intPt = new InteriorPointArea(this);
  interiorPt = intPt.getInteriorPoint();
 }
 return createPointFromInternalCoord(interiorPt, this);
}
origin: com.vividsolutions/jts

private void computeProperIntersectionIM(SegmentIntersector intersector, IntersectionMatrix im)
 int dimA = arg[0].getGeometry().getDimension();
 int dimB = arg[1].getGeometry().getDimension();
 boolean hasProper         = intersector.hasProperIntersection();
 boolean hasProperInterior = intersector.hasProperInteriorIntersection();
origin: org.orbisgis/h2gis-functions

  /**
   * @param geometry Geometry instance
   * @return Geometry dimension
   */
  public static Integer getDimension(Geometry geometry) {
    if(geometry==null) {
      return null;
    }
    return geometry.getDimension();
  }
}
origin: com.vividsolutions/jts

 return factory.createPoint((Coordinate) null);
Coordinate centPt = null;
int dim = getDimension();
if (dim == 0) {
 CentroidPoint cent = new CentroidPoint();
origin: org.orbisgis/h2spatial

private void feedDim(Geometry geometry) {
  final int geomDim = geometry.getDimension();
  maxDim = Math.max(maxDim, geomDim);
  minDim = Math.min(minDim, geomDim);
}
origin: com.vividsolutions/jts

  && geom.getDimension() == 0) {
boolean isAnyInTargetInterior = isAnyTestComponentInTargetInterior(geom);
return isAnyInTargetInterior;
origin: org.fudaa.framework.ctulu/ctulu-gis

public int getDimension() {
 int dimension = Dimension.FALSE;
 final int n = getNumGeometries();
 for (int i = 0; i < n; i++) {
  dimension = Math.max(dimension, getGeometryN(i).getDimension());
 }
 return dimension;
}
com.vividsolutions.jts.geomGeometrygetDimension

Javadoc

Returns the dimension of this geometry. The dimension of a geometry is is the topological dimension of its embedding in the 2-D Euclidean plane. In the JTS spatial model, dimension values are in the set {0,1,2}.

Note that this is a different concept to the dimension of the vertex Coordinates. The geometry dimension can never be greater than the coordinate dimension. For example, a 0-dimensional geometry (e.g. a Point) may have a coordinate dimension of 3 (X,Y,Z).

Popular methods of Geometry

  • getEnvelopeInternal
    Gets an Envelope containing the minimum and maximum x and y values in this Geometry. If the geometr
  • getCoordinates
    Returns an array containing the values of all the vertices for this geometry. If the geometry is a c
  • isEmpty
    Tests whether the set of points covered by this Geometry is empty.
  • getCentroid
    Computes the centroid of this Geometry. The centroid is equal to the centroid of the set of componen
  • getGeometryN
    Returns an element Geometry from a GeometryCollection(or this, if the geometry is not a collection).
  • toText
    Returns the Well-known Text representation of this Geometry. For a definition of the Well-known Text
  • getNumGeometries
    Returns the number of Geometrys in a GeometryCollection(or 1, if the geometry is not a collection).
  • getFactory
    Gets the factory which contains the context in which this geometry was created.
  • getGeometryType
    Returns the name of this Geometry's actual class.
  • getSRID
    Returns the ID of the Spatial Reference System used by the Geometry. JTS supports Spatial Reference
  • getCoordinate
    Returns a vertex of this Geometry (usually, but not necessarily, the first one). The returned coordi
  • intersection
    Computes a Geometry representing the point-set which is common to both this Geometry and the other
  • getCoordinate,
  • intersection,
  • buffer,
  • contains,
  • getArea,
  • getEnvelope,
  • intersects,
  • union,
  • apply,
  • getLength

Popular in Java

  • Parsing JSON documents to java classes using gson
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • onCreateOptionsMenu (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • Reference (javax.naming)
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • JCheckBox (javax.swing)
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Option (scala)
  • Top Vim 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