• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GeometryEngine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;
  }

}
 
开发者ID:Esri,项目名称:nearby-android,代码行数:24,代码来源:LocationService.java


示例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;
    }
  }
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:26,代码来源:ViewshedGeoElementSample.java


示例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);
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:23,代码来源:MainActivity.java


示例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));

}
 
开发者ID:Esri,项目名称:mapbook-android,代码行数:15,代码来源:MapbookTest.java


示例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;
}
 
开发者ID:Esri,项目名称:ecological-marine-unit-android,代码行数:38,代码来源:DataManager.java


示例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));

}
 
开发者ID:Esri,项目名称:ecological-marine-unit-android,代码行数:15,代码来源:EMUAppTest.java


示例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);
}
 
开发者ID:Esri,项目名称:nearby-android,代码行数:35,代码来源:LocationService.java


示例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);
  }
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:41,代码来源:MainActivity.java


示例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;
}
 
开发者ID:Esri,项目名称:arcgis-runtime-demos-android,代码行数:33,代码来源:MainActivity.java


示例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();
  }
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-java,代码行数:60,代码来源:AddFeaturesSample.java


示例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;
        }
    });
}
 
开发者ID:Esri,项目名称:arcgis-runtime-samples-android,代码行数:47,代码来源:MainActivity.java


示例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);
}
 
开发者ID:Esri,项目名称:ecological-marine-unit-android,代码行数:12,代码来源:MapPresenter.java



注:本文中的com.esri.arcgisruntime.geometry.GeometryEngine类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ActiveDescriptor类代码示例发布时间:2022-05-22
下一篇:
Java FloatDocValues类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap