📄 statelessmapimagebean.java
字号:
private void initMap(String mapServerHost, String mapServerName, String mapDescription, String imageDescription) throws Exception{
try{
initializeMapBean();
if(this.m_arcServerHostName.length() > 0 && this.m_mapServerName.length() > 0){
connectServer(m_arcServerHostName, m_mapServerName, mapDescription, imageDescription);
}
else{
connectServer(mapServerHost, mapServerName, mapDescription, imageDescription);
}
com.esri.arcgis.carto.IMapServerObjects mapServerObjects = new com.esri.arcgis.carto.IMapServerObjectsProxy(m_mapServer);
if(m_mapDescription.getCustomGraphics() != null){
m_graphicElements = m_mapDescription.getCustomGraphics();
}
else{
m_graphicElements = new com.esri.arcgis.carto.IGraphicElementsProxy(m_serverContext.createObject("esricarto.GraphicElements"));
}
m_mapServerInfo = new com.esri.arcgis.carto.IMapServerInfoProxy(m_mapServer.getServerInfo(m_mapServer.getDefaultMapName()));
m_imageType = new com.esri.arcgis.carto.IImageTypeProxy(m_imageDescription.getType());
m_imageDisplay = new com.esri.arcgis.carto.IImageDisplayProxy(m_imageDescription.getDisplay());
m_mapDescriptionString = m_serverContext.saveObject(m_mapDescription);
m_imageDescriptionString = m_serverContext.saveObject(m_imageDescription);
releaseResources();
}
catch(Exception msce){
throw new Exception("Error in initMap: " + msce.getMessage());
}
}
public java.util.Hashtable zoomMap(String mapServerHost, String mapServerName, String mapDescription, String imageDescription, int pixelX, int pixelY, double factor) throws Exception{
try{
this.initMap(mapServerHost, mapServerName, mapDescription, imageDescription);
com.esri.arcgis.system.ILongArray longArrayX = new com.esri.arcgis.system.ILongArrayProxy(m_serverContext.createObject("esrisystem.LongArray"));
longArrayX.add(pixelX);
com.esri.arcgis.system.ILongArray longArrayY = new com.esri.arcgis.system.ILongArrayProxy(m_serverContext.createObject("esrisystem.LongArray"));
longArrayY.add(pixelY);
com.esri.arcgis.geometry.IPointCollection points =
m_mapServer.toMapPoints(m_mapDescription, m_imageDisplay, longArrayX, longArrayY);
IPoint point = points.getPoint(0);
IEnvelope env = m_mapDescription.getMapArea().getExtent();
env.centerAt(point);
env.expand(factor,factor,true);
com.esri.arcgis.carto.IMapExtent mapExtent = new
com.esri.arcgis.carto.IMapExtentProxy(m_serverContext.createObject("esricarto.MapExtent"));
mapExtent.setExtent(env);
com.esri.arcgis.carto.IMapArea mapArea = new com.esri.arcgis.carto.IMapAreaProxy(mapExtent);
m_mapDescription.setMapArea(mapArea);
java.util.Hashtable hTable = new java.util.Hashtable(3);
m_mapImage = m_mapServer.exportMapImage(m_mapDescription, m_imageDescription);
hTable.put("MAPURL", m_mapImage.getURL());
m_mapDescriptionString = m_serverContext.saveObject(m_mapDescription);
m_imageDescriptionString = m_serverContext.saveObject(m_imageDescription);
hTable.put("MAPDESCRIPTION", m_mapDescriptionString);
hTable.put("IMAGEDESCRIPTION", m_imageDescriptionString);
com.esri.arcgis.geometry.IEnvelope currentExtent = m_mapDescription.getMapArea().getExtent();
com.esri.arcgis.samples.ejb.value.Envelope envelope = new com.esri.arcgis.samples.ejb.value.Envelope();
envelope.setMinX(currentExtent.getXMin());
envelope.setMaxX(currentExtent.getXMax());
envelope.setMinY(currentExtent.getYMin());
envelope.setMaxY(currentExtent.getYMax());
hTable.put("EXTENT", envelope);
return hTable;
}
catch(Exception exception){
throw new Exception("Error in zoomMap: " + exception.getMessage());
}
}
private void releaseResources(){
try {
m_serverContext.removeAll();
m_serverContext.releaseContext();
}
catch (Exception ex) {
System.out.println("Error releaseing Context: "+ex.getMessage());
}
}
private void initializeMapBean(){
javax.naming.Context initialContext, paramEnv;
try{
initialContext = new javax.naming.InitialContext();
paramEnv = (javax.naming.Context)initialContext.lookup("java:comp/env");
this.m_arcServerHostName = (String)paramEnv.lookup("ArcServerHostName");
this.m_arcServerHostDomain = (String)paramEnv.lookup("ArcServerDomainName");
this.m_arcServerHostUserName = (String)paramEnv.lookup("ArcServerHostUserName");
this.m_arcServerHostPassword = (String)paramEnv.lookup("ArcServerHostPassword");
this.m_mapServerName = (String)paramEnv.lookup("MapServerName");
XAResource xaResource = new XAResource();
LocalTransaction localTransaction = new LocalTransaction();
m_connectionRequestInfo = new com.intrinsyc.jca.JintConnectionRequestInfo(
m_arcServerHostName, this.m_arcServerHostDomain, this.m_arcServerHostUserName, this.m_arcServerHostPassword,
"", xaResource, localTransaction);
m_connectionFactory = (com.intrinsyc.jca.ConnectionFactory)initialContext.lookup("intrinsycjca");
}catch(Exception exception){
m_connectionFactory = null;
System.out.println("JCA Lookup Failed: " + exception);
}
try{
m_connection = (com.intrinsyc.jca.Connection)m_connectionFactory.getConnection(m_connectionRequestInfo);
java.util.Vector params = new java.util.Vector();
params.add(m_arcServerHostName);
if(m_connection != null){
m_serverConnectionObject = m_connection.getObject("com.esri.arcgis.server.ServerConnection",
params, this.m_arcServerHostDomain, this.m_arcServerHostUserName, this.m_arcServerHostPassword);
if((m_serverConnectionObject != null) && (m_serverConnectionObject instanceof com.esri.arcgis.server.ServerConnection)){
com.esri.arcgis.system.ServerInitializer serverInitializer = new com.esri.arcgis.system.ServerInitializer();
serverInitializer.setDefault(this.m_arcServerHostDomain, this.m_arcServerHostUserName, this.m_arcServerHostPassword);
serverInitializer.trackObjectsInCurrentThread();
m_serverConnection = (com.esri.arcgis.server.ServerConnection)m_serverConnectionObject;
}
}
}
catch(Exception exception){
System.out.println("MapBean inialization failed: " + exception.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -