use of com.esri.core.geometry.Geometry in project sis by apache.
the class ESRI method tryGetEnvelope.
/**
* If the given object is an ESRI geometry and its envelope is non-empty, returns
* that envelope as an Apache SIS implementation. Otherwise returns {@code null}.
*
* @param geometry the geometry from which to get the envelope, or {@code null}.
* @return the envelope of the given object, or {@code null} if the object is not
* a recognized geometry or its envelope is empty.
*/
@Override
final GeneralEnvelope tryGetEnvelope(final Object geometry) {
if (geometry instanceof Geometry) {
final Envelope2D bounds = new Envelope2D();
((Geometry) geometry).queryEnvelope2D(bounds);
if (!bounds.isEmpty()) {
// Test if there is NaN values.
final GeneralEnvelope env = new GeneralEnvelope(2);
env.setRange(0, bounds.xmin, bounds.xmax);
env.setRange(1, bounds.ymin, bounds.ymax);
return env;
}
}
return null;
}
use of com.esri.core.geometry.Geometry in project presto by prestodb.
the class BingTileUtils method findRawTileCovering.
private static List<BingTile> findRawTileCovering(OGCGeometry ogcGeometry, int maxZoom) {
Envelope envelope = getEnvelope(ogcGeometry);
Optional<List<BingTile>> trivialResult = handleTrivialCases(envelope, maxZoom);
if (trivialResult.isPresent()) {
return trivialResult.get();
}
accelerateGeometry(ogcGeometry, OperatorIntersects.local(), Geometry.GeometryAccelerationDegree.enumMedium);
Deque<TilingEntry> stack = new ArrayDeque<>();
Consumer<BingTile> addIntersecting = tile -> {
TilingEntry tilingEntry = new TilingEntry(tile);
if (satisfiesTileEdgeCondition(envelope, tilingEntry) && ogcGeometry.intersects(tilingEntry.polygon)) {
stack.push(tilingEntry);
}
};
// Populate with initial tiles. Since there aren't many low zoom tiles,
// and throwing away totally disjoint ones is cheap (envelope check),
// we might as well start comprehensively.
ImmutableList.of(BingTile.fromCoordinates(0, 0, 1), BingTile.fromCoordinates(0, 1, 1), BingTile.fromCoordinates(1, 0, 1), BingTile.fromCoordinates(1, 1, 1)).forEach(addIntersecting);
List<BingTile> outputTiles = new ArrayList<>();
while (!stack.isEmpty()) {
TilingEntry entry = stack.pop();
if (entry.tile.getZoomLevel() == maxZoom || ogcGeometry.contains(entry.polygon)) {
outputTiles.add(entry.tile);
} else {
entry.tile.findChildren().forEach(addIntersecting);
checkCondition(outputTiles.size() + stack.size() <= MAX_COVERING_COUNT, "The zoom level is too high or the geometry is too large to compute a set " + "of covering Bing tiles. Please use a lower zoom level, or tile only a section " + "of the geometry.");
}
}
return outputTiles;
}
use of com.esri.core.geometry.Geometry in project presto by prestodb.
the class GeometryUtils method getPointCount.
public static int getPointCount(OGCGeometry ogcGeometry) {
GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor();
int points = 0;
while (true) {
com.esri.core.geometry.Geometry geometry = cursor.next();
if (geometry == null) {
return points;
}
if (geometry.isEmpty()) {
continue;
}
if (geometry instanceof Point) {
points++;
} else {
points += ((MultiVertexGeometry) geometry).getPointCount();
}
}
}
use of com.esri.core.geometry.Geometry in project presto by prestodb.
the class GeometryUtils method getEnvelope.
public static Envelope getEnvelope(OGCGeometry ogcGeometry) {
GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor();
Envelope overallEnvelope = new Envelope();
while (true) {
Geometry geometry = cursor.next();
if (geometry == null) {
return overallEnvelope;
}
Envelope envelope = new Envelope();
geometry.queryEnvelope(envelope);
overallEnvelope.merge(envelope);
}
}
use of com.esri.core.geometry.Geometry in project drill by apache.
the class ShpBatchReader method next.
@Override
public boolean next() {
Geometry geom = null;
while (!rowWriter.isFull()) {
Object[] dbfRow = dbfReader.nextRecord();
geom = geomCursor.next();
if (geom == null) {
return false;
}
processShapefileSet(rowWriter, geomCursor.getGeometryID(), geom, dbfRow);
}
return true;
}
Aggregations