com.esri.core.geometry.Envelope Java Examples

The following examples show how to use com.esri.core.geometry.Envelope. 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: ST_MinX.java    From spatial-framework-for-hadoop with Apache License 2.0 6 votes vote down vote up
public DoubleWritable evaluate(BytesWritable geomref) {
	if (geomref == null || geomref.getLength() == 0) {
		LogUtils.Log_ArgumentsNull(LOG);
		return null;
	}

	OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref);
	if (ogcGeometry == null) {
		LogUtils.Log_ArgumentsNull(LOG);
		return null;
	}

	Envelope envBound = new Envelope();
	ogcGeometry.getEsriGeometry().queryEnvelope(envBound);
	resultDouble.set(envBound.getXMin());
	return resultDouble;
}
 
Example #2
Source File: GeoFunctions.java    From presto with Apache License 2.0 6 votes vote down vote up
@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 #3
Source File: GeoFunctions.java    From presto with Apache License 2.0 6 votes vote down vote up
@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 #4
Source File: BingTileFunctions.java    From presto with Apache License 2.0 6 votes vote down vote up
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 #5
Source File: BingTileFunctions.java    From presto with Apache License 2.0 6 votes vote down vote up
private static void checkGeometryToBingTilesLimits(OGCGeometry ogcGeometry, Envelope envelope, boolean pointOrRectangle, long tileCount, int zoomLevel)
{
    if (pointOrRectangle) {
        checkCondition(tileCount <= 1_000_000, "The number of tiles covering input rectangle exceeds the limit of 1M. " +
                        "Number of tiles: %d. Rectangle: xMin=%.2f, yMin=%.2f, xMax=%.2f, yMax=%.2f. Zoom level: %d.",
                tileCount, envelope.getXMin(), envelope.getYMin(), envelope.getXMax(), envelope.getYMax(), zoomLevel);
    }
    else {
        checkCondition((int) tileCount == tileCount, "The zoom level is too high to compute a set of covering Bing tiles.");
        long complexity = 0;
        try {
            complexity = multiplyExact(tileCount, getPointCount(ogcGeometry));
        }
        catch (ArithmeticException e) {
            checkCondition(false, "The zoom level is too high or the geometry is too complex to compute a set of covering Bing tiles. " +
                    "Please use a lower zoom level or convert the geometry to its bounding box using the ST_Envelope function.");
        }
        checkCondition(complexity <= 25_000_000, "The zoom level is too high or the geometry is too complex to compute a set of covering Bing tiles. " +
                "Please use a lower zoom level or convert the geometry to its bounding box using the ST_Envelope function.");
    }
}
 
Example #6
Source File: GeometrySerde.java    From presto with Apache License 2.0 6 votes vote down vote up
private static Envelope getEnvelope(BasicSliceInput input, GeometrySerializationType type, int length)
{
    switch (type) {
        case POINT:
            return getPointEnvelope(input);
        case MULTI_POINT:
        case LINE_STRING:
        case MULTI_LINE_STRING:
        case POLYGON:
        case MULTI_POLYGON:
            return getSimpleGeometryEnvelope(input, length);
        case GEOMETRY_COLLECTION:
            return getGeometryCollectionOverallEnvelope(input);
        case ENVELOPE:
            return readEnvelope(input);
        default:
            throw new IllegalArgumentException("Unexpected type: " + type);
    }
}
 
Example #7
Source File: TestGeometrySerialization.java    From presto with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeserializeType()
{
    assertDeserializeType("POINT (1 2)", POINT);
    assertDeserializeType("POINT EMPTY", POINT);
    assertDeserializeType("MULTIPOINT (20 20, 25 25)", MULTI_POINT);
    assertDeserializeType("MULTIPOINT EMPTY", MULTI_POINT);
    assertDeserializeType("LINESTRING (1 1, 5 1, 6 2))", LINE_STRING);
    assertDeserializeType("LINESTRING EMPTY", LINE_STRING);
    assertDeserializeType("MULTILINESTRING ((1 1, 5 1), (2 4, 4 4))", MULTI_LINE_STRING);
    assertDeserializeType("MULTILINESTRING EMPTY", MULTI_LINE_STRING);
    assertDeserializeType("POLYGON ((0 0, 0 4, 4 0))", POLYGON);
    assertDeserializeType("POLYGON EMPTY", POLYGON);
    assertDeserializeType("MULTIPOLYGON (((0 0 , 0 2, 2 2, 2 0)), ((2 2, 2 4, 4 4, 4 2)))", MULTI_POLYGON);
    assertDeserializeType("MULTIPOLYGON EMPTY", MULTI_POLYGON);
    assertDeserializeType("GEOMETRYCOLLECTION (POINT (3 7), LINESTRING (4 6, 7 10))", GEOMETRY_COLLECTION);
    assertDeserializeType("GEOMETRYCOLLECTION EMPTY", GEOMETRY_COLLECTION);

    assertEquals(deserializeType(serialize(new Envelope(1, 2, 3, 4))), ENVELOPE);
}
 
