Search in sources :

Example 21 with Point

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());
}
Also used : OGCPoint(com.esri.core.geometry.ogc.OGCPoint) OGCPoint(com.esri.core.geometry.ogc.OGCPoint) Point(com.esri.core.geometry.Point) DataByteArray(org.apache.pig.data.DataByteArray)

Example 22 with Point

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());
}
Also used : Line(com.esri.core.geometry.Line) DataBag(org.apache.pig.data.DataBag) OGCPolygon(com.esri.core.geometry.ogc.OGCPolygon) Point(com.esri.core.geometry.Point) OGCPolygon(com.esri.core.geometry.ogc.OGCPolygon) Polygon(com.esri.core.geometry.Polygon) DataByteArray(org.apache.pig.data.DataByteArray) Point(com.esri.core.geometry.Point) Tuple(org.apache.pig.data.Tuple) Segment(com.esri.core.geometry.Segment)

Example 23 with Point

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;
}
Also used : Point(com.esri.core.geometry.Point)

Example 24 with Point

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);
}
Also used : Point(com.esri.core.geometry.Point)

Example 25 with Point

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();
        }
    }
}
Also used : GeometryCursor(com.esri.core.geometry.GeometryCursor) Geometry(com.esri.core.geometry.Geometry) OGCPoint(com.esri.core.geometry.ogc.OGCPoint) Point(com.esri.core.geometry.Point) OGCPoint(com.esri.core.geometry.ogc.OGCPoint) Point(com.esri.core.geometry.Point)

Aggregations

Point (com.esri.core.geometry.Point)33 OGCPoint (com.esri.core.geometry.ogc.OGCPoint)13 OGCGeometry (com.esri.core.geometry.ogc.OGCGeometry)7 Polyline (com.esri.core.geometry.Polyline)6 Description (com.facebook.presto.spi.function.Description)6 ScalarFunction (com.facebook.presto.spi.function.ScalarFunction)6 SqlType (com.facebook.presto.spi.function.SqlType)6 Polygon (com.esri.core.geometry.Polygon)4 GeometryUtils.createJtsEmptyPoint (com.facebook.presto.geospatial.GeometryUtils.createJtsEmptyPoint)4 GeometryUtils.createJtsMultiPoint (com.facebook.presto.geospatial.GeometryUtils.createJtsMultiPoint)4 GeometryUtils.createJtsPoint (com.facebook.presto.geospatial.GeometryUtils.createJtsPoint)4 SqlNullable (com.facebook.presto.spi.function.SqlNullable)4 Test (org.testng.annotations.Test)4 Geometry (com.esri.core.geometry.Geometry)3 Line (com.esri.core.geometry.Line)3 MultiPath (com.esri.core.geometry.MultiPath)3 OGCPolygon (com.esri.core.geometry.ogc.OGCPolygon)3 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)3 CartesianPoint (com.facebook.presto.geospatial.SphericalGeographyUtils.CartesianPoint)3 PrestoException (com.facebook.presto.spi.PrestoException)3