Пример #1
0
  private void addBaseLayer() {

    GeofenceGlobalConfiguration geoFenceConfiguration =
        (GeofenceGlobalConfiguration) GeofenceUtils.getInstance().getGlobalConfiguration();

    /* base layer */
    WMSParams wmsParams = new WMSParams();
    wmsParams.setLayers(geoFenceConfiguration.getBaseLayerName());
    wmsParams.setFormat(geoFenceConfiguration.getBaseLayerFormat());
    wmsParams.setStyles(geoFenceConfiguration.getBaseLayerStyle());

    WMSOptions wmsLayerParams = new WMSOptions();
    wmsLayerParams.setTransitionEffect(TransitionEffect.RESIZE);

    WMS layer =
        new WMS(
            geoFenceConfiguration.getBaseLayerTitle(),
            geoFenceConfiguration.getBaseLayerURL(),
            wmsParams,
            wmsLayerParams);
    Dispatcher.forwardEvent(GeoGWTEvents.ADD_LAYER, layer);
  }
Пример #2
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.geosdi.geoplatform.gui.impl.map.store.GPLayerBuilder#buildRaster(
   * org.geosdi.geoplatform.gui.model.GPRasterBean)
   */
  @Override
  public WMS buildRaster(GPRasterBean rasterBean) {
    WMSParams wmsParams = new WMSParams();
    wmsParams.setFormat("image/png");
    wmsParams.setLayers(rasterBean.getName());
    if (!rasterBean.getStyles().isEmpty()) {
      wmsParams.setStyles(rasterBean.getStyles().get(0).getStyleString());
    }
    wmsParams.setIsTransparent(true);

    if (rasterBean.getBbox() != null) {

      Bounds bbox =
          new Bounds(
              rasterBean.getBbox().getLowerLeftX(),
              rasterBean.getBbox().getLowerLeftY(),
              rasterBean.getBbox().getUpperRightX(),
              rasterBean.getBbox().getUpperRightY());

      bbox.transform(
          new Projection(rasterBean.getCrs()), new Projection(mapWidget.getMap().getProjection()));

      wmsParams.setMaxExtent(bbox);
    }

    WMSOptions wmsOption = new WMSOptions();
    wmsOption.setIsBaseLayer(false);
    wmsOption.setDisplayInLayerSwitcher(false);
    wmsOption.setDisplayOutsideMaxExtent(true);
    wmsOption.setBuffer(0);
    wmsOption.setRatio(1);

    WMS layer = new WMS(rasterBean.getLabel(), rasterBean.getDataSource(), wmsParams, wmsOption);

    layer.setOpacity(rasterBean.getOpacity());

    return layer;
  }
Пример #3
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.geosdi.geoplatform.gui.impl.map.store.GPLayerBuilder#buildVector(
   * org.geosdi.geoplatform.gui.model.GPVectorBean)
   */
  @Override
  public WMS buildVector(GPVectorBean vectorBean) {
    WMSParams wmsParams = new WMSParams();
    wmsParams.setFormat("image/png");
    wmsParams.setLayers(vectorBean.getName());
    wmsParams.setStyles("");
    wmsParams.setIsTransparent(true);

    if (vectorBean.getBbox() != null) {

      Bounds bbox =
          new Bounds(
              vectorBean.getBbox().getLowerLeftX(),
              vectorBean.getBbox().getLowerLeftY(),
              vectorBean.getBbox().getUpperRightX(),
              vectorBean.getBbox().getUpperRightY());

      bbox.transform(
          new Projection(vectorBean.getCrs()), new Projection(mapWidget.getMap().getProjection()));

      wmsParams.setMaxExtent(bbox);
    }

    WMSOptions wmsOption = new WMSOptions();
    wmsOption.setIsBaseLayer(false);
    wmsOption.setDisplayInLayerSwitcher(false);
    wmsOption.setDisplayOutsideMaxExtent(true);
    wmsOption.setBuffer(0);
    wmsOption.setRatio(1);

    String dataSource = vectorBean.getDataSource();

    dataSource = dataSource.replaceAll("wfs", "wms");

    return new WMS(vectorBean.getLabel(), dataSource, wmsParams, wmsOption);
  }
  @Override
  public void buildPanel() {
    OpenLayers.setProxyHost("olproxy?targetURL=");

    // create some MapOptions
    MapOptions defaultMapOptions = new MapOptions();
    defaultMapOptions.setDisplayProjection(
        new Projection(
            "EPSG:4326")); // causes the mouse popup to display coordinates in this format
    defaultMapOptions.setNumZoomLevels(16);

    // Create a MapWidget
    MapWidget mapWidget = new MapWidget("500px", "500px", defaultMapOptions);
    // Create a WMS layer as base layer
    WMSParams wmsParams = new WMSParams();
    wmsParams.setFormat("image/png");
    wmsParams.setLayers("basic");
    wmsParams.setStyles("");

    WMSOptions wmsLayerParams = new WMSOptions();
    wmsLayerParams.setUntiled();
    wmsLayerParams.setTransitionEffect(TransitionEffect.RESIZE);

    String wmsUrl = "http://labs.metacarta.com/wms/vmap0";

    WMS wmsLayer = new WMS("Basic WMS", wmsUrl, wmsParams, wmsLayerParams);

    // Add the WMS to the map
    Map map = mapWidget.getMap();
    map.addLayer(wmsLayer);

    // Adds the custom mouse position to the map
    MousePositionOutput mpOut =
        new MousePositionOutput() {
          @Override
          public String format(LonLat lonLat, Map map) {
            String out = "";
            out += "<b>This is the longitude </b> ";
            out += lonLat.lon();
            out += "<b>, and this the latitude</b> ";
            out += lonLat.lat();

            return out;
          }
        };

    MousePositionOptions mpOptions = new MousePositionOptions();
    mpOptions.setFormatOutput(mpOut); // rename to setFormatOutput

    map.addControl(new MousePosition(mpOptions));

    // Lets add some default controls to the map
    map.addControl(
        new LayerSwitcher()); // + sign in the upperright corner to display the layer switcher
    map.addControl(new OverviewMap()); // + sign in the lowerright to display the overviewmap
    map.addControl(new ScaleLine()); // Display the scaleline

    // Center and zoom to a location
    map.setCenter(new LonLat(146.7, -41.8), 6);

    contentPanel.add(
        new HTML("<p>This example shows how to add a custom mouse position to the map..</p>"));
    contentPanel.add(mapWidget);

    initWidget(contentPanel);

    mapWidget
        .getElement()
        .getFirstChildElement()
        .getStyle()
        .setZIndex(0); // force the map to fall behind popups
  }
  @Override
  public void buildPanel() {
    OpenLayers.setProxyHost("olproxy?targetURL=");

    // create some MapOptions
    MapOptions defaultMapOptions = new MapOptions();
    defaultMapOptions.setDisplayProjection(
        new Projection(
            "EPSG:4326")); // causes the mouse popup to display coordinates in this format
    defaultMapOptions.setNumZoomLevels(16);

    // Create a MapWidget
    MapWidget mapWidget = new MapWidget("500px", "500px", defaultMapOptions);
    // Create a WMS layer as base layer
    WMSParams wmsParams = new WMSParams();
    wmsParams.setFormat("image/png");
    wmsParams.setLayers("basic");
    wmsParams.setStyles("");

    WMSOptions wmsLayerParams = new WMSOptions();
    wmsLayerParams.setUntiled();
    wmsLayerParams.setTransitionEffect(TransitionEffect.RESIZE);

    String wmsUrl = "http://labs.metacarta.com/wms/vmap0";

    WMS wmsLayer = new WMS("Basic WMS", wmsUrl, wmsParams, wmsLayerParams);

    // Add the WMS to the map
    Map map = mapWidget.getMap();
    map.addLayer(wmsLayer);

    // Adds the graticule control
    LineSymbolizerOptions lineOptions = new LineSymbolizerOptions();
    lineOptions.setStrokeColor("#ccccff");
    lineOptions.setStrokeOpacity(0.5);
    lineOptions.setStrokeWidth(1);

    LineSymbolizer line = new LineSymbolizer(lineOptions);

    TextSymbolizerOptions textOptions = new TextSymbolizerOptions();
    textOptions.setFontSize("9px");

    TextSymbolizer text = new TextSymbolizer(textOptions);

    final GraticuleOptions grtOptions = new GraticuleOptions();

    grtOptions.setTargetSize(200);
    grtOptions.setLabelled(true);
    grtOptions.setLineSymbolyzer(line);
    grtOptions.setLabelSymbolizer(text);
    Graticule graticule = new Graticule(grtOptions);

    graticule.setAutoActivate(true);

    map.addControl(graticule);

    // Lets add some default controls to the map
    map.addControl(
        new LayerSwitcher()); // + sign in the upperright corner to display the layer switcher
    map.addControl(new OverviewMap()); // + sign in the lowerright to display the overviewmap
    map.addControl(new ScaleLine()); // Display the scaleline

    // Center and zoom to a location
    map.setCenter(new LonLat(146.7, -41.8), 6);

    contentPanel.add(
        new HTML("<p>This example shows how to add a custom mouse position to the map..</p>"));
    contentPanel.add(mapWidget);

    initWidget(contentPanel);

    mapWidget
        .getElement()
        .getFirstChildElement()
        .getStyle()
        .setZIndex(0); // force the map to fall behind popups
  }
  @Override
  public void buildPanel() {

    OpenLayers.setProxyHost("olproxy?targetURL=");

    // create some MapOptions
    MapOptions defaultMapOptions = new MapOptions();
    defaultMapOptions.setNumZoomLevels(16);

    // Create a MapWidget
    MapWidget mapWidget = new MapWidget("500px", "500px", defaultMapOptions);
    // Create a WMS layer as base layer
    WMSParams wmsParams = new WMSParams();
    wmsParams.setFormat("image/png");
    wmsParams.setLayers("basic");
    wmsParams.setStyles("");

    WMSOptions wmsLayerParams = new WMSOptions();
    wmsLayerParams.setUntiled();
    wmsLayerParams.setTransitionEffect(TransitionEffect.RESIZE);

    String wmsUrl = "http://vmap0.tiles.osgeo.org/wms/vmap0";

    WMS wmsLayer = new WMS("Basic WMS", wmsUrl, wmsParams, wmsLayerParams);

    Map map = mapWidget.getMap();

    // Add some control to the map
    LayerSwitcher layerSwitcher = new LayerSwitcher();
    map.addControl(layerSwitcher); // Display the LayerSwitcher
    map.addControl(new ScaleLine()); // Display the scaleline

    // Add the WMS to the map
    map.addLayer(wmsLayer);

    // Add some vectors
    final Point point = new Point(-110, 45);

    final Vector vectorLayer = new Vector("Features to Transform");

    // Style for the vector
    final Style featureStyle = new Style();
    featureStyle.setFillColor("#eeeeff");
    featureStyle.setStrokeColor("#3300ff");
    featureStyle.setStrokeWidth(2);
    featureStyle.setPointRadius(3);

    // Style for the rotation Handle
    final Style rotationHandlerStyle = new Style();
    rotationHandlerStyle.setFillColor("#eeeeee");
    rotationHandlerStyle.setFillOpacity(1);
    rotationHandlerStyle.setPointRadius(12);

    // create a polygon feature from a linear ring of points
    Point[] pointList = new Point[6];
    for (int p = 0; p < 6; p++) {
      double a = p * (2 * Math.PI) / 7;
      double r = Math.random() + 1;
      Point newPoint =
          new Point(point.getX() + (r * Math.cos(a)), point.getY() + (r * Math.sin(a)));
      pointList[p] = newPoint;
    }
    LinearRing linearRing = new LinearRing(pointList);
    final Polygon polygon = new Polygon(new LinearRing[] {linearRing});

    final VectorFeature polygonFeature =
        new VectorFeature(polygon, featureStyle); // create a VectorFeature from the polygon

    vectorLayer.addFeature(polygonFeature);

    // Create Options For the Transform Control
    TransformFeatureOptions transformFeatureOptions = new TransformFeatureOptions();

    transformFeatureOptions.setRotate(true);
    transformFeatureOptions.setRotation(0);
    transformFeatureOptions.setRederIntent("transform");
    transformFeatureOptions.setRotationHandleSymbolizer(rotationHandlerStyle);

    // Create The Transform Control
    TransformFeature transformFeature = new TransformFeature(vectorLayer, transformFeatureOptions);

    map.setCenter(new LonLat(point.getX(), point.getY()), 7);
    map.addLayer(vectorLayer);
    // Add and activate the control
    map.addControl(transformFeature);
    transformFeature.activate();

    contentPanel.add(new HTML("<p>This example shows the transformation of a Feature.</p>"));

    contentPanel.add(mapWidget);

    initWidget(contentPanel);

    mapWidget
        .getElement()
        .getFirstChildElement()
        .getStyle()
        .setZIndex(0); // force the map to fall behind popups
  }