Example #8
Source File: ClusterApp.java    From arcgis-runtime-demo-java with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #9
Source File: GeoFunctions.java    From Quicksql with MIT License 6 votes vote down vote up
/** Returns the OGC type of a geometry. */
private static Type type(Geometry g) {
  switch (g.getType()) {
  case Point:
    return Type.POINT;
  case Polyline:
    return Type.LINESTRING;
  case Polygon:
    return Type.POLYGON;
  case MultiPoint:
    return Type.MULTIPOINT;
  case Envelope:
    return Type.POLYGON;
  case Line:
    return Type.LINESTRING;
  case Unknown:
    return Type.Geometry;
  default:
    throw new AssertionError(g);
  }
}
 
Example #10
Source File: MoreMapLayer.java    From arcgis-android-moremap with Apache License 2.0 6 votes vote down vote up
protected void initLayer() {
    if (getID() == 0L) {
        nativeHandle = create();
        changeStatus(com.esri.android.map.event.OnStatusChangedListener.STATUS
                .fromInt(-1000));
    } else {
        this.setDefaultSpatialReference(SpatialReference.create(layerInfo
                .getSrid()));
        this.setFullExtent(new Envelope(layerInfo.getxMin(), layerInfo
                .getyMin(), layerInfo.getxMax(), layerInfo.getyMax()));
        this.setTileInfo(new TileInfo(layerInfo.getOrigin(), layerInfo
                .getScales(), layerInfo.getResolutions(), layerInfo
                .getScales().length, layerInfo.getDpi(), layerInfo
                .getTileWidth(), layerInfo.getTileHeight()));
        super.initLayer();
    }
}
 
Example #11
Source File: GeoFunctions.java    From calcite with Apache License 2.0 6 votes vote down vote up
/** Returns the OGC type of a geometry. */
private static Type type(Geometry g) {
  switch (g.getType()) {
  case Point:
    return Type.POINT;
  case Polyline:
    return Type.LINESTRING;
  case Polygon:
    return Type.POLYGON;
  case MultiPoint:
    return Type.MULTIPOINT;
  case Envelope:
    return Type.POLYGON;
  case Line:
    return Type.LINESTRING;
  case Unknown:
    return Type.Geometry;
  default:
    throw new AssertionError(g);
  }
}
 
Example #12
Source File: ST_MaxY.java    From spatial-framework-for-hadoop with Apache License 2.0 6 votes vote down vote up
public DoubleWritable evaluate(BytesWritable geomref) {
	if (geomref == null || geomref.getLength() == 0) {
		LogUtils.Log_ArgumentsNull(LOG);
		return null;
	}

	OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref);
	if (ogcGeometry == null) {
		LogUtils.Log_ArgumentsNull(LOG);
		return null;
	}

	Envelope envBound = new Envelope();
	ogcGeometry.getEsriGeometry().queryEnvelope(envBound);
	resultDouble.set(envBound.getYMax());
	return resultDouble;
}
 
Example #13
Source File: ST_MinY.java    From spatial-framework-for-hadoop with Apache License 2.0 6 votes vote down vote up
public DoubleWritable evaluate(BytesWritable geomref) {
	if (geomref == null || geomref.getLength() == 0) {
		LogUtils.Log_ArgumentsNull(LOG);
		return null;
	}

	OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref);
	if (ogcGeometry == null) {
		LogUtils.Log_ArgumentsNull(LOG);
		return null;
	}

	Envelope envBound = new Envelope();
	ogcGeometry.getEsriGeometry().queryEnvelope(envBound);
	resultDouble.set(envBound.getYMin());
	return resultDouble;
}
 
