Package com.gi.server.core.service.mapservice

Examples of com.gi.server.core.service.mapservice.MapService


      obj.put("GIServerVersion", VersionUtil.getCurrentversion());
      arrayTemp = new JSONArray();
      for(Iterator<Entry<String, MapService>> itr=mapServices.entrySet().iterator();itr.hasNext();){
        Entry<String, MapService> entry = itr.next();
        String name = entry.getKey();
        MapService mapService = entry.getValue();
        if (mapService.isStarted()) {
          objTemp = new JSONObject();
          objTemp.put("name", name);
          objTemp.put("needToken", mapService.getMapServiceDesc().isNeedToken());
          arrayTemp.put(objTemp);
        }
      }
      obj.put("mapServices", arrayTemp);
View Full Code Here


      sb.append("<b><a href='" + contextRoot + "/rest/service/MapService'>Map Service</a>:</b>");
      sb.append("<ul>");
      for(Iterator<Entry<String, MapService>> itr=mapServices.entrySet().iterator();itr.hasNext();){
        Entry<String, MapService> entry = itr.next();
        String name = entry.getKey();
        MapService mapService = entry.getValue();
        if (mapService.isStarted()) {
          sb.append("<li><a href='" + contextRoot + "/rest/service/MapService/" + name + "'>"
              + name + "</a>");
          if (mapService.getMapServiceDesc().isNeedToken()) {
            sb.append("<img src='" + contextRoot + "/image/lock.png'>");
          }
          sb.append("</li>");
        }
      }
      sb.append("</ul><br/>");

      sb.append("<b><a href='" + contextRoot + "/rest/service/FeatureService'>Feature Service</a>:</b>");
      sb.append("<ul>");
      for(Iterator<Entry<String, MapService>> itr=mapServices.entrySet().iterator();itr.hasNext();){
        Entry<String, MapService> entry = itr.next();
        String name = entry.getKey();
        MapService mapService = entry.getValue();
        if (mapService.isStarted()) {
          sb.append("<li><a href='" + contextRoot + "/rest/service/FeatureService/" + name + "'>"
              + name + "</a>");
          if (mapService.getMapServiceDesc().isNeedToken()) {
            sb.append("<img src='" + contextRoot + "/image/lock.png'>");
          }
          sb.append("</li>");
        }
      }
View Full Code Here

      arrayTemp = new JSONArray();
      for (Iterator<Entry<String, MapService>> itr = mapServices
          .entrySet().iterator(); itr.hasNext();) {
        Entry<String, MapService> entry = itr.next();
        String name = entry.getKey();
        MapService mapService = entry.getValue();
        if (mapService.isStarted()) {
          objTemp = new JSONObject();
          objTemp.put("name", name);
          objTemp.put("needToken", mapService.getMapServiceDesc()
              .isNeedToken());
          arrayTemp.put(objTemp);
        }
      }
      obj.put("featureServices", arrayTemp);
View Full Code Here

      sb.append("<ul>");
      for (Iterator<Entry<String, MapService>> itr = mapServices
          .entrySet().iterator(); itr.hasNext();) {
        Entry<String, MapService> entry = itr.next();
        String name = entry.getKey();
        MapService mapService = entry.getValue();
        if (mapService.isStarted()) {
          sb.append("<li><a href='" + contextRoot
              + "/rest/service/FeatureService/" + name + "'>" + name
              + "</a>");
          if (mapService.getMapServiceDesc().isNeedToken()) {
            sb.append("<img src='" + contextRoot
                + "/image/lock.png'>");
          }
          sb.append("</li>");
        }
View Full Code Here

      // Clear map instances
      HashMap<String, MapService> mapServices = ServiceManager.getMapServices();
      for(Iterator<Entry<String, MapService>> itr=mapServices.entrySet().iterator();itr.hasNext();){
        Entry<String, MapService> entry = itr.next();
        MapService mapService = entry.getValue();
        MapServicePool mapServicePool = mapService.getMapServicePool();
        mapServicePool.shrinkPool();
      }

    }
  }