Пример #7
0
  /** initialize map widget using gwt-openlayers */
  void initMapGwtOl() {

    MapOptions defaultMapOptions = new MapOptions();
    defaultMapOptions.setNumZoomLevels(16); //

    // defaultMapOptions.setProjection("EPSG:4326");
    defaultMapOptions.setMaxExtent(new Bounds(-180, -90, 180, 90));
    defaultMapOptions.setRestrictedExtent(new Bounds(-180, -90, 180, 90));
    defaultMapOptions.setUnits("degrees");
    mapWidget = new MapWidget("500px", "500px", defaultMapOptions);
    /*GoogleV3Options gNormalOptions = new GoogleV3Options();
    gNormalOptions.setIsBaseLayer(true);
    gNormalOptions.setType(GoogleV3MapType.G_NORMAL_MAP);
    GoogleV3 gNormal = new GoogleV3("Google Normal", gNormalOptions);*/

    // Create a WMS layer as base layer
    WMSParams wmsParams = new WMSParams();
    wmsParams.setFormat("image/png");
    wmsParams.setLayers("basic");
    wmsParams.setStyles("");

    WMSOptions wmsLayerParams = new WMSOptions();
    wmsLayerParams.setUntiled();
    wmsLayerParams.setTransitionEffect(TransitionEffect.RESIZE);

    String wmsUrl = EUOSMEGWT.wmsEndpoint;
    WMS wmsLayer = new WMS("Basic WMS", wmsUrl, wmsParams, wmsLayerParams);

    // Add the WMS to the map
    final Map map = mapWidget.getMap();
    // map.addLayer(gNormal);
    map.addLayer(wmsLayer);

    /*OSM osm_1 = OSM.Mapnik("Mapnik");
    OSM osm_2 = OSM.CycleMap("CycleMap");
    osm_1.setIsBaseLayer(true);
    osm_2.setIsBaseLayer(true);
    map.addLayer(osm_1);
    map.addLayer(osm_2);*/

    // Lets add some default controls to the map
    map.addControl(
        new LayerSwitcher()); // + sign in the upperright corner to display the layer switcher
    map.addControl(new ScaleLine()); // Display the scaleline
    map.addControl(new MousePosition());
    // Center and zoom to a location
    LonLat lonLat = new LonLat(6.95, 50.94);
    lonLat.transform(
        DEFAULT_PROJECTION.getProjectionCode(),
        map.getProjection()); // transform lonlat to OSM coordinate system
    map.setCenter(lonLat, 3);

    /*map.addMapClickListener(new MapClickListener() {

        public void onClick(MapClickListener.MapClickEvent mapClickEvent) {
            LonLat lonLat = mapClickEvent.getLonLat();

            lonLat.transform(map.getProjection(), DEFAULT_PROJECTION.getProjectionCode()); //transform lonlat to more readable format

            Window.alert("LonLat = (" + lonLat.lon() + " ; " + lonLat.lat() + ")");
        }

    });*/

    FeatureAddedListener listener =
        new FeatureAddedListener() {
          public void onFeatureAdded(VectorFeature vf) {
            Polygon aoi = Polygon.narrowToPolygon(vf.getGeometry().getJSObject());
            LinearRing[] rings = aoi.getComponents();
            if (rings != null) {
              rings[0].getComponents();
            }
            Geometry geo = vf.getGeometry();

            // Window.alert("Feature of class " + geo.getClassName() +  " added with bounds " +
            // geo.getBounds().toString());
            double north = Math.floor(geo.getBounds().getUpperRightY() * 100000) / 100000;
            double east = Math.floor(geo.getBounds().getUpperRightX() * 100000) / 100000;
            double south = Math.floor(geo.getBounds().getLowerLeftY() * 100000) / 100000;
            double west = Math.floor(geo.getBounds().getLowerLeftX() * 100000) / 100000;
            geoBoundsObj.newTextBoxNorth.setValue("" + north);
            geoBoundsObj.newTextBoxEast.setValue("" + east);
            geoBoundsObj.newTextBoxSouth.setValue("" + south);
            geoBoundsObj.newTextBoxWest.setValue("" + west);
            map.zoomToExtent(geo.getBounds());
          }
        };
    Vector boxLayer = new Vector("Box Layer");
    DrawFeatureOptions drawRegularPolygonFeatureOptions = new DrawFeatureOptions();
    drawRegularPolygonFeatureOptions.onFeatureAdded(listener);
    RegularPolygonHandlerOptions regularPolygonHandlerOptions = new RegularPolygonHandlerOptions();
    regularPolygonHandlerOptions.setSides(4);
    regularPolygonHandlerOptions.setIrregular(true);
    regularPolygonHandlerOptions.setPersist(true);
    drawRegularPolygonFeatureOptions.setHandlerOptions(regularPolygonHandlerOptions);
    final DrawFeature drawRegularPolygon =
        new DrawFeature(boxLayer, new RegularPolygonHandler(), drawRegularPolygonFeatureOptions);
    map.addControl(drawRegularPolygon);
    drawRegularPolygon.activate();
  }
  @Override
  public void buildPanel() {

    OpenLayers.setProxyHost("olproxy?targetURL=");

    // create some MapOptions
    MapOptions defaultMapOptions = new MapOptions();
    defaultMapOptions.setNumZoomLevels(16);

    // Create a MapWidget
    MapWidget mapWidget = new MapWidget("500px", "500px", defaultMapOptions);
    // Create a WMS layer as base layer
    WMSParams wmsParams = new WMSParams();
    wmsParams.setFormat("image/png");
    wmsParams.setLayers("basic");
    wmsParams.setStyles("");

    WMSOptions wmsLayerParams = new WMSOptions();
    wmsLayerParams.setUntiled();
    wmsLayerParams.setTransitionEffect(TransitionEffect.RESIZE);

    String wmsUrl = "http://vmap0.tiles.osgeo.org/wms/vmap0";

    WMS wmsLayer = new WMS("Basic WMS", wmsUrl, wmsParams, wmsLayerParams);

    // Add the WMS to the map
    Map map = mapWidget.getMap();
    map.addLayer(wmsLayer);

    // Add some vectors
    final Vector vectorLayer = new Vector("Simple Geometry");
    map.addLayer(vectorLayer);

    // create a point feature
    final Point point =
        new Point(-110, 45); // we need a Point object because this has the rotate method
    Style pointStyle = new Style();
    pointStyle.setFillColor("blue");
    pointStyle.setStrokeColor("blue");
    pointStyle.setStrokeWidth(3);
    pointStyle.setPointRadius(6);
    pointStyle.setFillOpacity(0.6);
    final VectorFeature pointFeature =
        new VectorFeature(point, pointStyle); // create a VectorFeature from the rotatable Polygon
    vectorLayer.addFeature(pointFeature);

    // create a line feature
    Point[] linePoints = {new Point(-120, 40), new Point(-115, 45), new Point(-110, 40)};
    final LineString lineString =
        new LineString(
            linePoints); // we need a LineString object because this has the rotate method
    final Style lineStyle = new Style();
    lineStyle.setStrokeColor("#339933");
    lineStyle.setStrokeWidth(3);
    lineStyle.setPointRadius(6);
    final VectorFeature lineFeature =
        new VectorFeature(
            lineString, lineStyle); // create a VectorFeature from the rotatable LineString
    vectorLayer.addFeature(lineFeature);

    // create a polygon feature from a linear ring of points
    Point[] pointList = new Point[6];
    for (int p = 0; p < 6; p++) {
      double a = p * (2 * Math.PI) / 7;
      double r = Math.random() + 1;
      Point newPoint =
          new Point(point.getX() + (r * Math.cos(a)), point.getY() + (r * Math.sin(a)));
      pointList[p] = newPoint;
    }
    LinearRing linearRing = new LinearRing(pointList);
    final Polygon polygon =
        new Polygon(
            new LinearRing[] {
              linearRing
            }); // we need a Polygon object because this has the rotate method
    final VectorFeature polygonFeature =
        new VectorFeature(polygon, lineStyle); // create a VectorFeature from the rotatable Polygon
    vectorLayer.addFeature(polygonFeature);

    // Lets add some default controls to the map
    map.addControl(
        new LayerSwitcher()); // + sign in the upperright corner to display the layer switcher
    map.addControl(new OverviewMap()); // + sign in the lowerright to display the overviewmap
    map.addControl(new ScaleLine()); // Display the scaleline

    // Center and zoom to a location
    map.setCenter(new LonLat(point.getX(), point.getY()), 5);

    // start the actual rotating
    final Point origin = new Point(-111.04, 45.68);

    final Timer t =
        new Timer() // we just use a GWT timer to have animation, no need for special OpenLayer
        // timer stuff...
        {
          @Override
          public void run() {
            polygon.rotate(-360 / 20, origin);
            vectorLayer.drawFeature(polygonFeature, lineStyle);

            lineString.rotate(360 / 40, origin);
            vectorLayer.drawFeature(lineFeature, lineStyle);

            point.rotate(360 / 20, origin);
            vectorLayer.drawFeature(pointFeature, lineStyle);
          }
        };
    t.scheduleRepeating(100);

    contentPanel.add(
        new HTML(
            "<p>This example shows a few features rotating. There is not yet a control built that provides a tool for rotating, but the geometry.rotate method can be accessed to rotate programmatically.</p>"));

    contentPanel.add(mapWidget);

    initWidget(contentPanel);

    mapWidget
        .getElement()
        .getFirstChildElement()
        .getStyle()
        .setZIndex(0); // force the map to fall behind popups
  }