Example #14
Source File: ST_MaxX.java    From spatial-framework-for-hadoop with Apache License 2.0 6 votes vote down vote up
public DoubleWritable evaluate(BytesWritable geomref) {
	if (geomref == null || geomref.getLength() == 0) {
		LogUtils.Log_ArgumentsNull(LOG);
		return null;
	}

	OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref);
	if (ogcGeometry == null) {
		LogUtils.Log_ArgumentsNull(LOG);
		return null;
	}

	Envelope envBound = new Envelope();
	ogcGeometry.getEsriGeometry().queryEnvelope(envBound);
	resultDouble.set(envBound.getXMax());
	return resultDouble;
}
 
Example #15
Source File: ST_Envelope.java    From spatial-framework-for-hadoop with Apache License 2.0 6 votes vote down vote up
public BytesWritable evaluate(BytesWritable geometryref)
{
	if (geometryref == null || geometryref.getLength() == 0) {
		LogUtils.Log_ArgumentsNull(LOG);
		return null;
	}

	OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geometryref);
	if (ogcGeometry == null){
		LogUtils.Log_ArgumentsNull(LOG);
		return null;
	}

	int wkid = GeometryUtils.getWKID(geometryref);
	SpatialReference spatialReference = null;
	if (wkid != GeometryUtils.WKID_UNKNOWN) {
		spatialReference = SpatialReference.create(wkid);
	}
	Envelope envBound = new Envelope();
	ogcGeometry.getEsriGeometry().queryEnvelope(envBound);
	return GeometryUtils.geometryToEsriShapeBytesWritable(OGCGeometry.createFromEsriGeometry(envBound,
															  spatialReference));
}
 
Example #16
Source File: ClusterLayer.java    From arcgis-runtime-demo-java with Apache License 2.0 6 votes vote down vote up
private Envelope getBoundingRectangle(Cluster<ClusterableLocation> cluster) {
  double xmin = cluster.getPoints().get(0).getPoint()[0];
  double xmax = xmin;
  double ymin = cluster.getPoints().get(0).getPoint()[1];
  double ymax = ymin;
  for (ClusterableLocation p : cluster.getPoints()) {
    if (p.getPoint()[0] < xmin) {
      xmin = p.getPoint()[0];
    }
    if (p.getPoint()[0] > xmax) {
      xmax = p.getPoint()[0];
    }
    if (p.getPoint()[1] < ymin) {
      ymin = p.getPoint()[1];
    }
    if (p.getPoint()[1] > ymax) {
      ymax = p.getPoint()[1];
    }
  }
  Envelope boundingRectangle = new Envelope(xmin, ymin, xmax, ymax);
  return boundingRectangle;
}
 
Example #17
Source File: GeoFunctions.java    From Bats with Apache License 2.0 6 votes vote down vote up
/** Returns the OGC type of a geometry. */
private static Type type(Geometry g) {
  switch (g.getType()) {
  case Point:
    return Type.POINT;
  case Polyline:
    return Type.LINESTRING;
  case Polygon:
    return Type.POLYGON;
  case MultiPoint:
    return Type.MULTIPOINT;
  case Envelope:
    return Type.POLYGON;
  case Line:
    return Type.LINESTRING;
  case Unknown:
    return Type.Geometry;
  default:
    throw new AssertionError(g);
  }
}
 
Example #18
Source File: GeoFunctions.java    From presto with Apache License 2.0 5 votes vote down vote up
@SqlNullable
@Description("Returns X maxima of a bounding box of a Geometry")
@ScalarFunction("ST_XMax")
@SqlType(DOUBLE)
public static Double stXMax(@SqlType(GEOMETRY_TYPE_NAME) Slice input)
{
    Envelope envelope = deserializeEnvelope(input);
    if (envelope.isEmpty()) {
        return null;
    }
    return envelope.getXMax();
}
 
