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(); }
public InteriorPointPoint(Geometry g) { centroid = g.getCentroid().getCoordinate(); add(g); }
public InteriorPointLine(Geometry g) { centroid = g.getCentroid().getCoordinate(); addInterior(g); if (interiorPoint == null) addEndpoints(g); }
static public Geometry centroid(Geometry arg0) { Geometry _this = arg0; return _this.getCentroid(); }
public static Geometry getCentroid(Geometry geometry) { if(geometry==null) { return null; } return geometry.getCentroid(); } }
static public Geometry centroid(Geometry arg0) { if (arg0 == null) return null; Geometry _this = arg0; return _this.getCentroid(); }
public static Geometry getCentroid(Geometry geometry) { if(geometry==null) { return null; } return geometry.getCentroid(); } }
public static Geometry getCentroid(Geometry geometry) { if(geometry==null) { return null; } return geometry.getCentroid(); } }
@Override public com.vividsolutions.jts.geom.Point getCentroid() { Geometry temp = getGeometry(); if(temp != null){ return temp.getCentroid(); } return null; }
@Override public com.vividsolutions.jts.geom.Point getCentroid() { Geometry temp = getGeometry(); if(temp != null){ return temp.getCentroid(); } return null; }
@Override public com.vividsolutions.jts.geom.Point getCentroid() { checkState(); return this.boundingBoxGeometry.getCentroid(); }
/** * 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); }
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); } }
@Override public Item item(final QueryContext qc, final InputInfo ii) throws QueryException { return toElement(checkGeo(0, qc).getCentroid(), qc); } }
public InteriorPointPoint(Geometry g) { centroid = g.getCentroid().getCoordinate(); add(g); }
/** * 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); }
@Override public JtsPoint getCenter() { if (isEmpty()) //geom.getCentroid == null return new JtsPoint(ctx.getGeometryFactory().createPoint((Coordinate)null), ctx); return new JtsPoint(geom.getCentroid(), ctx); }
/** * 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(); }
public InteriorPointLine(Geometry g) { centroid = g.getCentroid().getCoordinate(); addInterior(g); if (interiorPoint == null) addEndpoints(g); }
/** * 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()); }