Пример #9
0
  @Override
  public void buildPanel() {
    OpenLayers.setProxyHost("olproxy?targetURL=");

    // create some MapOptions
    MapOptions defaultMapOptions = new MapOptions();
    defaultMapOptions.setDisplayProjection(
        new Projection(
            "EPSG:4326")); // causes the mouse popup to display coordinates in this format
    defaultMapOptions.setNumZoomLevels(16);

    // Create a MapWidget
    MapWidget mapWidget = new MapWidget("500px", "500px", defaultMapOptions);
    // Create a WMS layer as base layer
    WMSParams wmsParams = new WMSParams();
    wmsParams.setFormat("image/png");
    wmsParams.setLayers("basic");
    wmsParams.setStyles("");

    WMSOptions wmsLayerParams = new WMSOptions();
    wmsLayerParams.setUntiled();
    wmsLayerParams.setTransitionEffect(TransitionEffect.RESIZE);

    String wmsUrl = "http://labs.metacarta.com/wms/vmap0";

    WMS wmsLayer = new WMS("Basic WMS", wmsUrl, wmsParams, wmsLayerParams);

    // Add the WMS to the map
    Map map = mapWidget.getMap();
    map.addLayer(wmsLayer);

    // Add a measure control to the map
    MeasureOptions measOpts = new MeasureOptions();
    measOpts.setPersist(true);
    measOpts.setGeodesic(true); // earth is not a cylinder
    Measure measure = new Measure(new PathHandler(), measOpts);
    map.addControl(measure);

    measure.addMeasureListener(
        new MeasureListener() {
          public void onMeasure(MeasureEvent eventObject) {
            Window.alert(
                "Measured distance is " + eventObject.getMeasure() + " " + eventObject.getUnits());
          }
        });
    measure.activate();

    // Lets add some default controls to the map
    map.addControl(
        new LayerSwitcher()); // + sign in the upperright corner to display the layer switcher
    map.addControl(new OverviewMap()); // + sign in the lowerright to display the overviewmap
    map.addControl(new ScaleLine()); // Display the scaleline

    // Center and zoom to a location
    map.setCenter(new LonLat(146.7, -41.8), 6);

    contentPanel.add(
        new HTML(
            "<p>This example shows how to add a Measure Control to the map.</p><p>Click on the map to add measure points, end a measurement using double click.</p><p>Note that you could add buttons to enable/disable the measure control on command.</p>"));
    contentPanel.add(mapWidget);

    initWidget(contentPanel);

    mapWidget
        .getElement()
        .getFirstChildElement()
        .getStyle()
        .setZIndex(0); // force the map to fall behind popups
  }