Example #19
Source File: RasterAnalysisHelper.java    From arcgis-runtime-demos-android with Apache License 2.0 5 votes vote down vote up
public void loadRasterAsBasemap() {
  if (mMapView == null) {
    return;
  }

  try {
    mMapView.removeAll();
    // Create a RasterSource from a local raster file
    FileRasterSource rasterSource = new FileRasterSource(mPathLayer);
    // Create a raster layer from the RasterSource
    mRasterLayer = new RasterLayer(rasterSource);
    // allow to zoom in after the largest LOD for the Landsat 8 image
    mRasterLayer.setMaxScale(200000);
    // Add the raster layer to the map view
    mMapView.addLayer(mRasterLayer);
    // Set RGBRenderer
    applyRGBRenderer(true);

    // Set the extent
    Envelope initialExtent = new Envelope(-157.4368965374797, 20.516069728186316, -155.81463794462434, 21.298471528698848);
    mMapView.setExtent(initialExtent);

    // Add a graphics layer
    mGraphicsLayer = new GraphicsLayer();
    mMapView.addLayer(mGraphicsLayer);

  } catch (FileNotFoundException | RuntimeException e) {
    e.printStackTrace();
  }

}
 
Example #20
Source File: ST_BinEnvelope.java    From spatial-framework-for-hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public Object evaluate(DeferredObject[] args) throws HiveException {
	double binSize = PrimitiveObjectInspectorUtils.getDouble(args[0].get(), oiBinSize);
	
	
	if (!binSizeIsConstant || bins == null) {
		bins = new BinUtils(binSize);
	} 
			
	Envelope env = new Envelope();
	
	if (oiBinId != null) {
		// argument 1 is a number, attempt to get the envelope with bin ID
		if (args[1].get() == null) {
			// null bin ID argument usually means the source point was null or failed to parse
			return null; 
		}
		
		long binId = PrimitiveObjectInspectorUtils.getLong(args[1].get(), oiBinId);
		bins.queryEnvelope(binId, env);
	} else {
		// argument 1 is a geometry, attempt to get the envelope with a point
		OGCPoint point = binPoint.getPoint(args);
		
		if (point == null) {
			return null;
		}
		
		bins.queryEnvelope(point.X(), point.Y(), env);
	}

	return GeometryUtils.geometryToEsriShapeBytesWritable(env, 0, OGCType.ST_POLYGON);
}
 
Example #21
Source File: GeoFunctions.java    From presto with Apache License 2.0 5 votes vote down vote up
@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 #22
Source File: GeoFunctions.java    From presto with Apache License 2.0 5 votes vote down vote up
@Description("Returns the bounding rectangular polygon of a Geometry")
@ScalarFunction("ST_Envelope")
@SqlType(GEOMETRY_TYPE_NAME)
public static Slice stEnvelope(@SqlType(GEOMETRY_TYPE_NAME) Slice input)
{
    Envelope envelope = deserializeEnvelope(input);
    if (envelope.isEmpty()) {
        return EMPTY_POLYGON;
    }
    return serialize(envelope);
}
 
Example #23
Source File: GeoFunctions.java    From presto with Apache License 2.0 5 votes vote down vote up
@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 #24
Source File: GeoFunctions.java    From presto with Apache License 2.0 5 votes vote down vote up
@SqlNullable
@Description("Returns TRUE if and only if no points of right lie in the exterior of left, and at least one point of the interior of left lies in the interior of right")
@ScalarFunction("ST_Contains")
@SqlType(BOOLEAN)
public static Boolean stContains(@SqlType(GEOMETRY_TYPE_NAME) Slice left, @SqlType(GEOMETRY_TYPE_NAME) Slice right)
{
    if (!envelopes(left, right, Envelope::contains)) {
        return false;
    }
    OGCGeometry leftGeometry = deserialize(left);
    OGCGeometry rightGeometry = deserialize(right);
    verifySameSpatialReference(leftGeometry, rightGeometry);
    return leftGeometry.contains(rightGeometry);
}
 
