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

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

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

origin: opentripplanner/OpenTripPlanner

public void setGeom(Geometry geom) throws EmptyPolygonException, UnsupportedGeometryException {
  if (geom instanceof MultiPolygon) {
    if (geom.isEmpty()) {
      throw new EmptyPolygonException();
    }
    if (geom.getNumGeometries() > 1) {
      // LOG.warn("Multiple polygons in MultiPolygon, using only the first.");
      // TODO percolate this warning up somehow
    }
    this.geom = geom.getGeometryN(0);
  } else if( geom instanceof Point || geom instanceof Polygon){
    this.geom = geom;
  } else {
    throw new UnsupportedGeometryException( "Non-point, non-polygon Geometry, not supported." );
  }
  // cache a representative point
  Point point = geom.getCentroid();
  this.lat = point.getY();
  this.lon = point.getX();
}
origin: com.vividsolutions/jts

public InteriorPointPoint(Geometry g)
{
 centroid = g.getCentroid().getCoordinate();
 add(g);
}
origin: com.vividsolutions/jts

public InteriorPointLine(Geometry g)
{
 centroid = g.getCentroid().getCoordinate();
 addInterior(g);
 if (interiorPoint == null)
  addEndpoints(g);
}
origin: org.geotools/gt2-main

static public Geometry centroid(Geometry arg0)
{
   Geometry _this = arg0;
   return _this.getCentroid();
}
origin: org.orbisgis/h2spatial

  public static Geometry getCentroid(Geometry geometry) {
    if(geometry==null) {
      return null;
    }
    return geometry.getCentroid();
  }
}
origin: org.geotools/gt-main

static public Geometry centroid(Geometry arg0)
{
   if (arg0 == null) return null;
   Geometry _this = arg0;
   return _this.getCentroid();
}
origin: org.orbisgis/h2gis-functions

  public static Geometry getCentroid(Geometry geometry) {
    if(geometry==null) {
      return null;
    }
    return geometry.getCentroid();
  }
}
origin: org.orbisgis/h2gis

  public static Geometry getCentroid(Geometry geometry) {
    if(geometry==null) {
      return null;
    }
    return geometry.getCentroid();
  }
}
origin: nl.cloudfarming.client/isobus-type

@Override
public com.vividsolutions.jts.geom.Point getCentroid() {
  Geometry temp = getGeometry();
  if(temp != null){
    return temp.getCentroid();
  }
  return null;
}
origin: nl.cloudfarming.client/isobus-tree

@Override
public com.vividsolutions.jts.geom.Point getCentroid() {
  Geometry temp = getGeometry();
  if(temp != null){
    return temp.getCentroid();
  }
  return null;
}
origin: eu.agrosense.client/grid

@Override
public com.vividsolutions.jts.geom.Point getCentroid() {
  checkState();
  return this.boundingBoxGeometry.getCentroid();
}
origin: Stratio/cassandra-lucene-index

/**
 * Returns the center of the specified {@link JtsGeometry}.
 *
 * @param shape the JTS shape to be transformed
 * @return the center
 */
@Override
public JtsGeometry apply(JtsGeometry shape) {
  Geometry centroid = shape.getGeom().getCentroid();
  return CONTEXT.makeShape(centroid);
}
origin: org.geotools/gt-main

  public Object evaluate(Object feature) {
    Geometry  arg0;


    try{  //attempt to get value and perform conversion
      arg0 = (Geometry) getExpression(0).evaluate(feature);
    }
    catch (Exception e) // probably a type error
    {
       throw new IllegalArgumentException("Filter Function problem for function getZ argument #0 - expected type Geometry");
    }

    return new Double(arg0.getCentroid().getCoordinate().z);
    
  }
}
origin: BaseXdb/basex

 @Override
 public Item item(final QueryContext qc, final InputInfo ii) throws QueryException {
  return toElement(checkGeo(0, qc).getCentroid(), qc);
 }
}
origin: com.vividsolutions/jts-core

public InteriorPointPoint(Geometry g)
{
 centroid = g.getCentroid().getCoordinate();
 add(g);
}
origin: Stratio/cassandra-lucene-index

/**
 * Returns the center of the specified {@link JtsGeometry}.
 *
 * @return the center
 */
@Override
public JtsGeometry apply() {
  Geometry centroid = shape.apply().getGeom().getCentroid();
  return CONTEXT.makeShape(centroid);
}
origin: com.spatial4j/spatial4j

@Override
public JtsPoint getCenter() {
 if (isEmpty()) //geom.getCentroid == null
  return new JtsPoint(ctx.getGeometryFactory().createPoint((Coordinate)null), ctx);
 return new JtsPoint(geom.getCentroid(), ctx);
}
origin: org.geotools/gt-process-raster

/**
 * Gets a point to represent the Geometry. If the Geometry is a point, this is returned.
 * Otherwise, the centroid is used.
 * 
 * @param g the geometry to find a point for
 * @return a point representing the Geometry
 */
private static Coordinate getPoint(Geometry g) {
  if (g.getNumPoints() == 1)
    return g.getCoordinate();
  return g.getCentroid().getCoordinate();
}
origin: com.vividsolutions/jts-core

public InteriorPointLine(Geometry g)
{
 centroid = g.getCentroid().getCoordinate();
 addInterior(g);
 if (interiorPoint == null)
  addEndpoints(g);
}
origin: org.geotools/gt-jts-wrapper

/**
 * Returns the centroid of this geometry.
 */
public final DirectPosition getCentroid() {
  com.vividsolutions.jts.geom.Geometry jtsGeom = getJTSGeometry();
  com.vividsolutions.jts.geom.Point jtsCentroid = jtsGeom.getCentroid();
  return JTSUtils.pointToDirectPosition(jtsCentroid,
      getCoordinateReferenceSystem());
}
com.vividsolutions.jts.geomGeometrygetCentroid

Javadoc

Computes the centroid of this Geometry. The centroid is equal to the centroid of the set of component Geometries of highest dimension (since the lower-dimension geometries contribute zero "weight" to the centroid).

The centroid of an empty geometry is POINT EMPTY.

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.
  • 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
  • buffer
    Computes a buffer area around this geometry having the given width and with a specified accuracy of
  • intersection,
  • buffer,
  • contains,
  • getArea,
  • getEnvelope,
  • intersects,
  • union,
  • apply,
  • getLength

Popular in Java

  • Reading from database using SQL prepared statement
  • getSupportFragmentManager (FragmentActivity)
  • startActivity (Activity)
  • getSystemService (Context)
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • JButton (javax.swing)
  • 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