use of com.esri.core.geometry.Point in project pigeon by aseldawy.
the class MakePoint method exec.
@Override
public DataByteArray exec(Tuple input) throws IOException {
if (input.size() != 2)
throw new GeoException("MakePoint takes two numerical arguments");
double x = ESRIGeometryParser.parseDouble(input.get(0));
double y = ESRIGeometryParser.parseDouble(input.get(1));
Point point = new Point(x, y);
OGCPoint ogc_point = new OGCPoint(point, SpatialReference.create(4326));
return new DataByteArray(ogc_point.asBinary().array());
}
use of com.esri.core.geometry.Point in project pigeon by aseldawy.
the class MakePolygon method exec.
@Override
public DataByteArray exec(Tuple b) throws IOException {
DataBag points = (DataBag) b.get(0);
Point[] coordinates = new Point[(int) points.size()];
int i = 0;
for (Tuple t : points) {
coordinates[i++] = (Point) (geometryParser.parseGeom(t.get(0))).getEsriGeometry();
}
Polygon multi_path = new Polygon();
for (i = 1; i < coordinates.length; i++) {
Segment segment = new Line();
segment.setStart(coordinates[i - 1]);
segment.setEnd(coordinates[i]);
multi_path.addSegment(segment, false);
}
OGCPolygon linestring = new OGCPolygon(multi_path, 0, SpatialReference.create(4326));
return new DataByteArray(linestring.asBinary().array());
}
use of com.esri.core.geometry.Point in project presto by prestodb.
the class BingTileUtils method satisfiesTileEdgeCondition.
/*
* BingTiles don't contain their eastern/southern edges, so that each point lies
* on a unique tile. However, the easternmost and southernmost tiles must contain
* their eastern and southern bounds (respectively), because they are the only
* tiles that can.
*/
private static boolean satisfiesTileEdgeCondition(Envelope query, TilingEntry entry) {
BingTile tile = entry.tile;
int maxXY = (1 << tile.getZoomLevel()) - 1;
if (tile.getY() < maxXY && query.getYMax() == entry.envelope.getYMin()) {
return false;
}
if (tile.getX() < maxXY && query.getXMin() == entry.envelope.getXMax()) {
return false;
}
return true;
}
use of com.esri.core.geometry.Point in project presto by prestodb.
the class BingTileUtils method latitudeLongitudeToTile.
/**
* Returns a Bing tile at a given zoom level containing a point at a given latitude and longitude.
* Latitude must be within [-85.05112878, 85.05112878] range. Longitude must be within [-180, 180] range.
* Zoom levels from 1 to 23 are supported.
*/
static BingTile latitudeLongitudeToTile(double latitude, double longitude, int zoomLevel) {
long mapSize = mapSize(zoomLevel);
int tileX = longitudeToTileX(longitude, mapSize);
int tileY = latitudeToTileY(latitude, mapSize);
return BingTile.fromCoordinates(tileX, tileY, zoomLevel);
}
use of com.esri.core.geometry.Point 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();
}
}
}
Aggregations