Example #25
Source File: TestGeometrySerialization.java    From presto with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeserializeEnvelope()
{
    assertDeserializeEnvelope("MULTIPOINT (20 20, 25 25)", new Envelope(20, 20, 25, 25));
    assertDeserializeEnvelope("MULTILINESTRING ((1 1, 5 1), (2 4, 4 4))", new Envelope(1, 1, 5, 4));
    assertDeserializeEnvelope("POLYGON ((0 0, 0 4, 4 0))", new Envelope(0, 0, 4, 4));
    assertDeserializeEnvelope("MULTIPOLYGON (((0 0 , 0 2, 2 2, 2 0)), ((2 2, 2 4, 4 4, 4 2)))", new Envelope(0, 0, 4, 4));
    assertDeserializeEnvelope("GEOMETRYCOLLECTION (POINT (3 7), LINESTRING (4 6, 7 10))", new Envelope(3, 6, 7, 10));
    assertDeserializeEnvelope("POLYGON EMPTY", new Envelope());
    assertDeserializeEnvelope("POINT (1 2)", new Envelope(1, 2, 1, 2));
    assertDeserializeEnvelope("POINT EMPTY", new Envelope());
    assertDeserializeEnvelope("GEOMETRYCOLLECTION (GEOMETRYCOLLECTION (POINT (2 7), LINESTRING (4 6, 7 10)), POINT (3 7), LINESTRING (4 6, 7 10))", new Envelope(2, 6, 7, 10));
}
 
Example #26
Source File: GeometryOfflineApp.java    From arcgis-runtime-demo-java with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a map.
 * @return a map.
 */
private JMap createMap() throws Exception {
  final JMap jMap = new JMap();
  // -----------------------------------------------------------------------------------------
  // Base Layer - set initial map extent to USA
  // -----------------------------------------------------------------------------------------
  final ArcGISLocalTiledLayer tiledLayer = new ArcGISLocalTiledLayer(TPK_PATH);
  jMap.setExtent(new Envelope(-15000000, 2000000, -7000000, 8000000));
  jMap.getLayers().add(tiledLayer);

  // -----------------------------------------------------------------------------------------
  // Graphics Layer - to add lines
  // -----------------------------------------------------------------------------------------
  graphicsLayerQueryResults = new GraphicsLayer();
  jMap.getLayers().add(graphicsLayerQueryResults);
  
  graphicsLayer = new GraphicsLayer();
  jMap.getLayers().add(graphicsLayer);

  jMap.addMapOverlay(new MouseOverlay(jMap, graphicsLayer, graphicsLayerQueryResults));

  // create the geodatabase and geodatabase feature table once
  try {
    geodatabase = new Geodatabase(GEODATABASE_PATH);
    table = geodatabase.getGeodatabaseFeatureTableByLayerId(LAYER_ID);
  } catch (Exception e) {
    JOptionPane.showMessageDialog(contentPane, "Error: " + e.getLocalizedMessage() + "\r\nSee notes for this application.");
  }

  jMap.getLayers().add(new FeatureLayer(table));

  return jMap;
}
 
Example #27
Source File: TestGeometrySerialization.java    From presto with Apache License 2.0 5 votes vote down vote up
@Test
public void testEnvelope()
{
    testEnvelopeSerialization(new Envelope(0, 0, 1, 1));
    testEnvelopeSerialization(new Envelope(1, 2, 3, 4));
    testEnvelopeSerialization(new Envelope(10101, -2.05, -3e5, 0));
}
 
Example #28
Source File: GeometrySerde.java    From presto with Apache License 2.0 5 votes vote down vote up
@Nullable
private static Envelope merge(@Nullable Envelope left, @Nullable Envelope right)
{
    if (left == null) {
        return right;
    }
    if (right == null) {
        return left;
    }
    right.merge(left);
    return right;
}
 
Example #29
Source File: GeometrySerde.java    From presto with Apache License 2.0 5 votes vote down vote up
private static void writeEnvelopeCoordinates(DynamicSliceOutput output, Envelope envelope)
{
    if (envelope.isEmpty()) {
        output.appendDouble(NaN);
        output.appendDouble(NaN);
        output.appendDouble(NaN);
        output.appendDouble(NaN);
    }
    else {
        output.appendDouble(envelope.getXMin());
        output.appendDouble(envelope.getYMin());
        output.appendDouble(envelope.getXMax());
        output.appendDouble(envelope.getYMax());
    }
}
 
Example #30
Source File: BinUtils.java    From spatial-framework-for-hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the envelope for the bin that contains the x,y coords.
 * 
 * @param x
 * @param y
 * @param envelope
 */
public void queryEnvelope(double x, double y, Envelope envelope) {
	double down = (extentMax - y) / binSize;
	double over = (x - extentMin) / binSize;
	
	double xmin = extentMin + (over * binSize);
	double xmax = xmin + binSize;
	double ymax = extentMax - (down * binSize);
	double ymin = ymax - binSize;
	
	envelope.setCoords(xmin, ymin, xmax, ymax);
}