zoukankan      html  css  js  c++  java
  • arcgis sample代码之SOE示例代码PageLayout REST Server Object Extension的源码分析(Java)

    为什么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的关系:链接

  • 相关阅读:
    4月7日工作日志
    5月4日工作日志
    4月7日工作日志
    4月1日工作日志
    3月31日工作日志
    3月31日工作日志
    对元素绑定事件方法
    css实现垂直居中的各种方法
    纯css写一个switch开关
    弹性盒模型flex布局
  • 原文地址:https://www.cnblogs.com/2008nmj/p/14544786.html
Copyright © 2011-2022 走看看