Java Code Examples for com.esri.core.geometry.Envelope#getYMin()
The following examples show how to use
com.esri.core.geometry.Envelope#getYMin() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeoFunctions.java From presto with Apache License 2.0 | 6 votes |
@SqlNullable @Description("Returns the lower left and upper right corners of bounding rectangular polygon of a Geometry") @ScalarFunction("ST_EnvelopeAsPts") @SqlType("array(" + GEOMETRY_TYPE_NAME + ")") public static Block stEnvelopeAsPts(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { Envelope envelope = deserializeEnvelope(input); if (envelope.isEmpty()) { return null; } BlockBuilder blockBuilder = GEOMETRY.createBlockBuilder(null, 2); Point lowerLeftCorner = new Point(envelope.getXMin(), envelope.getYMin()); Point upperRightCorner = new Point(envelope.getXMax(), envelope.getYMax()); GEOMETRY.writeSlice(blockBuilder, serialize(createFromEsriGeometry(lowerLeftCorner, null, false))); GEOMETRY.writeSlice(blockBuilder, serialize(createFromEsriGeometry(upperRightCorner, null, false))); return blockBuilder.build(); }
Example 2
Source File: GeoFunctions.java From presto with Apache License 2.0 | 6 votes |
@ScalarFunction @SqlNullable @Description("Returns an array of spatial partition IDs for a geometry representing a set of points within specified distance from the input geometry") @SqlType("array(integer)") public static Block spatialPartitions(@SqlType(KdbTreeType.NAME) Object kdbTree, @SqlType(GEOMETRY_TYPE_NAME) Slice geometry, @SqlType(DOUBLE) double distance) { if (isNaN(distance)) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "distance is NaN"); } if (isInfinite(distance)) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "distance is infinite"); } if (distance < 0) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "distance is negative"); } Envelope envelope = deserializeEnvelope(geometry); if (envelope.isEmpty()) { return null; } Rectangle expandedEnvelope2D = new Rectangle(envelope.getXMin() - distance, envelope.getYMin() - distance, envelope.getXMax() + distance, envelope.getYMax() + distance); return spatialPartitions((KdbTree) kdbTree, expandedEnvelope2D); }
Example 3
Source File: BingTileFunctions.java From presto with Apache License 2.0 | 6 votes |
private static BingTile getTileCoveringLowerRightCorner(Envelope envelope, int zoomLevel) { BingTile tile = latitudeLongitudeToTile(envelope.getYMin(), envelope.getXMax(), zoomLevel); // If the tile covering the lower right corner of the envelope overlaps the envelope only // at the border then return a tile shifted to the left and/or top int deltaX = 0; int deltaY = 0; Point upperLeftCorner = tileXYToLatitudeLongitude(tile.getX(), tile.getY(), tile.getZoomLevel()); if (upperLeftCorner.getX() == envelope.getXMax()) { deltaX = -1; } if (upperLeftCorner.getY() == envelope.getYMin()) { deltaY = -1; } if (deltaX != 0 || deltaY != 0) { return BingTile.fromCoordinates(tile.getX() + deltaX, tile.getY() + deltaY, tile.getZoomLevel()); } return tile; }
Example 4
Source File: ClusterApp.java From arcgis-runtime-demo-java with Apache License 2.0 | 6 votes |
/** * Adds graphics symbolized with SimpleMarkerSymbols. * @param graphicsLayer */ private void addSimpleMarkerGraphics(GraphicsLayer graphicsLayer, Envelope bounds) { SimpleMarkerSymbol symbol = new SimpleMarkerSymbol(Color.RED, 16, Style.CIRCLE); double xmin = bounds.getXMin(); double xmax = bounds.getXMax(); double xrand; double ymin = bounds.getYMin(); double ymax = bounds.getYMax(); double yrand; for (int i = 0; i < 1000; i++) { xrand = xmin + (int) (Math.random() * ((xmax - xmin) + 1)); yrand = ymin + (int) (Math.random() * ((ymax - ymin) + 1)); Point point = new Point(xrand, yrand); graphicsLayer.addGraphic(new Graphic(point, symbol)); } }
Example 5
Source File: GeoFunctions.java From presto with Apache License 2.0 | 5 votes |
@SqlNullable @Description("Returns Y minima of a bounding box of a Geometry") @ScalarFunction("ST_YMin") @SqlType(DOUBLE) public static Double stYMin(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { Envelope envelope = deserializeEnvelope(input); if (envelope.isEmpty()) { return null; } return envelope.getYMin(); }
Example 6
Source File: GeoFunctions.java From presto with Apache License 2.0 | 5 votes |
@Description("Returns the Geometry value that represents the point set intersection of two Geometries") @ScalarFunction("ST_Intersection") @SqlType(GEOMETRY_TYPE_NAME) public static Slice stIntersection(@SqlType(GEOMETRY_TYPE_NAME) Slice left, @SqlType(GEOMETRY_TYPE_NAME) Slice right) { if (deserializeType(left) == GeometrySerializationType.ENVELOPE && deserializeType(right) == GeometrySerializationType.ENVELOPE) { Envelope leftEnvelope = deserializeEnvelope(left); Envelope rightEnvelope = deserializeEnvelope(right); // Envelope#intersect updates leftEnvelope to the intersection of the two envelopes if (!leftEnvelope.intersect(rightEnvelope)) { return EMPTY_POLYGON; } Envelope intersection = leftEnvelope; if (intersection.getXMin() == intersection.getXMax()) { if (intersection.getYMin() == intersection.getYMax()) { return serialize(createFromEsriGeometry(new Point(intersection.getXMin(), intersection.getXMax()), null)); } return serialize(createFromEsriGeometry(new Polyline(new Point(intersection.getXMin(), intersection.getYMin()), new Point(intersection.getXMin(), intersection.getYMax())), null)); } if (intersection.getYMin() == intersection.getYMax()) { return serialize(createFromEsriGeometry(new Polyline(new Point(intersection.getXMin(), intersection.getYMin()), new Point(intersection.getXMax(), intersection.getYMin())), null)); } return serialize(intersection); } OGCGeometry leftGeometry = deserialize(left); OGCGeometry rightGeometry = deserialize(right); verifySameSpatialReference(leftGeometry, rightGeometry); return serialize(leftGeometry.intersection(rightGeometry)); }
Example 7
Source File: SpatialPartitioningInternalAggregateFunction.java From presto with Apache License 2.0 | 5 votes |
@InputFunction public static void input(SpatialPartitioningState state, @SqlType(GEOMETRY_TYPE_NAME) Slice slice, @SqlType(INTEGER) long partitionCount) { Envelope envelope = deserializeEnvelope(slice); if (envelope.isEmpty()) { return; } Rectangle extent = new Rectangle(envelope.getXMin(), envelope.getYMin(), envelope.getXMax(), envelope.getYMax()); if (state.getCount() == 0) { state.setPartitionCount(toIntExact(partitionCount)); state.setExtent(extent); state.setSamples(new ArrayList<>()); } else { state.setExtent(state.getExtent().merge(extent)); } // use reservoir sampling List<Rectangle> samples = state.getSamples(); if (samples.size() <= MAX_SAMPLE_COUNT) { samples.add(extent); } else { long sampleIndex = ThreadLocalRandom.current().nextLong(state.getCount()); if (sampleIndex < MAX_SAMPLE_COUNT) { samples.set(toIntExact(sampleIndex), extent); } } state.setCount(state.getCount() + 1); }