本文整理汇总了Java中com.esri.arcgisruntime.geometry.GeometryEngine类的典型用法代码示例。如果您正苦于以下问题:Java GeometryEngine类的具体用法?Java GeometryEngine怎么用?Java GeometryEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GeometryEngine类属于com.esri.arcgisruntime.geometry包,在下文中一共展示了GeometryEngine类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResultEnvelope
import com.esri.arcgisruntime.geometry.GeometryEngine; //导入依赖的package包/类
/**
* Return the current extent. If the current extent is null,
* calculate extent based on current search results.
* @return Envelope
*/
public final Envelope getResultEnvelope(){
if (mCurrentEnvelope == null){
Envelope envelope = null;
final List<Place> places = getPlacesFromRepo();
if (!places.isEmpty()){
final List<Point> points = new ArrayList<>();
for (final Place place : places){
points.add(place.getLocation());
}
final Multipoint mp = new Multipoint(points);
envelope = GeometryEngine.buffer(mp, 0.0007).getExtent();
}
return envelope;
}else{
return mCurrentEnvelope;
}
}
示例2: animate
import com.esri.arcgisruntime.geometry.GeometryEngine; //导入依赖的package包/类
/**
* Moves the tank toward the current waypoint a short distance.
*/
private void animate() {
if (waypoint != null) {
// get current location and distance from waypoint
Point location = (Point) tank.getGeometry();
GeodeticDistanceResult distance = GeometryEngine.distanceGeodetic(location, waypoint, METERS, DEGREES,
GeodeticCurveType.GEODESIC);
// move toward waypoint a short distance
location = GeometryEngine.moveGeodetic(location, 1.0, METERS, distance.getAzimuth1(), DEGREES,
GeodeticCurveType.GEODESIC);
tank.setGeometry(location);
// rotate toward waypoint
double heading = (double) tank.getAttributes().get("HEADING");
tank.getAttributes().put("HEADING", heading + ((distance.getAzimuth1() - heading) / 10));
// reached waypoint, stop moving
if (distance.getDistance() <= 5) {
waypoint = null;
}
}
}
示例3: onCreate
import com.esri.arcgisruntime.geometry.GeometryEngine; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MapView mapView = (MapView)findViewById(R.id.mapView);
// create ArcGISMap with topographic basemap
ArcGISMap map = new ArcGISMap(Basemap.createLightGrayCanvas());
mapView.setMap(map);
// create graphics overlays to show the inputs and results of the spatial operation
mapView.getGraphicsOverlays().add(inputGeometryOverlay);
mapView.getGraphicsOverlays().add(resultGeometryOverlay);
// create input polygons and add graphics to display these polygons in an overlay
createPolygons();
// center the map view on the input geometries
Geometry viewpointGeom = GeometryEngine.union(inputPolygon1, inputPolygon2).getExtent();
mapView.setViewpointGeometryAsync(viewpointGeom, 20);
}
示例4: deriveScreenPointForLocation
import com.esri.arcgisruntime.geometry.GeometryEngine; //导入依赖的package包/类
private android.graphics.Point deriveScreenPointForLocation(final Geometry location){
final MapView mapView = (MapView) solo.getView(R.id.mapView) ;
final DisplayMetrics metrics = new DisplayMetrics();
mActivityRule.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);;
final float screenHeight = metrics.heightPixels;
final float mapViewHeight = mapView.getHeight();
final float buffer = screenHeight - mapViewHeight;
final Point projectedPoint = (Point) GeometryEngine.project(location, SpatialReference.create(3857));
final android.graphics.Point derivedPoint = mapView.locationToScreen(projectedPoint);
return new android.graphics.Point(derivedPoint.x,derivedPoint.y+Math.round(buffer));
}
示例5: findClosestWaterColumn
import com.esri.arcgisruntime.geometry.GeometryEngine; //导入依赖的package包/类
/**
* Find the closest WaterColumn to the center of the given Envelope
* @param envelope - Envelope
* @param waterColumnMap - Map<Geometry,WaterColumn> map of WaterColumn values keyed by Geometry objects.
* @return WaterColumn
*/
private static WaterColumn findClosestWaterColumn(final Envelope envelope,
final Map<Geometry, WaterColumn> waterColumnMap){
WaterColumn closestWaterColumn = null;
if (waterColumnMap.size() == 1){
final WaterColumn[] columns = waterColumnMap.values().toArray(new WaterColumn[1]);
closestWaterColumn = columns[0];
}
if (waterColumnMap.size() > 1){
final Point center = envelope.getCenter();
final LinearUnit linearUnit = new LinearUnit(LinearUnitId.METERS);
final AngularUnit angularUnit = new AngularUnit(AngularUnitId.DEGREES);
final Set<Geometry> geometries = waterColumnMap.keySet();
final Iterator<Geometry> iterator = geometries.iterator();
final List<WaterColumn> waterColumnList = new ArrayList<>();
while (iterator.hasNext()){
final Geometry geo = iterator.next();
final WaterColumn waterColumn = waterColumnMap.get(geo);
final Point point = (Point) geo;
final Point waterColumnPoint = new Point(point.getX(), point.getY(), center.getSpatialReference());
final GeodeticDistanceResult geodeticDistanceResult = GeometryEngine.distanceGeodetic(center, waterColumnPoint, linearUnit, angularUnit, GeodeticCurveType.GEODESIC);
final double calculatedDistance = geodeticDistanceResult.getDistance();
waterColumn.setDistanceFrom(calculatedDistance);
waterColumnList.add(waterColumn);
}
// Sort water columns
Collections.sort(waterColumnList);
closestWaterColumn = waterColumnList.get(0);
}
return closestWaterColumn;
}
示例6: deriveScreenPointForLocation
import com.esri.arcgisruntime.geometry.GeometryEngine; //导入依赖的package包/类
private android.graphics.Point deriveScreenPointForLocation(Point location){
MapView mapView = (MapView) solo.getView(R.id.map) ;
DisplayMetrics metrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);;
float screenHeight = metrics.heightPixels;
float mapViewHeight = mapView.getHeight();
float buffer = screenHeight - mapViewHeight;
Point projectedPoint = (Point) GeometryEngine.project(location, SpatialReference.create(3857));
android.graphics.Point derivedPoint = mapView.locationToScreen(projectedPoint);
return new android.graphics.Point(derivedPoint.x,derivedPoint.y+Math.round(buffer));
}
示例7: setBearingAndDistanceForPlace
import com.esri.arcgisruntime.geometry.GeometryEngine; //导入依赖的package包/类
private final void setBearingAndDistanceForPlace(final Place place){
String bearing = null;
if ((mCurrentLocation != null) && (place.getLocation() != null)){
final LinearUnit linearUnit = new LinearUnit(LinearUnitId.METERS);
final AngularUnit angularUnit = new AngularUnit(AngularUnitId.DEGREES);
final Point newPoint = new Point(mCurrentLocation.getX(), mCurrentLocation.getY(), place.getLocation().getSpatialReference() );
final GeodeticDistanceResult result =GeometryEngine.distanceGeodetic(newPoint, place.getLocation(),linearUnit, angularUnit, GeodeticCurveType.GEODESIC);
final double distance = result.getDistance();
place.setDistance(Math.round(distance));
final double degrees = result.getAzimuth1();
if ((degrees > -22.5) && (degrees <= 22.5)){
bearing = "N";
}else if ((degrees > 22.5) && (degrees <= 67.5)){
bearing = "NE";
}else if ((degrees > 67.5) && (degrees <= 112.5)){
bearing = "E";
}else if ((degrees > 112.5) && (degrees <= 157.5)){
bearing = "SE";
}else if( degrees > 157.5 || degrees <= -157.5){
bearing = "S";
}else if ((degrees > -157.5) && (degrees <= -112.5)){
bearing = "SW";
}else if ((degrees > -112.5) && (degrees <= -67.5)){
bearing = "W";
}else if ((degrees > -67.5) && (degrees <= -22.5)){
bearing = "NW";
}
if (bearing==null){
Log.i(TAG, "Can't find bearing for " + degrees);
}
}
place.setBearing(bearing);
}
示例8: onOptionsItemSelected
import com.esri.arcgisruntime.geometry.GeometryEngine; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// handle menu item selection
int itemId = item.getItemId();
// clear previous operation result
resultGeometryOverlay.getGraphics().clear();
// perform spatial operations and add results as graphics, depending on the option selected
// if-else is used because this sample is used elsewhere as a Library module
if (itemId == R.id.action_no_operation) {
// no spatial operation - graphics have been cleared previously
noOperationMenuItem.setChecked(true);
return true;
}
else if (itemId == R.id.action_intersection) {
intersectionMenuItem.setChecked(true);
showGeometry(GeometryEngine.intersection(inputPolygon1, inputPolygon2));
return true;
}
else if (itemId == R.id.action_union) {
unionMenuItem.setChecked(true);
showGeometry(GeometryEngine.union(inputPolygon1, inputPolygon2));
return true;
}
else if (itemId == R.id.action_difference) {
differenceMenuItem.setChecked(true);
// note that the difference method gives different results depending on the order of input geometries
showGeometry(GeometryEngine.difference(inputPolygon1, inputPolygon2));
return true;
}
else if (itemId == R.id.action_symmetric_difference) {
symmetricDifferenceMenuItem.setChecked(true);
showGeometry(GeometryEngine.symmetricDifference(inputPolygon1, inputPolygon2));
return true;
}
else {
return super.onOptionsItemSelected(item);
}
}
示例9: onNavigationItemSelected
import com.esri.arcgisruntime.geometry.GeometryEngine; //导入依赖的package包/类
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
Viewpoint selectedViewpoint = null;
if (id == R.id.nav_world_location1) {
selectedViewpoint = mViewpoint1;
} else if (id == R.id.nav_world_location2) {
selectedViewpoint = mViewpoint2;
} else if (id == R.id.nav_world_location3) {
selectedViewpoint = mViewpoint3;
} else if (id == R.id.nav_world_location4) {
selectedViewpoint = mViewpoint4;
}
// If new target already inside the current extent, then zoom directly to it.
if (GeometryEngine.intersects(mMapView.getVisibleArea(), selectedViewpoint.getTargetGeometry())) {
jumpZoom(selectedViewpoint, null);
} else {
// If target is outside of current extent, zoom out first to see both extents, then zoom back in.
Geometry union = GeometryEngine.union(mMapView.getVisibleArea().getExtent().getCenter(), selectedViewpoint
.getTargetGeometry());
if ((union != null) && (!union.isEmpty())) {
jumpZoom(new Viewpoint(union.getExtent()), selectedViewpoint);
}
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
示例10: start
import com.esri.arcgisruntime.geometry.GeometryEngine; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
try {
// create stack pane and application scene
StackPane stackPane = new StackPane();
Scene scene = new Scene(stackPane);
// set title, size, and add scene to stage
stage.setTitle("Add Features Sample");
stage.setWidth(800);
stage.setHeight(700);
stage.setScene(scene);
stage.show();
// create a map with streets basemap
ArcGISMap map = new ArcGISMap(Basemap.Type.STREETS, 40, -95, 4);
// create a view for this ArcGISMap
mapView = new MapView();
// create service feature table from URL
featureTable = new ServiceFeatureTable(SERVICE_LAYER_URL);
// create a feature layer from table
FeatureLayer featureLayer = new FeatureLayer(featureTable);
// add the layer to the ArcGISMap
map.getOperationalLayers().add(featureLayer);
mapView.setOnMouseClicked(event -> {
// check that the primary mouse button was clicked
if (event.isStillSincePress() && event.getButton() == MouseButton.PRIMARY) {
// create a point from where the user clicked
Point2D point = new Point2D(event.getX(), event.getY());
// create a map point from a point
Point mapPoint = mapView.screenToLocation(point);
// for a wrapped around map, the point coordinates include the wrapped around value
// for a service in projected coordinate system, this wrapped around value has to be normalized
Point normalizedMapPoint = (Point) GeometryEngine.normalizeCentralMeridian(mapPoint);
// add a new feature to the service feature table
addFeature(normalizedMapPoint, featureTable);
}
});
// set ArcGISMap to be displayed in map view
mapView.setMap(map);
// add the map view to stack pane
stackPane.getChildren().addAll(mapView);
} catch (Exception e) {
// on any error, display the stack trace
e.printStackTrace();
}
}
示例11: onCreate
import com.esri.arcgisruntime.geometry.GeometryEngine; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// inflate MapView from layout
mMapView = (MapView) findViewById(R.id.mapView);
// create a map with the Basemap Type topographic
final ArcGISMap mMap = new ArcGISMap(Basemap.Type.TOPOGRAPHIC, 34.056295, -117.195800, 10);
// set the map to be displayed in this view
mMapView.setMap(mMap);
mMapView.setOnTouchListener(new DefaultMapViewOnTouchListener(this, mMapView) {
@Override
public boolean onSingleTapConfirmed(MotionEvent motionEvent) {
Log.d(sTag, "onSingleTapConfirmed: " + motionEvent.toString());
// get the point that was clicked and convert it to a point in map coordinates
android.graphics.Point screenPoint = new android.graphics.Point(Math.round(motionEvent.getX()),
Math.round(motionEvent.getY()));
// create a map point from screen point
Point mapPoint = mMapView.screenToLocation(screenPoint);
// convert to WGS84 for lat/lon format
Point wgs84Point = (Point) GeometryEngine.project(mapPoint, SpatialReferences.getWgs84());
// create a textview for the callout
TextView calloutContent = new TextView(getApplicationContext());
calloutContent.setTextColor(Color.BLACK);
calloutContent.setSingleLine();
// format coordinates to 4 decimal places
calloutContent.setText("Lat: " + String.format("%.4f", wgs84Point.getY()) +
", Lon: " + String.format("%.4f", wgs84Point.getX()));
// get callout, set content and show
mCallout = mMapView.getCallout();
mCallout.setLocation(mapPoint);
mCallout.setContent(calloutContent);
mCallout.show();
// center on tapped point
mMapView.setViewpointCenterAsync(mapPoint);
return true;
}
});
}
示例12: getBufferPolygonForPoint
import com.esri.arcgisruntime.geometry.GeometryEngine; //导入依赖的package包/类
/**
* Create a polygon representing a buffered region around a
* a given point
* @param point - A geolocation representing the
* place a user clicked on the map
* @param distance - size of the buffer to build around the point
* @return - a polygon representing the buffered region with the point as its center
*/
@Override public Polygon getBufferPolygonForPoint(final Point point, final double distance) {
return GeometryEngine.buffer(point, distance);
}