?? mapservice.java
字號:
package com.esri.aims.mtier.dx;
import java.util.*;
import com.esri.aims.mtier.dx.ConfigService;
import com.esri.aims.mtier.model.acetate.*;
import com.esri.aims.mtier.model.envelope.*;
import com.esri.aims.mtier.model.map.*;
import com.esri.aims.mtier.model.map.layer.*;
import com.esri.aims.mtier.model.map.layer.query.*;
import com.esri.aims.mtier.model.map.layer.renderer.*;
import com.esri.aims.mtier.model.map.layer.renderer.symbol.*;
import com.esri.aims.mtier.model.util.*;
public class MapService extends MapConnection {
//parameter
String activeLayerId = null;
String bufferLayerId = null;
//layer
FeatureLayer flyr = null;
//recordset
HashMap filterMap = null;
HashMap bufferMap = null;
//symbol
static String fillColor = "255,0,0";
static String chartColors[] = {"0,255,0","0,0,255","255,255,0","255,0,255","0,255,255","255,0,0"};
static long chartSize = 10;
SimpleMarkerSymbol markSymbol = null;
SimpleLineSymbol lineSymbol = null;
SimplePolygonSymbol polySymbol = null;
//buffer distance
static final double dis = 1.0e-3;
// join table
boolean isJoin=false;
String orignTableName=null;
String joinTableName=null;
String joinColName=null;
public MapService() {
markSymbol = new SimpleMarkerSymbol();
lineSymbol = new SimpleLineSymbol();
polySymbol = new SimplePolygonSymbol();
filterMap = new HashMap();
bufferMap = new HashMap();
}
/**
* 設置圖例
*/
public void setLegend() {
Legend leg = imsmap.getLegend();
leg.setFont("楷體_GB2312");
leg.setTitle("");
leg.setCellSpacing(2);
leg.setLayerFontSize(16);
leg.setValueFontSize(12);
leg.setAutoExtend(true);
leg.setDisplay(true);
}
/**
* 設置Map顯示范圍
* @param maxX double
* @param maxY double
* @param minX double
* @param minY double
*/
public void setMapExtent(double maxX, double maxY, double minX, double minY) {
if (Math.abs(maxX - minX) >= dis && Math.abs(maxY - minY) > dis) {
if (maxX < minX) {
double tempX = maxX;
maxX = minX;
minX = tempX;
}
if (maxY < minY) {
double tempY = maxY;
maxY = minY;
minY = tempY;
}
imsmap.getEnvelope().setMaxX(maxX);
imsmap.getEnvelope().setMaxY(maxY);
imsmap.getEnvelope().setMinX(minX);
imsmap.getEnvelope().setMinY(minY);
//Envelope env = imsmap.getEnvelope();
//imsmap.doZoomToExtent(env);
}
}
/**
* 設置全圖顯示
*/
public void setMapFullExtent() {
imsmap.doZoomToFullExtent();
}
/**
* 返回Map顯示范圍MaxX
* @return double
*/
public double getMaxX() {
return imsmap.getEnvelope().getMaxX();
}
/**
* 返回Map顯示范圍MaxY
* @return double
*/
public double getMaxY() {
return imsmap.getEnvelope().getMaxY();
}
/**
* 返回Map顯示范圍MinX
* @return double
*/
public double getMinX() {
return imsmap.getEnvelope().getMinX();
}
/**
* 返回Map顯示范圍MinY
* @return double
*/
public double getMinY() {
return imsmap.getEnvelope().getMinY();
}
/**
* 設置Map高寬
* @param width 寬度
* @param height 高度
*/
public void setMapWidthHeight(long width, long height) {
imsmap.setWidth(width);
imsmap.setHeight(height);
}
/**
* 返回Map高度
* @return long
*/
public long getMapWidth() {
return imsmap.getWidth();
}
/**
* 返回Map寬度
* @return long
*/
public long getMapHeight() {
return imsmap.getHeight();
}
/**
* 刷新地圖
*/
public void mapRefresh() {
imsmap.refresh();
ConfigService.setLegendUrl(imsmap.getLegend().getLegendOutput().getURL());
ConfigService.setMapUrl(imsmap.getMapOutput().getURL());
}
/**
* 返回圖例路徑
* @return String
*/
public String getLegendUrl() {
return ConfigService.getLegendUrl();
}
/**
* 返回地圖路徑
* @return String
*/
public String getMapUrl() {
return ConfigService.getMapUrl();
}
/**
* 設置 ActiveFeaturelayer
* @param layerId String
*/
public void setActiveFeatureLayer(String layerId) {
flyr = null;
for (int i = 0; i < getLayerCount(); i++) {
if (imsmap.getLayers().item(i) instanceof FeatureLayer) {
if (imsmap.getLayers().item(i).getID().equalsIgnoreCase(layerId)) {
flyr = (FeatureLayer) imsmap.getLayers().item(i);
activeLayerId = imsmap.getLayers().item(i).getID();
break;
}
}
}
}
/**
* 返回 ActiveFeaturelayerId
* @return String
*/
public String getActiveFeatureLayerId() {
if (activeLayerId == null) {
for (int i = 0; i < getLayerCount(); i++) {
if (imsmap.getLayers().item(i) instanceof FeatureLayer) {
activeLayerId = imsmap.getLayers().item(i).getID();
break;
}
}
}
return activeLayerId;
}
/**
* 設置高亮顯示要素顏色
* @param color 顏色,輸入格式="255,255,255"
*/
public static void setFillColor(String color) {
fillColor = color;
}
/**
* 返回高亮顯示要素顏色
* @return String
*/
public static String getFillColor() {
return fillColor;
}
/**
* 設置高亮顯示要素填充的Symbol
* @param type 圖層類型,輸入類型="point","line","polygon"
*/
protected void setDisplaySymbol(String type) {
if (markSymbol == null) {
markSymbol = new SimpleMarkerSymbol();
}
if (lineSymbol == null) {
lineSymbol = new SimpleLineSymbol();
}
if (polySymbol == null) {
polySymbol = new SimplePolygonSymbol();
}
if (type.equalsIgnoreCase("point")) {
markSymbol.setColor(fillColor);
markSymbol.setOverlap(true);
markSymbol.setWidth(16);
markSymbol.setMarkerType(SimpleMarkerSymbol.STAR);
}
if (type.equalsIgnoreCase("line")) {
lineSymbol.setColor(fillColor);
lineSymbol.setOverlap(true);
lineSymbol.setWidth(2);
lineSymbol.setLineType(SimpleLineSymbol.SOLID);
}
if (type.equalsIgnoreCase("polygon")) {
polySymbol.setBoundary(false);
polySymbol.setOverlap(true);
polySymbol.setFillColor(fillColor);
polySymbol.setFillTransparency(0.6);
polySymbol.setFillType(SimplePolygonSymbol.FDIAGONAL);
}
}
/**
* 查詢的要素集設置顯示范圍
* @param rs Recordset
*/
public void setFilterExtent(Recordset rs) {
if (rs != null && rs.getEnvelopeCount() != 0) {
double tmaxX = rs.getEnvelope(0).getMaxX();
double tmaxY = rs.getEnvelope(0).getMaxY();
double tminX = rs.getEnvelope(0).getMinX();
double tminY = rs.getEnvelope(0).getMinY();
for (int i = 0; i < rs.getEnvelopeCount(); i++) {
if (tmaxX < rs.getEnvelope(i).getMaxX()) {
tmaxX = rs.getEnvelope(i).getMaxX();
}
if (tmaxY < rs.getEnvelope(i).getMaxY()) {
tmaxY = rs.getEnvelope(i).getMaxY();
}
if (tminX > rs.getEnvelope(i).getMinX()) {
tminX = rs.getEnvelope(i).getMinX();
}
if (tminY > rs.getEnvelope(i).getMinY()) {
tminY = rs.getEnvelope(i).getMinY();
}
}
tmaxX = tmaxX +(fullMaxX - fullMinX) / 64;
tmaxY = tmaxY +(fullMaxY - fullMinY) / 64;
tminX = tminX -(fullMaxX - fullMinX) / 64;
tminY = tminY -(fullMaxY - fullMinY) / 64;
System.out.println("tmaxX:" + tmaxX + " tmaxY:" + tmaxY + " tminX:" + tminX + " tminY:" + tminY);
setMapExtent(tmaxX, tmaxY, tminX, tminY);
}
}
/**
* 檢驗 SubField
* @param lyr FeatureLayer
* @param fd String
* @return boolean
*/
protected boolean checkSubField(FeatureLayer lyr,String fd) {
boolean isField = false;
TableDesc td = lyr.getRecordset().getTableDesc();
for (int jj = 0; jj < td.getCount(); jj++) {
if (fd.equalsIgnoreCase(td.getFieldName(jj))) {
isField = true;
break;
}
}
return isField;
}
/**
*
* @param tab TableDesc
* @return String
*/
protected String getFieldTitle(TableDesc tab){
String title="";
for(int t=0;t<tab.getCount();t++){
if(!(tab.getFieldName(t).equalsIgnoreCase("#shape#") || tab.getFieldName(t).equalsIgnoreCase("#id#"))){
title=tab.getFieldName(t);
break;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -