use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class IndexedNestedRingTester method buildIndex.
private void buildIndex() {
this.index = new StrTree();
for (int i = 0; i < this.rings.size(); i++) {
final LinearRing ring = (LinearRing) this.rings.get(i);
final BoundingBox env = ring.getBoundingBox();
this.index.insertItem(env, ring);
}
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class LineSegmentVisitor method query.
public List query(final LineSegment querySeg) {
final BoundingBox env = querySeg.getBoundingBox();
final LineSegmentVisitor visitor = new LineSegmentVisitor(querySeg);
this.index.forEach(env, visitor);
final List itemsFound = visitor.getItems();
return itemsFound;
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class GeometricShapeFactory method newEllipse.
/**
* Creates an elliptical {@link Polygon}.
* If the supplied envelope is square the
* result will be a circle.
*
* @return an ellipse or circle
*/
public Polygon newEllipse() {
final BoundingBox env = this.dim.getEnvelope();
final double xRadius = env.getWidth() / 2.0;
final double yRadius = env.getHeight() / 2.0;
final double centreX = env.getMinX() + xRadius;
final double centreY = env.getMinY() + yRadius;
final double[] coordinates = new double[(this.vertexCount + 1) * 2];
int coordinateIndex = 0;
for (int i = 0; i < this.vertexCount; i++) {
final double ang = i * (2 * Math.PI / this.vertexCount);
final double x = xRadius * Math.cos(ang) + centreX;
final double y = yRadius * Math.sin(ang) + centreY;
coordinates[coordinateIndex++] = x;
coordinates[coordinateIndex++] = y;
}
coordinates[coordinateIndex++] = 0;
coordinates[coordinateIndex++] = 1;
final Polygon poly = this.geomFact.polygon(2, coordinates);
return poly;
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class GeometricShapeFactory method newArc.
/**
* Creates an elliptical arc, as a {@link LineString}.
* The arc is always created in a counter-clockwise direction.
* This can easily be reversed if required by using
* {#link LineString.reverse()}
*
* @param startAng start angle in radians
* @param angExtent size of angle in radians
* @return an elliptical arc
*/
public LineString newArc(final double startAng, final double angExtent) {
final BoundingBox env = this.dim.getEnvelope();
final double xRadius = env.getWidth() / 2.0;
final double yRadius = env.getHeight() / 2.0;
final double centreX = env.getMinX() + xRadius;
final double centreY = env.getMinY() + yRadius;
double angSize = angExtent;
if (angSize <= 0.0 || angSize > 2 * Math.PI) {
angSize = 2 * Math.PI;
}
final double angInc = angSize / (this.vertexCount - 1);
final Point[] pts = new Point[this.vertexCount];
int iPt = 0;
for (int i = 0; i < this.vertexCount; i++) {
final double ang = startAng + i * angInc;
final double x = xRadius * Math.cos(ang) + centreX;
final double y = yRadius * Math.sin(ang) + centreY;
pts[iPt++] = newPoint(x, y);
}
final LineString line = this.geomFact.lineString(pts);
return line;
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class UtmRectangularMapGrid method getTileByLocation.
@Override
public RectangularMapTile getTileByLocation(final double x, final double y) {
final String mapTileName = getMapTileName(x, y);
final BoundingBox boundingBox = getBoundingBox(mapTileName);
final String formattedMapTileName = getFormattedMapTileName(mapTileName);
return new SimpleRectangularMapTile(this, formattedMapTileName, mapTileName, boundingBox);
}
Aggregations