本文整理汇总了Java中com.esri.core.geometry.GeometryEngine.buffer方法的典型用法代码示例。如果您正苦于以下问题:Java GeometryEngine.buffer方法的具体用法?Java GeometryEngine.buffer怎么用?Java GeometryEngine.buffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.esri.core.geometry.GeometryEngine
的用法示例。
在下文中一共展示了GeometryEngine.buffer方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: constructBuffer
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
private com.esri.ges.spatial.Geometry constructBuffer(double x, double y, double radius, String units, int wkidin, int wkidbuffer, int wkidout) throws GeometryException
{
Point center = new Point();
center.setX(x);
center.setY(y);
SpatialReference srIn = SpatialReference.create(wkidin);
SpatialReference srBuffer = SpatialReference.create(wkidbuffer);
SpatialReference srOut = SpatialReference.create(wkidout);
UnitConverter uc = new UnitConverter();
String c_name = uc.findConnonicalName(units);
int unitout = uc.findWkid(c_name);
Unit u = new LinearUnit(unitout);
Point centerProj = (Point) GeometryEngine.project(center, srIn, srBuffer);
Geometry buffer = GeometryEngine.buffer(centerProj, srBuffer, radius, u);
Geometry bufferout = GeometryEngine.project(buffer, srBuffer, srOut);
String json = GeometryEngine.geometryToJson(srOut, bufferout);
return spatial.fromJson(json);
}
示例2: constructBuffer
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
private Geometry constructBuffer(double x, double y,
double radius, String units, int wkidin, int wkidbuffer, int wkidout)
{
Point center = new Point();
center.setX(x);
center.setY(y);
SpatialReference srIn = SpatialReference.create(wkidin);
SpatialReference srBuffer = SpatialReference.create(wkidbuffer);
SpatialReference srOut = SpatialReference.create(wkidout);
UnitConverter uc = new UnitConverter();
String c_name = uc.findConnonicalName(units);
int unitout = uc.findWkid(c_name);
Unit u = LinearUnit.create(unitout);
Point centerProj = (Point) GeometryEngine.project(center, srIn,
srBuffer);
Geometry buffer = GeometryEngine
.buffer(centerProj, srBuffer, radius, u);
Geometry bufferout = GeometryEngine.project(buffer, srBuffer, srOut);
//String json = GeometryEngine.geometryToJson(srOut, bufferout);
return bufferout;
}
示例3: bufferLine
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
/**
* Create a buffer for a line.
* @param lineJsonString A JSON string defining the line.
* @param distance The buffer distance.
* @return A JSON string with the buffer polygon.
*/
public static String bufferLine(String lineJsonString, double distance){
String geoJson = null;
try{
Polyline polyline = new Polyline();
JSONObject lineJson = new JSONObject(lineJsonString);
JSONArray paths = lineJson.getJSONArray("paths");
JSONArray line = paths.getJSONArray(0);
for(int k = 0; k < line.length(); k++){
JSONArray point = line.getJSONArray(k);
double x = point.getDouble(0);
double y = point.getDouble(1);
if(k == 0){
polyline.startPath(x, y);
}else{
polyline.lineTo(x, y);
}
}
SpatialReference srsWGS84 = SpatialReference.create(SpatialReference.WKID_WGS84);
SpatialReference srsWebMercator = SpatialReference.create(SpatialReference.WKID_WGS84_WEB_MERCATOR);
Geometry mercatorPolyline = GeometryEngine.project(polyline, srsWGS84, srsWebMercator);
Polygon mercatorPolygon = GeometryEngine.buffer(mercatorPolyline, srsWebMercator, distance, srsWebMercator.getUnit());
Polygon polygon = (Polygon) GeometryEngine.project(mercatorPolygon, srsWebMercator, srsWGS84);
geoJson = GeometryEngine.geometryToJson(srsWGS84, polygon);
}catch(Exception e){
log.error("Error creating line buffer: "+e.getMessage());
}
return geoJson;
}
示例4: highlightGeometry
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
private void highlightGeometry(Point point) {
if (point == null) {
return;
}
graphicsLayer.removeAll();
graphicsLayer.addGraphic(
new Graphic(point, new SimpleMarkerSymbol(Color.CYAN, 20, SimpleMarkerSymbol.Style.CIRCLE)));
// -----------------------------------------------------------------------------------------
// Zoom to the highlighted graphic
// -----------------------------------------------------------------------------------------
Geometry geometryForZoom = GeometryEngine.buffer(
point,
map.getSpatialReference(),
map.getFullExtent().getWidth() * 0.10,
map.getSpatialReference().getUnit());
map.zoomTo(geometryForZoom);
}
示例5: constructBuffer
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
private com.esri.ges.spatial.Geometry constructBuffer(Geometry geo, double radius, Unit u) throws GeometryException, JsonParseException, IOException
{
com.esri.core.geometry.Geometry buffer = GeometryEngine.buffer(inGeometry, srBuffer, radius, u);
com.esri.core.geometry.Geometry bufferout = GeometryEngine.project(buffer, srBuffer, srOut);
String json = GeometryEngine.geometryToJson(srOut, bufferout);
return spatial.fromJson(json);
}
示例6: constructBuffer
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
private MapGeometry constructBuffer(Geometry geo, double radius, Unit u) throws JsonParseException, IOException
{
Polygon buffer = GeometryEngine.buffer(inGeometry, srBuffer, radius, u);
Geometry bufferout = GeometryEngine.project(buffer, srBuffer, srOut);
MapGeometry mapGeo = new MapGeometry(bufferout, srOut);
return mapGeo;
//String json = GeometryEngine.geometryToJson(srOut, bufferout);
//return spatial.fromJson(json);
}
示例7: constructBuffer
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
private MapGeometry constructBuffer(Geometry geo, double radius, Unit u)
throws JsonParseException, IOException {
Polygon buffer = GeometryEngine.buffer(inGeometry, srBuffer, radius, u);
Geometry bufferout = GeometryEngine.project(buffer, srBuffer, srOut);
MapGeometry mapGeo = new MapGeometry(bufferout, srOut);
return mapGeo;
}
示例8: showViewshedBoundsGraphic
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
/**
* Displays a temporary graphic on the map representing the bounds of the viewshed
* that will be calculated if the given points are used.
* @param viewshedCenter the center of the proposed viewshed (i.e. the observer).
* @param radius the radius of the proposed viewshed.
* @see #showViewshedBoundsGraphic(com.esri.core.geometry.Point, com.esri.core.geometry.Point)
* @see #removeViewshedBoundsGraphic()
*/
public void showViewshedBoundsGraphic(Point viewshedCenter, double radius) {
Polygon buffer = GeometryEngine.buffer(
viewshedCenter,
mapController.getSpatialReference(),
radius,
mapController.getSpatialReference().getUnit());
if (0 > viewshedBoundsGraphicId) {
viewshedBoundsGraphicId = addGraphic(
new Graphic(buffer, VIEWSHED_BOUNDS_SYMBOL));
} else {
updateGraphic(viewshedBoundsGraphicId, buffer);
}
}
示例9: onMouseClicked
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
@Override
public void onMouseClicked(MouseEvent event) {
graphicsLayer.removeAll();
// add buffer as a graphic
Point mapPoint = map.toMapPoint(event.getX(), event.getY());
final Geometry buffer = GeometryEngine.buffer(
mapPoint, map.getSpatialReference(), 200000, map.getSpatialReference().getUnit());
graphicsLayer.addGraphic(new Graphic(buffer, new SimpleFillSymbol(new Color(255, 0, 0, 255))));
// get states at the buffered area
QueryTask queryTask = new QueryTask(featureLayer.getUrl());
QueryParameters queryParams = new QueryParameters();
queryParams.setInSpatialReference(map.getSpatialReference());
queryParams.setOutSpatialReference(map.getSpatialReference());
queryParams.setGeometry(buffer);
queryParams.setReturnGeometry(true);
queryParams.setOutFields(new String[] {"STATE_NAME"});
queryTask.execute(queryParams, new CallbackListener<FeatureResult>() {
@Override
public void onError(Throwable arg0) {
// deal with any exception
}
@Override
public void onCallback(FeatureResult result) {
for (Object objFeature : result) {
Feature feature = (Feature) objFeature;
graphicsLayer.addGraphic(new Graphic(feature.getGeometry(), stateSymbol));
graphicsLayer.addGraphic(new Graphic(buffer, new SimpleFillSymbol(new Color(255, 0, 0, 255))));
}
}
});
}
示例10: onMouseClicked
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
@Override
public void onMouseClicked(MouseEvent e) {
Point pt = map.toMapPoint(e.getX(), e.getY());
Geometry buffer = GeometryEngine.buffer(pt, map.getSpatialReference(), 200000, map.getSpatialReference().getUnit());
Graphic g = new Graphic(buffer, bufferSymbol);
graphicsLayer.addGraphic(g);
}
示例11: onMouseClicked
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
@Override
public void onMouseClicked(MouseEvent event) {
graphicsLayer.removeAll();
// add buffer as a graphic
Point mapPoint = map.toMapPoint(event.getX(), event.getY());
Geometry buffer = GeometryEngine.buffer(
mapPoint, map.getSpatialReference(), 200000, map.getSpatialReference().getUnit());
graphicsLayer.addGraphic(new Graphic(buffer, new SimpleFillSymbol(new Color(100, 0, 0, 80))));
// get states at the buffered area
QueryTask queryTask = new QueryTask(featureLayer.getUrl());
QueryParameters queryParams = new QueryParameters();
queryParams.setInSpatialReference(map.getSpatialReference());
queryParams.setOutSpatialReference(map.getSpatialReference());
queryParams.setGeometry(buffer);
queryParams.setReturnGeometry(true);
queryParams.setOutFields(new String[] {"STATE_NAME"});
queryTask.executeAsync(queryParams, new CallbackListener<FeatureResult>() {
@Override
public void onError(Throwable arg0) {
// deal with any exception
}
@Override
public void onCallback(FeatureResult result) {
for (Object objFeature : result) {
Feature feature = (Feature) objFeature;
graphicsLayer.addGraphic(new Graphic(feature.getGeometry(), stateSymbol));
}
}
});
}
示例12: ST_Buffer
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
/** Computes a buffer around {@code geom}. */
public static Geom ST_Buffer(Geom geom, double distance) {
final Polygon g = GeometryEngine.buffer(geom.g(), geom.sr(), distance);
return geom.wrap(g);
}
示例13: onMouseMoved
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
/**
* Handle mouse-clicks.
* On left-click - draws either a polyline or a point.
* On right-click - computes and draws the buffer of the polyline or point.
*/
@Override
public void onMouseMoved(MouseEvent event) {
super.onMouseMoved(event);
gLayer.removeAll();
Point currPoint = jMap.toMapPoint(event.getX(), event.getY());
// point
bufferedArea = GeometryEngine.buffer(
currPoint,
jMap.getSpatialReference(),
BUFFER_DISTANCE,
jMap.getSpatialReference().getUnit());
Graphic currPointGraphic = new Graphic(currPoint, GeometryOfflineApp.SYM_POINT);
gLayer.addGraphic(currPointGraphic);
// add the buffered area to the graphics layer
Graphic bufferedGraphic = new Graphic(bufferedArea, GeometryOfflineApp.SYM_BUFFER);
gLayer.addGraphic(bufferedGraphic);
if (queryInProgress.get() == false) {
// query
QueryParameters query = new QueryParameters();
query.setReturnGeometry(true);
query.setGeometry(bufferedArea);
query.setOutFields(new String[] {"STATE_NAME"});
// execute the query.
table.queryFeatures(query, new CallbackListener<FeatureResult>() {
@Override
public void onError(Throwable e) {
e.printStackTrace();
}
@Override
public void onCallback(FeatureResult result) {
gLayerResults.removeAll();
for (Object objFeature : result) {
Feature feature = (Feature) objFeature;
gLayerResults.addGraphic(new Graphic(feature.getGeometry(), SYM_BUFFER));
}
queryInProgress.set(false);
}
});
queryInProgress.set(true);
}
prevPoint = null;
polyLine.setEmpty();
return;
}
示例14: onMouseMoved
import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
/**
* Handle mouse-clicks.
* On left-click - draws either a polyline or a point.
* On right-click - computes and draws the buffer of the polyline or point.
*/
@Override
public void onMouseMoved(MouseEvent event) {
super.onMouseMoved(event);
gLayer.removeAll();
Point currPoint = jMap.toMapPoint(event.getX(), event.getY());
// point
bufferedArea = GeometryEngine.buffer(
currPoint,
jMap.getSpatialReference(),
BUFFER_DISTANCE,
jMap.getSpatialReference().getUnit());
Graphic currPointGraphic = new Graphic(currPoint, GeometryApp.SYM_POINT);
gLayer.addGraphic(currPointGraphic);
// add the buffered area to the graphics layer
Graphic bufferedGraphic = new Graphic(bufferedArea, GeometryApp.SYM_BUFFER);
gLayer.addGraphic(bufferedGraphic);
if (queryInProgress.get() == false) {
// query
QueryParameters query = new QueryParameters();
query.setReturnGeometry(true);
query.setGeometry(bufferedArea);
query.setOutFields(new String[] {"STATE_NAME"});
// execute the query.
table.queryFeatures(query, new CallbackListener<FeatureResult>() {
@Override
public void onError(Throwable e) {
e.printStackTrace();
}
@Override
public void onCallback(FeatureResult result) {
gLayerResults.removeAll();
for (Object objFeature : result) {
Feature feature = (Feature) objFeature;
gLayerResults.addGraphic(new Graphic(feature.getGeometry(), SYM_BUFFER));
}
queryInProgress.set(false);
}
});
queryInProgress.set(true);
}
prevPoint = null;
polyLine.setEmpty();
return;
}