本文整理了Java中org.locationtech.jts.geom.Polygon.getEnvelopeInternal()
方法的一些代码示例,展示了Polygon.getEnvelopeInternal()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Polygon.getEnvelopeInternal()
方法的具体详情如下:
包路径:org.locationtech.jts.geom.Polygon
类名称:Polygon
方法名:getEnvelopeInternal
暂无
代码示例来源:origin: geotools/geotools
public Envelope getEnvelopeInternal() {
return polygon.getEnvelopeInternal();
}
代码示例来源:origin: geotools/geotools
public Envelope decodeGeometryEnvelope(ResultSet rs, int column, Connection cx)
throws SQLException, IOException {
// String wkb = rs.getString( column );
byte[] wkb = rs.getBytes(column);
try {
// TODO: srid
Polygon polygon = (Polygon) new WKBReader().read(wkb);
return polygon.getEnvelopeInternal();
} catch (ParseException e) {
String msg = "Error decoding wkb for envelope";
throw (IOException) new IOException(msg).initCause(e);
}
}
代码示例来源:origin: geotools/geotools
public Object getProperty(Object object, QName name) {
// check for a polygon
if (object instanceof Polygon) {
object = ((Polygon) object).getEnvelopeInternal();
}
Envelope e = (Envelope) object;
if ("Envelope".equals(name.getLocalPart()) && !e.isNull()) {
return e;
}
if ("Null".equals(name.getLocalPart()) && e.isNull()) {
return e;
}
return null;
}
}
代码示例来源:origin: geotools/geotools
protected Node find(Polygon polygon) {
List close = index.query(polygon.getEnvelopeInternal());
for (Iterator itr = close.iterator(); itr.hasNext(); ) {
Node node = (Node) itr.next();
Polygon p = (Polygon) node.getObject();
if (rel.equal(polygon, p)) {
return node;
}
}
return null;
}
代码示例来源:origin: geotools/geotools
/**
* Rectangle ordinates for polygon.
*
* <p>You should in sure that the provided <code>polygon</code> is a rectangle using
* isRectangle( Polygon )
*
* <p>
*
* @param list List to add coordiantes to
* @param polygon Polygon to be encoded
*/
private static void addCoordinatesInterpretation3(List list, Polygon poly) {
Envelope e = poly.getEnvelopeInternal();
list.add(new double[] {e.getMinX(), e.getMinY()});
list.add(new double[] {e.getMaxX(), e.getMaxY()});
}
代码示例来源:origin: geotools/geotools
/**
* Convert the crop envelope into a polygon and the use the world-to-grid transform to get a ROI
* for the source coverage.
*/
public static Polygon getPolygon(final GeneralEnvelope env, final GeometryFactory gf)
throws IllegalStateException, MismatchedDimensionException {
final Rectangle2D rect = env.toRectangle2D();
final Coordinate[] coord =
new Coordinate[] {
new Coordinate(rect.getMinX(), rect.getMinY()),
new Coordinate(rect.getMinX(), rect.getMaxY()),
new Coordinate(rect.getMaxX(), rect.getMaxY()),
new Coordinate(rect.getMaxX(), rect.getMinY()),
new Coordinate(rect.getMinX(), rect.getMinY())
};
final LinearRing ring = gf.createLinearRing(coord);
final Polygon modelSpaceROI = new Polygon(ring, null, gf);
// check that we have the same thing here
assert modelSpaceROI
.getEnvelopeInternal()
.equals(new ReferencedEnvelope(rect, env.getCoordinateReferenceSystem()));
return modelSpaceROI;
}
代码示例来源:origin: geotools/geotools
public Graphable remove(Object obj) {
Node node = (Node) get(obj);
if (node != null) {
Polygon polygon = (Polygon) node.getObject();
index.remove(polygon.getEnvelopeInternal(), node);
builder.removeNode(node);
}
return node;
}
代码示例来源:origin: geotools/geotools
protected void relate(Node node) {
Polygon polygon = (Polygon) node.getObject();
List close = index.query(polygon.getEnvelopeInternal());
for (Iterator itr = close.iterator(); itr.hasNext(); ) {
Node n = (Node) itr.next();
Polygon p = (Polygon) n.getObject();
if (!rel.equal(polygon, p) && rel.related(polygon, p)) {
Edge edge = builder.buildEdge(node, n);
builder.addEdge(edge);
builder.addEdge(edge);
}
}
}
}
代码示例来源:origin: geotools/geotools
public Graphable add(Object obj) {
Node node = (Node) get(obj);
if (node == null) {
node = builder.buildNode();
builder.addNode(node);
node.setObject(obj);
relate(node);
// TODO: the envelope should be buffered by some tolerance
index.insert(((Polygon) obj).getEnvelopeInternal(), node);
}
return node;
}
代码示例来源:origin: geotools/geotools
private ReferencedEnvelope reduceEnvelope(
ReferencedEnvelope envelope, ProjectionHandler handler)
throws TransformException, FactoryException {
Polygon polygon = JTS.toGeometry(envelope);
Geometry geom = handler.preProcess(polygon);
if (geom == null) {
return null;
}
PolygonExtractor pe = new PolygonExtractor();
Polygon largest = null;
for (Polygon p : pe.getPolygons(geom)) {
if (largest == null || largest.getArea() > p.getArea()) {
largest = p;
}
}
ReferencedEnvelope reduced =
new ReferencedEnvelope(
largest.getEnvelopeInternal(), envelope.getCoordinateReferenceSystem());
return reduced;
}
代码示例来源:origin: geotools/geotools
private double[] getTranslationFactors(Polygon reference, Polygon displaced) {
// compare the two envelopes
Envelope re = reference.getEnvelopeInternal();
Envelope de = displaced.getEnvelopeInternal();
double dw = Math.abs(re.getWidth() - de.getWidth());
double dh = Math.abs(re.getHeight() - de.getHeight());
if (dw > EPS * re.getWidth() || dh > EPS * re.getWidth()) {
// this was not just a translation
return null;
}
// compute the translation
double dx = de.getMinX() - re.getMinX();
double dy = de.getMinY() - re.getMinY();
Polygon cloned = (Polygon) displaced.copy();
cloned.apply(AffineTransformation.translationInstance(-dx, -dy));
if (1 - new HausdorffSimilarityMeasure().measure(cloned, reference) > EPS) {
return null;
} else {
return new double[] {dx, dy};
}
}
代码示例来源:origin: geotools/geotools
if (displayGeomEnv.contains(poly.getEnvelopeInternal())) {
代码示例来源:origin: geotools/geotools
for (Polygon p : polygons) {
ReferencedEnvelope cropEnvelope =
new ReferencedEnvelope(p.getEnvelopeInternal(), readerCRS);
cropEnvelope =
new ReferencedEnvelope(
代码示例来源:origin: geotools/geotools
@Test
public void box() throws Exception {
Polygon p =
builder.box(
RECT_ENV.getMinX(),
RECT_ENV.getMinY(),
RECT_ENV.getMaxX(),
RECT_ENV.getMaxY());
assertBounds(RECT_ENV, p.getEnvelopeInternal(), 1.0e-8);
}
代码示例来源:origin: geotools/geotools
@Test
public void circle() throws Exception {
double radius = SQUARE_ENV.getWidth() / 2;
Polygon p =
builder.circle(
SQUARE_ENV.getMinX() + radius,
SQUARE_ENV.getMinY() + radius,
radius,
getNumSides(SQUARE_ENV));
assertBounds(SQUARE_ENV, p.getEnvelopeInternal(), 0.01);
}
代码示例来源:origin: geotools/geotools
@Test
public void ellipse() throws Exception {
Polygon p =
builder.ellipse(
RECT_ENV.getMinX(),
RECT_ENV.getMinY(),
RECT_ENV.getMaxX(),
RECT_ENV.getMaxY(),
getNumSides(RECT_ENV));
assertBounds(RECT_ENV, p.getEnvelopeInternal(), 0.01);
}
代码示例来源:origin: geotools/geotools
@Test
public void boxZ() throws Exception {
Polygon p =
builder.boxZ(
RECT_ENV.getMinX(),
RECT_ENV.getMinY(),
RECT_ENV.getMaxX(),
RECT_ENV.getMaxY(),
42);
assertBounds(RECT_ENV, p.getEnvelopeInternal(), 1.0e-8);
assertEquals(42, (int) p.getCoordinate().z);
}
代码示例来源:origin: geotools/geotools
@Test
public void smoothPolygon() {
Coordinate[] coords = getPolyCoords();
Polygon poly = factory.createPolygon(factory.createLinearRing(coords), null);
Geometry smoothed = JTS.smooth(poly, 0);
assertTrue(smoothed instanceof Polygon);
CoordList list = new CoordList(smoothed.getCoordinates());
assertTrue(list.containsAll(coords));
Envelope polyEnv = poly.getEnvelopeInternal();
Envelope smoothEnv = smoothed.getEnvelopeInternal();
assertTrue(smoothEnv.covers(polyEnv));
}
代码示例来源:origin: geotools/geotools
bounds.expandToInclude(geom.getEnvelopeInternal());
代码示例来源:origin: geotools/geotools
Envelope e2 = new Envelope(3.25, 3.75, 1.25, 1.75);
assertTrue(e1.contains(e2));
assertTrue(p.getEnvelopeInternal().contains(e2));
assertTrue(p.getEnvelopeInternal().intersects(e1));
BBOXImpl bbox1 =
(BBOXImpl)
内容来源于网络,如有侵权,请联系作者删除!