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

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


      String inSR, String spatialRel, String where, String outFields,
      boolean returnGeometry, String outSR, boolean returnIdsOnly) {
    String result = null;

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

      if (mapService != null) {
        MapDesc mapDesc = mapService.getMapDesc();
        MapServiceDesc mapServiceDesc = mapService.getMapServiceDesc();
        if (mapServiceDesc.isNeedToken()) {
          boolean htmlNoParams = "html".equals(f)
              && objectIds == null && geometry == null
              && geometryType == null && inSR == null
              && spatialRel == null && where == null
              && outFields == null && outSR == null;
          if (!TokenService.verifyToken(token) && !htmlNoParams) {
            return TokenService.TOKEN_INVALID_TIP;
          }
        }

        // Handle layerId
        int nLayerId = Integer.parseInt(layerId);

        // Handle SRs
        String sr = mapDesc.getWkid();
        if (inSR == null || "".equals(inSR)) {
          inSR = sr;
        }
        if (outSR == null || "".equals(outSR)) {
          outSR = sr;
        }

        String[] featureIds = null;
        com.gi.engine.carto.QueryParam queryParam = null;

        // Handle objectids
        if (objectIds != null && !"".equals(objectIds)) {
          featureIds = objectIds.split(",");
        } else {
          // Handle geometry
          Geometry geo = null;
          if (geometry != null && !"".equals(geometry)) {
            geo = EsriJsonUtil.json2Geometry(geometry);

            if (!sr.equals(inSR)) {
              geo = GeometryToolkit.project(geo, inSR, sr);
            }
          }

          // Handle spatialRel
          SpatialFilterType relation;
          if ("esriSpatialRelContains".equals(spatialRel)) {
            relation = SpatialFilterType.CONTAINS;
          } else if ("esriSpatialRelCrosses".equals(spatialRel)) {
            relation = SpatialFilterType.CROSSES;
          } else if ("esriSpatialRelEnvelopeIntersects"
              .equals(spatialRel)) {
            relation = SpatialFilterType.ENVELOPE_INTERSECTS;
          } else if ("esriSpatialRelIndexIntersects"
              .equals(spatialRel)) {
            relation = SpatialFilterType.INDEX_INTERSECTS;
          } else if ("esriSpatialRelOverlaps".equals(spatialRel)) {
            relation = SpatialFilterType.OVERLAPS;
          } else if ("esriSpatialRelTouches".equals(spatialRel)) {
            relation = SpatialFilterType.TOUCHES;
          } else if ("esriSpatialRelWithin".equals(spatialRel)) {
            relation = SpatialFilterType.WITHIN;
          } else {
            relation = SpatialFilterType.INTERSECTS;
          }

          queryParam = new com.gi.engine.carto.QueryParam();
          queryParam.setGeometry(geo);
          queryParam.setSpatialFilterType(relation);
          queryParam.setWhere(where);
        }

        FeatureCollection<? extends FeatureType, ? extends Feature> featureCollection = null;
        MapServiceInstance instance = (MapServiceInstance) mapService
            .getMapServicePool().checkoutIdleInstance();
        try {
          Layer layer = instance.getMap().getLayer(nLayerId);
          if (featureIds != null) {
            featureCollection = layer.query(featureIds);
          } else {
            featureCollection = layer.query(queryParam);
          }
        } finally {
          if (instance != null) {
            mapService.getMapServicePool().checkinIdelInstance(
                instance);
          }
        }

        // Various out format
View Full Code Here


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

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

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

        String[] featureIds = new String[] { String.valueOf(featureId) };

        FeatureCollection<? extends FeatureType, ? extends Feature> featureCollection = null;
        MapServiceInstance instance = (MapServiceInstance) mapService
            .getMapServicePool().checkoutIdleInstance();
        try {
          Layer layer = instance.getMap().getLayer(layerId);
          featureCollection = layer.query(featureIds);
        } finally {
          if (instance != null) {
            mapService.getMapServicePool().checkinIdelInstance(
                instance);
          }
        }

        // Various out format
View Full Code Here

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

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

      if (mapService != null) {
        MapServiceDesc mapServiceDesc = mapService.getMapServiceDesc();
        if (mapServiceDesc.isNeedToken()) {
          if (!TokenService.verifyToken(token) && !("html".equals(f))) {
            return TokenService.TOKEN_INVALID_TIP;
          }
        }
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("mapServices", 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/MapService/" + name + "'>" + name
              + "</a>");
          if (mapService.getMapServiceDesc().isNeedToken()) {
            sb.append("<img src='" + contextRoot
                + "/image/lock.png'>");
          }
          sb.append("</li>");
        }
View Full Code Here

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

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

      if (mapService != null) {
        MapServiceDesc mapServiceDesc = mapService.getMapServiceDesc();
        if (mapServiceDesc.isNeedToken()) {
          if (!TokenService.verifyToken(token) && !("html".equals(f))) {
            return TokenService.TOKEN_INVALID_TIP;
          }
        }
View Full Code Here

      String f, String objectIds, String geometry, String geometryType,
      String inSR, String spatialRel, String where) {
    String result = null;

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

      if (mapService != null) {
        MapServiceDesc mapServiceDesc = mapService.getMapServiceDesc();
        if (mapServiceDesc.isNeedToken()) {
          boolean htmlNoParams = "html".equals(f)
              && objectIds == null && geometry == null
              && geometryType == null && inSR == null
              && spatialRel == null && where == null;
          if (!TokenService.verifyToken(token) && !htmlNoParams) {
            return TokenService.TOKEN_INVALID_TIP;
          }
        }

        // Handle layerId
        int nLayerId = Integer.parseInt(layerId);

        MapDesc mapDesc = mapService.getMapDesc();
        boolean editable = mapDesc.getLayerInfo(nLayerId).isEditable();
        if (!editable) {
          return null;
        }

        // Handle SRs
        String sr = mapDesc.getWkid();
        if (inSR == null || "".equals(inSR)) {
          inSR = sr;
        }

        String[] featureIds = null;
        com.gi.engine.carto.QueryParam queryParam = null;

        // Handle objectids
        if (objectIds != null && !"".equals(objectIds)) {
          featureIds = objectIds.split(",");
        } else {
          // Handle geometry
          Geometry geo = null;
          if (geometry != null && !"".equals(geometry)) {
            geo = EsriJsonUtil.json2Geometry(geometry);

            if (!sr.equals(inSR)) {
              geo = GeometryToolkit.project(geo, inSR, sr);
            }
          }

          // Handle spatialRel
          SpatialFilterType relation;
          if ("esriSpatialRelContains".equals(spatialRel)) {
            relation = SpatialFilterType.CONTAINS;
          } else if ("esriSpatialRelCrosses".equals(spatialRel)) {
            relation = SpatialFilterType.CROSSES;
          } else if ("esriSpatialRelEnvelopeIntersects"
              .equals(spatialRel)) {
            relation = SpatialFilterType.ENVELOPE_INTERSECTS;
          } else if ("esriSpatialRelIndexIntersects"
              .equals(spatialRel)) {
            relation = SpatialFilterType.INDEX_INTERSECTS;
          } else if ("esriSpatialRelOverlaps".equals(spatialRel)) {
            relation = SpatialFilterType.OVERLAPS;
          } else if ("esriSpatialRelTouches".equals(spatialRel)) {
            relation = SpatialFilterType.TOUCHES;
          } else if ("esriSpatialRelWithin".equals(spatialRel)) {
            relation = SpatialFilterType.WITHIN;
          } else {
            relation = SpatialFilterType.INTERSECTS;
          }

          queryParam = new com.gi.engine.carto.QueryParam();
          queryParam.setGeometry(geo);
          queryParam.setSpatialFilterType(relation);
          queryParam.setWhere(where);
        }

        boolean success = false;
        MapServiceInstance instance = (MapServiceInstance) mapService
            .getMapServicePool().checkoutIdleInstance();
        try {
          Layer layer = instance.getMap().getLayer(nLayerId);
          if (featureIds != null) {
            success = layer.delete(featureIds);
          } else {
            success = layer.delete(queryParam);
          }
        } finally {
          if (instance != null) {
            mapService.getMapServicePool().checkinIdelInstance(
                instance);
          }
        }

        // Various out format
View Full Code Here

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

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

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

        // Handle layerId
        int nLayerId = Integer.parseInt(layerId);

        MapDesc mapDesc = mapService.getMapDesc();
        boolean editable = mapDesc.getLayerInfo(nLayerId).isEditable();
        if (!editable) {
          return null;
        }

        FeatureType featureType = null;
        MapServiceInstance instance = (MapServiceInstance) mapService
            .getMapServicePool().checkoutIdleInstance();
        try {
          Layer layer = instance.getMap().getLayer(nLayerId);
          featureType = layer.getMapLayer().getFeatureSource()
              .getSchema();
        } finally {
          if (instance != null) {
            mapService.getMapServicePool().checkinIdelInstance(
                instance);
          }
        }

        // Handle features
        FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection = EsriJsonUtil
            .json2FeatureCollection(features,
                (SimpleFeatureType) featureType);

        instance = (MapServiceInstance) mapService.getMapServicePool()
            .checkoutIdleInstance();
        HashMap<FeatureId, Boolean> updates = null;
        try {
          Layer layer = instance.getMap().getLayer(nLayerId);
          updates = layer.update(featureCollection);
        } finally {
          if (instance != null) {
            mapService.getMapServicePool().checkinIdelInstance(
                instance);
          }
        }

        // Various out format
View Full Code Here

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

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

      MapDesc mapDesc = mapService.getMapDesc();
      boolean editable = mapDesc.getLayerInfo(layerId).isEditable();

      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(), editable);
          }
        }
      }
    } catch (Exception ex) {
View Full Code Here

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

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

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

        String[] featureIds = new String[] { String.valueOf(featureId) };

        FeatureCollection<? extends FeatureType, ? extends Feature> featureCollection = null;
        MapServiceInstance instance = (MapServiceInstance) mapService
            .getMapServicePool().checkoutIdleInstance();
        try {
          Layer layer = instance.getMap().getLayer(layerId);
          featureCollection = layer.query(featureIds);
        } finally {
          if (instance != null) {
            mapService.getMapServicePool().checkinIdelInstance(
                instance);
          }
        }

        // Various out format
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.