为什么10.2里面没有pagelayout的代码了。。
10.2版本的arcobjects for java sdk自带例子
10.0版本的arcobjects for java sdk自带例子
IMapServerLayout......这个类还是在的
原文:https://www.cnblogs.com/ayanmw/archive/2012/06/06/2538783.html
https://blog.csdn.net/weixin_33831196/article/details/86108606
在src/arcgissample.soe包下 有 PageLayoutImpl.java 和 PageLayoutSOE.java
其中还有一个 rest 的java客户端,这个是单独运行的,和上面两个没啥关系。上面两个文件发布成 jar文件,放到java/lib/ext文件夹下面后部署SOE成功,并且添加到地图服务的 功能 上就可以使用了。比如http://localhost:8399/arcgis/rest/services/portland/MapServer/exts/PageLayoutSOE就是portland的地图服务下面的扩展功能 SOE 是 PageLayoutSOE 了。其实这个SOE可以放到任何一个地图服务的扩展功能当中。
arcgis自带的eclipse无法打开。。。从网上自己下的eclipse3.3,具体的安装和导入arcobjects:链接
PageLayoutImpl.java-核心函数
/* Copyright 2010 ESRI * * All rights reserved under the copyright laws of the United States * and applicable international laws, treaties, and conventions. * */
PageLayoutSOE.java
/* Copyright 2010 ESRI * * All rights reserved under the copyright laws of the United States * and applicable international laws, treaties, and conventions. */
PageLayoutRESTClient.java
其实核心函数只有100行不到
public void generatePageLayout() throws Exception { try { mapName = serverObject.getDefaultMapName(); map = serverObject.getMap(mapName); activeView = coerce(map); serverObjects = coerce(serverObject); pageLayout = coerce(serverObjects.getPageLayout()); pageActiveView = coerce(pageLayout); IGraphicsContainer graphicsContainer = coerce(pageLayout); graphicsContainer.reset(); IFrameElement frameElement = graphicsContainer.findFrame(map); IMapFrame mapFrame = coerce(frameElement); //create a legend IUID uid = coerce(new UID()); uid.setValue(Legend.getClsid()); IMapSurroundFrame legendFrame = mapFrame.createSurroundFrame(uid, null); legendFrame.getMapSurround().setName("Map Legend"); IElement legendElement = coerce(legendFrame); legendElement.activate(pageActiveView.getScreenDisplay()); ILegend legend = coerce(legendFrame.getMapSurround()); legend.setTitle("Map Legend."); legend.setAutoAdd(true); legend.refresh(); IElement mapElement = coerce(mapFrame); IEnvelope mainEnvelope = mapElement.getGeometry().getEnvelope(); IEnvelope elementEnvelope = coerce(new Envelope()); double xmin = mainEnvelope.getXMax() + 2; double ymin = mainEnvelope.getYMin() + 0.5; double xmax = mainEnvelope.getXMax() - 2; double ymax = mainEnvelope.getYMax() - 0.5; elementEnvelope.putCoords(xmin, ymin, xmax, ymax); legendElement.setGeometry((IGeometry)elementEnvelope); //add it to the graphicsContainer. graphicsContainer.addElement(legendElement, 0); //add a North Arrow IUID uidNorth = coerce(new UID()); uidNorth.setValue(MarkerNorthArrow.getClsid()); IEnvelope northArrowEnvelope = coerce(new Envelope()); northArrowEnvelope.putCoords(xmin , ymax - 0.5, xmin + 2, ymax + 1); IMapSurroundFrame northArrowFrame = mapFrame.createSurroundFrame(uidNorth, null); IElement northElement = coerce(northArrowFrame); northElement.setGeometry(northArrowEnvelope); graphicsContainer.addElement(northElement, 0); //add a Title TextElement title = new TextElement(); title.setSize(20); title.setText(serverObject.getConfigurationName().toUpperCase()); IPoint titleGeometry = coerce(new Point()); titleGeometry.setX((ymax - ymin) / 2); titleGeometry.setY(((xmin + xmax) / 2) + 2); IElement titleElement = coerce(title); titleElement.setGeometry(titleGeometry); //title element is always on top graphicsContainer.addElement(titleElement, 1); //Add a ScaleBar IUID uidScaleBar = coerce(new UID()); uidScaleBar.setValue(AlternatingScaleBar.getClsid()); IMapSurroundFrame scaleBarFrame = mapFrame.createSurroundFrame(uidScaleBar, null); IEnvelope scaleEnvelope = coerce(new Envelope()); scaleEnvelope.putCoords(1, 1, 3, 1.3); IElement scaleElement = coerce(scaleBarFrame); scaleElement.setGeometry(scaleEnvelope); //Scale bar on top. graphicsContainer.addElement(scaleElement, 1); graphicsContainer.reset(); activeView.partialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); pageActiveView.partialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); //Generate Layout IMapServerLayout mapLayout = coerce(serverObject); IImageDescription imageDesc = coerce(new ImageDescription()); IImageDisplay imageDisplay = coerce(new ImageDisplay()); imageDisplay.setDeviceResolution(dpi); imageDisplay.setWidth(width); imageDisplay.setHeight(height); IImageType iImageType = coerce(new ImageType()); iImageType.setFormat(esriImageFormat.esriImagePNG24); iImageType.setReturnType(esriImageReturnType.esriImageReturnURL); imageDesc.setDisplay(imageDisplay); imageDesc.setType(iImageType); ILayoutImage outputImage = mapLayout.exportLayout(mapLayout.getDefaultPageDescription(), imageDesc); //dont persist -> restore back to original state. graphicsContainer.deleteElement(legendElement); graphicsContainer.deleteElement(northElement); graphicsContainer.deleteElement(titleElement); graphicsContainer.deleteElement(scaleElement); graphicsContainer.reset(); outputUrl = outputImage.getURL(); logger.info("Generated Layout : " + outputImage.getURL()); }catch (Exception e) { logger.severe("Error generating page layout : " + e.getMessage()); throw e; } }
如何把这段代码移植到C#.NET。。。
关于IMapServer和IMapServerObject和MapServer Class的关系:链接
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)