📄 selectbypointbuffertask.java
字号:
this.targetLayerParam = targetLayerParam;
}
/**
* Get display attribute
*/
public String getDisplayAttribute() {
return this.displayAttribute;
}
/**
* Set display attribute
*/
public void setDisplayAttribute(String displayAttribute) {
this.displayAttribute = displayAttribute;
}
/**
* Get unit parameter
*/
public String getUnitParam() {
return this.unitParam;
}
/**
* Set unit parameter
*/
public void setUnitParam(String unitParam) {
this.unitParam = unitParam;
}
/**
* Get unit
*/
public Integer getUnit() {
return this.unit;
}
/**
* Set unit
*/
public void setUnit(Integer unit) {
this.unit = unit;
}
/**
* Get distance
*/
public String getDistance() {
return this.distance;
}
/**
* Set distance
*/
public void setDistance(String distance) {
this.distance = distance;
}
/**
* Get input layer list
*/
public Map<String, String> getInputLayerList() {
return this.layerList;
}
/**
* Get unit list
*/
public Map<Integer, String> getUnitList() {
this.unitList = GeomUtil.getUnitList();
return this.unitList;
}
/**
* Update list event
*/
public void updateList(TaskEvent event) {
_logger.info("Updating layer list");
requestTaskRender();
this.layerList = new LayerList(this._context);
}
/**
* Adds the buffer graphic and origin point to the query graphics layer
* @param webQuery
* @param pointBufferOrigin
* @param geoBuffer
*/
protected void renderBuffer(WebGraphics webGraphics,
WebPoint pointBufferOrigin, WebGeometry geoBuffer) {
//If the buffer is distance is great than 0
if (geoBuffer != null) {
//Set buffer symbol
_logger.debug("Adding buffer to WebQuery graphics");
WebSimplePolygonSymbol pSymbol = new WebSimplePolygonSymbol();
pSymbol.setFillColor(FILL_COLOR);
pSymbol.setFillTransparency(TRANSPARENCY_FACTOR);
pSymbol.setBoundaryColor(FILL_COLOR);
//Element added to graphics layer
GraphicElement graphicElem = new GraphicElement();
graphicElem.setGeometry(geoBuffer);
graphicElem.setSymbol(pSymbol);
webGraphics.addGraphics(graphicElem);
}
//Set buffer origin symbol
_logger.debug("Adding buffer origin to WebQuery graphics");
WebSimpleMarkerSymbol pmSymbol = new WebSimpleMarkerSymbol();
pmSymbol.setColor(POINT_COLOR);
pmSymbol.setMarkerType(WebSimpleMarkerSymbol.CROSS);
pmSymbol.setWidth(5);
//Add point to graphics layer
GraphicElement graphicElem = new GraphicElement();
graphicElem.setGeometry(pointBufferOrigin);
graphicElem.setSymbol(pmSymbol);
webGraphics.addGraphics(graphicElem);
}
/**
* Select point event
*/
public void selectPoint(MapEvent event) {
try {
_logger.info("Selecting point location for buffer");
super.requestTaskRender();
String layer = this.getLayer();
String[] layerInfo = layer.split("!");
//Get Web Objects
WebContext webContext = event.getWebContext();
WebGraphics webGraphics = webContext.getWebGraphics();
WebResults webResults = webContext.getWebResults();
WebQuery webQuery = (WebQuery) webContext.getWebQuery();
WebMap webMap = webContext.getWebMap();
WebGeometry webGeo = event.getWebGeometry();
//Get buffer origin
WebPoint geoOrigin = (WebPoint) webGeo.toMapGeometry(webMap);
_logger.debug("Clearing graphics layer");
if ((_highlighter == null) || _highlighter.getClearPreviousResults()) {
_context.getWebGraphics().clearGraphics();
}
//Get distance
double dDistance = 0;
if ((getDistance() != null) && (getDistance().length() > 0)) {
dDistance = Double.parseDouble(getDistance());
}
String session_id = ADFDownloadServlet.generateId();
LinkedHashMap<String, GISResource> resources = (LinkedHashMap<String, GISResource>) this._context.getResources();
String id = layerInfo[0];
Object resource = resources.get(id);
String layerName = "";
String lyrId = layerInfo[1];
//Calculating buffer
GISResource gisResource = (GISResource) resource;
IServerContextFactory ipSvrCtxFact = this.getServerContextFactor();
IBufferCalculator bufferCalculator = BufferCalculatorFactory.createInstance(gisResource, ipSvrCtxFact);
int iUnits = getUnit().intValue();
WebGeometry geoBuffer = null;
//Calculate and render buffer (exception can be thrown here)
geoBuffer = bufferCalculator.calculateBuffer(geoOrigin, dDistance, iUnits);
renderBuffer(webGraphics, geoOrigin, geoBuffer);
List<QueryResult> searchResults = null;
if (resource instanceof AIMSMapResource) {
// ADF Bug, it can't do the Identify with the WebPolygon. Below uses AIMS API to perform the query
AIMSMapResource aimsMapResource = (AIMSMapResource) resource;
AIMSMapFunctionality aimsMapFunc = (AIMSMapFunctionality) (aimsMapResource).getFunctionality("map");
Layer aimsLayer = aimsMapFunc.getLayer(lyrId);
layerName = aimsLayer.getName();
if (dDistance > 0) {
AimsBufferUtil bufUtil = new AimsBufferUtil();
String aimsWhereClause = bufUtil.doBuffer(session_id, aimsMapResource, aimsMapFunc, lyrId, (WebPolygon) geoBuffer);
bufUtil = null;
PredefinedQueryCriteria pqc = new PredefinedQueryCriteria();
pqc.setWhereClause(aimsWhereClause);
searchResults = webQuery.query(pqc, WebLayerInfoUtil.getWebLayerInfoList(webQuery.getQueryLayers(), gisResource, layerName));
} else {
IdentifyCriteria iqc = new IdentifyCriteria(geoBuffer);
searchResults = webQuery.query(iqc, WebLayerInfoUtil.getWebLayerInfoList(webQuery.getQueryLayers(), gisResource, layerName));
}
} else {
//Get the layer info for the desired service
List<WebLayerInfo> lstWebLayerInfos = webQuery.getQueryLayers();
List<WebLayerInfo> lstQueryLayers = WebLayerInfoUtil.getWebLayerInfoList(lstWebLayerInfos, gisResource, layerInfo[1]);
//Query the service
if (lstQueryLayers != null) {
IdentifyCriteria iqc = new IdentifyCriteria(geoBuffer);
searchResults = webQuery.query(iqc, lstQueryLayers);
}
}
if((searchResults != null)) {
_logger.debug("Selecting query results");
this.highlightResults(searchResults);
_logger.debug("Adding point buffer results to WebResults");
webResults.addResultsWithActionMap("Point Buffer Task", searchResults, "getName", "getDetails", _actions, "clearGraphic");
}
_logger.debug("Refreshing web context");
this._context.refresh();
} catch (Exception e) {
renderResourceMessage("pointbuffertask.msg.error.couldNotPerformBuffer");
_logger.error("Could not perform buffer query", e);
}
}
/**
* Clear buffer event
*/
public void clearBuffer(TaskEvent event) {
try {
_logger.info("Clearing buffer graphics");
super.requestTaskRender();
this._context.getWebGraphics().clearGraphics();
this._context.getWebQuery().clearGraphics();
this.currentHighlighted = null;
} catch (Exception e) {
renderExceptionMessage(e);
_logger.error("Unable to clear buffer", e);
}
}
/**
* Get current highlighted feature
*/
public QueryResult getCurrentHighlighted() {
return currentHighlighted;
}
/**
* Set current highlighted feature
*/
public void setCurrentHighlighted(QueryResult currentHighlighted) {
this.currentHighlighted = currentHighlighted;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -