/**
  * If a new click is done while creating a cadastre object, it has to snap to a point. Because the
  * only layer used as snaptarget is the NewSurveyPointLayer the only points are the survey points.
  *
  * @param ev
  */
 @Override
 public void onMouseClicked(MapMouseEvent ev) {
   if (ev.getButton() == java.awt.event.MouseEvent.BUTTON1
       && this.getSnappedTarget() != SNAPPED_TARGET_TYPE.Vertex) {
     Messaging.getInstance().show(GisMessage.CADASTRE_CHANGE_NEW_CO_MUST_SNAP);
     return;
   }
   super.onMouseClicked(ev);
 }
Пример #2
0
 /**
  * It adds a graphics layer in the map
  *
  * @param layerName layer name
  * @param layerTitle layer title
  * @param geometryType geometry type for this layer
  * @param styleResource the resource name .xml in the location of resources for layer styles. This
  *     resource location is added in the path decided in SLD_RESOURCES {
  * @see org.sola.clients.geotools.ui.layers.SolaFeatureLayer}.
  * @return
  */
 public ExtendedLayerGraphics addLayerGraphics(
     String layerName, String layerTitle, Geometries geometryType, String styleResource) {
   ExtendedLayerGraphics layer = null;
   try {
     layer = new ExtendedLayerGraphics(layerName, geometryType, styleResource);
     layer.setTitle(layerTitle);
     this.addLayer(layer);
   } catch (InitializeLayerException ex) {
     Messaging.getInstance().show(ex.getMessage());
   }
   return layer;
 }
Пример #3
0
 /**
  * It adds a editor layer in the map.
  *
  * @param layerName layer name
  * @param layerTitle layer title
  * @param geometryType geometry type for this layer
  * @param styleResource the resource name .xml in the location of resources for layer styles. This
  *     resource location is added in the path decided in SLD_RESOURCES {
  * @see org.sola.clients.geotools.ui.layers.SolaFeatureLayer}.
  * @return
  */
 public ExtendedLayerEditor addLayerEditor(
     String layerName,
     String layerTitle,
     Geometries geometryType,
     String styleResource,
     String extraFieldsFormat) {
   ExtendedLayerEditor layer = null;
   try {
     layer = new ExtendedLayerEditor(layerName, geometryType, styleResource, extraFieldsFormat);
     layer.setTitle(layerTitle);
     this.addLayer(layer);
   } catch (InitializeLayerException ex) {
     Messaging.getInstance().show(ex.getMessage());
   }
   return layer;
 }
Пример #4
0
 /**
  * It adds a shapefile layer setting the layer to visible by default.
  *
  * @param layerName the layer name
  * @param layerTitle layer title
  * @param pathOfShapefile the path of the .shp file
  * @param styleResource the resource name .xml in the location of resources for layer styles.
  * @param visible Indicates if the default state of the layer is visible or not. This resource
  *     location is added in the path decided in SLD_RESOURCES {
  * @see org.sola.clients.geotools.ui.layers.SolaFeatureLayer}.
  * @return
  */
 public ExtendedLayerShapefile addLayerShapefile(
     String layerName,
     String layerTitle,
     String pathOfShapefile,
     String styleResource,
     boolean visible) {
   ExtendedLayerShapefile layer = null;
   try {
     layer = new ExtendedLayerShapefile(layerName, pathOfShapefile, styleResource);
     layer.setTitle(layerTitle);
     layer.setVisible(visible);
     this.addLayer(layer);
   } catch (InitializeLayerException ex) {
     Messaging.getInstance().show(ex.getMessage());
   }
   return layer;
 }
Пример #5
0
 /**
  * Initializes the selection layer on the map control. This method should be called after all map
  * layers have been added to ensure the selection layer appears on top of the other SOLA layers.
  */
 public void initializeSelectionLayer() {
   try {
     ExtendedLayerGraphics selectionLayer =
         (ExtendedLayerGraphics) getSolaLayers().get(SELECTION_LAYER_NAME);
     if (selectionLayer == null) {
       selectionLayer =
           new ExtendedLayerGraphics(
               SELECTION_LAYER_NAME,
               Geometries.GEOMETRY,
               SELECTION_SLD_FILE,
               LAYER_FIELD_GEOMETRY_TYPE + ":String");
       selectionLayer.setShowInToc(false);
       this.addLayer(selectionLayer);
     }
   } catch (InitializeLayerException ex) {
     Messaging.getInstance().show(ex.getMessage());
   }
 }
Пример #6
0
 /**
  * It adds a layer of type WMS which is actually a WMS Server with a list of layers in it.
  *
  * @param layerName The name
  * @param layerTitle layer title
  * @param URL The Url to the wms server
  * @param layerNames The list of layer names
  * @param visible Flag to indicate if the layer should be visible by default.
  * @return
  */
 public ExtendedWmsLiteLayer addLayerWms(
     String layerName,
     String layerTitle,
     String Url,
     List<String> layerNames,
     boolean visible,
     String version,
     String format) {
   ExtendedWmsLiteLayer layer = null;
   try {
     layer =
         new ExtendedWmsLiteLayer(
             layerName, layerTitle, Url, layerNames, this.getSrid(), version, format);
     layer.setVisible(visible);
     this.addLayer(layer);
     this.getSolaLayers().put(layerName, layer);
   } catch (InitializeLayerException ex) {
     Messaging.getInstance().show(ex.getMessage());
   }
   return layer;
 }
Пример #7
0
  /** Zooms the map to the selected object and highlight it in the map. */
  @Override
  public void onSelectionConfirmed() {
    if (this.getSelectedElement() == null) {
      return;
    }
    SpatialSearchResultBean selectedObj = (SpatialSearchResultBean) this.getSelectedElement();
    try {
      Geometry geom = PojoFeatureSource.getWkbReader().read(selectedObj.getTheGeom());

      // Select the object on the map
      this.map.clearSelectedFeatures();
      this.map.selectFeature(selectedObj.getId(), geom);

      // Zoom to map to the object
      ReferencedEnvelope boundsToZoom = JTS.toEnvelope(geom);
      boundsToZoom.expandBy(this.searchByObject.getZoomInBuffer().doubleValue());
      this.map.setDisplayArea(boundsToZoom);
    } catch (ParseException ex) {
      Messaging.getInstance().show(GisMessage.LEFT_PANEL_FIND_ERROR);
      org.sola.common.logging.LogUtility.log(GisMessage.LEFT_PANEL_FIND_ERROR, ex);
    }
  }
Пример #8
0
 /**
  * Given the extent, modifies the feature collection
  *
  * @param west
  * @param south
  * @param east
  * @param north
  */
 private void ModifyFeatureCollection(double west, double south, double east, double north) {
   if (!this.layer.isForceRefresh()) {
     if (this.lastWest == west
         && this.lastSouth == south
         && this.lastEast == east
         && this.lastNorth == north) {
       return;
     }
   } else {
     this.layer.setForceRefresh(false);
   }
   this.lastWest = west;
   this.lastSouth = south;
   this.lastEast = east;
   this.lastNorth = north;
   try {
     ResultForNavigationInfo resultInfo =
         this.dataSource.GetQueryData(
             this.getSchema().getTypeName(),
             west,
             south,
             east,
             north,
             this.getLayer().getSrid(),
             this.getLayer().getMapControl().getPixelResolution());
     List<SimpleFeature> featuresToAdd = this.getFeaturesFromData(resultInfo.getToAdd());
     this.collection.clear();
     this.collection.addAll(featuresToAdd);
   } catch (WebServiceClientException ex) {
     LogUtility.log(
         String.format(GisMessage.GENERAL_RETRIEVE_FEATURES_ERROR, this.getLayer().getTitle()),
         ex);
     Messaging.getInstance()
         .show(GisMessage.GENERAL_RETRIEVE_FEATURES_ERROR, this.getLayer().getTitle());
   }
 }