View Full Code Here

  public synchronized boolean startMapService(String serviceName) {
    boolean result = false;

    if (authorized) {
      try {
        MapService mapService = ServiceManager
            .loadMapService(serviceName);
        result = mapService.start();
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
View Full Code Here

  public synchronized boolean stopMapService(String serviceName) {
    boolean result = false;

    if (authorized) {
      try {
        MapService mapService = ServiceManager
            .getMapService(serviceName);
        if (mapService != null) {
          result = mapService.stop();
        }
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
View Full Code Here

  private String result(String serviceName, int layerId, String f) {
    String result = null;

    try {
      MapService mapService = ServiceManager.getMapService(serviceName);

      if (mapService != null) {
        MapLayer mapLayer = null;
        MapServiceInstance instance = (MapServiceInstance) mapService
            .getMapServicePool().checkoutIdleInstance();
        try {
          mapLayer = instance.getMap().getLayer(layerId)
              .getMapLayer();
        } finally {
          if (instance != null) {
            mapService.getMapServicePool().checkinIdelInstance(
                instance);
          }
        }
        if (mapLayer != null) {
          // Various out format
          if ("json".equals(f)) {
            result = this.generateJSONResult(layerId, mapLayer);
          } else if ("html".equals(f)) {
            result = this.generateHTMLResult(serviceName, layerId,
                mapLayer, mapService.getMapServiceDesc()
                    .isNeedToken());
          }
        }
      }
    } catch (Exception ex) {
View Full Code Here

      String tolerance, String mapExtent, String imageDisplay,
      String returnGeometry) {
    String result = null;

    try {
      MapService mapService = ServiceManager.getMapService(serviceName);

      if (mapService != null) {
        MapDesc mapDesc = mapService.getMapDesc();
        MapServiceDesc mapServiceDesc = mapService.getMapServiceDesc();
        if (mapServiceDesc.isNeedToken()) {
          if (!TokenService.verifyToken(token)
              && !("html".equals(f) && geometry == null)) {
            return TokenService.TOKEN_INVALID_TIP;
          }
        }

        // Handle geometry
        Geometry identifyGeometry = EsriJsonUtil
            .json2Geometry(geometry);

        // Handle SRs
        String mapSR = mapDesc.getWkid();
        if (sr == null || "".equals(sr)) {
          sr = mapSR;
        }
        if (!sr.equals(mapSR)) {
          identifyGeometry = GeometryToolkit.project(
              identifyGeometry, sr, mapSR);
        }

        // Handle layers
        IdentifyType identifyType = IdentifyType.TOP;
        ArrayList<String> layerIds = new ArrayList<String>();
        if (layers != null && !"".equals(layers)) {
          String type = null;
          String ids = layers;
          if (layers.indexOf(":") > 0) {
            String[] str = layers.split(":");
            type = str[0];
            ids = str[1];
            if (ids != null && !"".equals(ids)) {
              try {
                String[] strLayers = ids.split(",");
                int layerCount = strLayers.length;
                for (int i = 0; i < layerCount; i++) {
                  layerIds.add(strLayers[i]);
                }
              } catch (Exception ex) {
                ex.printStackTrace();
              }
            }
          } else {
            type = layers;
            for (int i = 0, count = mapDesc.getLayerInfos().size(); i < count; i++) {
              layerIds.add(String.valueOf(i));
            }
          }

          if ("top".equals(type.toLowerCase())) {
            identifyType = IdentifyType.TOP;
          } else if ("visible".equals(type.toLowerCase())) {
            identifyType = IdentifyType.VISIBLE;
          } else if ("all".equals(type.toLowerCase())) {
            identifyType = IdentifyType.ALL;
          }
        }

        // Handle tolerance
        int nTolerance = Integer.parseInt(tolerance);

        // Handle mapExtent
        Envelope env = null;
        if (mapExtent != null && !"".equals(mapExtent)) {
          String[] mapStrs = mapExtent.split(",");
          double xmin = Double.parseDouble(mapStrs[0]);
          double ymin = Double.parseDouble(mapStrs[1]);
          double xmax = Double.parseDouble(mapStrs[2]);
          double ymax = Double.parseDouble(mapStrs[3]);
          env = new Envelope(xmin, xmax, ymin, ymax);
          if (!sr.equals(mapSR)) {
            env = GeometryToolkit.project(env, sr, mapSR);
          }
        }

        // Handle imageDisplay
        int width = 0;
        int height = 0;
        @SuppressWarnings("unused")
        int dpi = 0;
        if (mapExtent != null && !"".equals(mapExtent)) {
          String[] imageStrs = imageDisplay.split(",");
          width = Integer.parseInt(imageStrs[0]);
          height = Integer.parseInt(imageStrs[1]);
          dpi = Integer.parseInt(imageStrs[2]);
        }

        // Handle returnGeometry
        boolean isReturnGeometry = Boolean.parseBoolean(returnGeometry);

        ArrayList<FeatureResult> featureResults = null;
        if (env != null) {
          // Handle resolution
          double resolutionX = env.getWidth() / width;
          double resolutionY = env.getHeight() / height;
          double resolution = Math.max(resolutionX, resolutionY);

          IdentifyParam identifyParam = new IdentifyParam();
          identifyParam.setGeometry(identifyGeometry);
          identifyParam.setIdentifyType(identifyType);
          identifyParam.setResolution(resolution);
          identifyParam.setTolerance(nTolerance);

          MapServiceInstance instance = (MapServiceInstance) mapService
              .getMapServicePool().checkoutIdleInstance();
          try {
            featureResults = instance.identify(layerIds,
                identifyParam);
          } finally {
            if (instance != null) {
              mapService.getMapServicePool().checkinIdelInstance(
                  instance);
            }
          }
        }
View Full Code Here

        restBody += "<ul>";
        for (Iterator<Entry<String, MapService>> itr = mapServices
            .entrySet().iterator(); itr.hasNext();) {
          Entry<String, MapService> entry = itr.next();
          String name = entry.getKey();
          MapService mapService = entry.getValue();
          restBody += "<li>";
          restBody += "&nbsp;&nbsp;<b>" + name + "</b>";
          if (mapService.isStarted()) {
            MapServicePool pool = mapService.getMapServicePool();
            restBody += "&nbsp;&nbsp;Running("
                + pool.getWorkingInstanceCount() + ")";
            restBody += "&nbsp;&nbsp;Totle("
                + (pool.getWorkingInstanceCount() + pool
                    .getIdleInstanceCount()) + ")";
View Full Code Here

TOP

Related Classes of com.gi.server.core.service.mapservice.MapService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.