org.gwtopenmaps.openlayers.client.Bounds Java Examples

The following examples show how to use org.gwtopenmaps.openlayers.client.Bounds. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StationSelectorMap.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
public void zoomToMarkers() {
    try {
        if (markerLayer != null) {
            Bounds bbox = markerLayer.getDataExtent();
            if (bbox != null) {
                int z = map.getZoomForExtent(bbox, false);
                map.zoomToExtent(bbox);
                map.zoomTo(z);
            }
        }
    }
    catch (Exception e) {
        if ( !GWT.isProdMode()) {
            GWT.log("", e);
        }
    }
}
 
Example #2
Source File: StationSelectorMap.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
public StationSelectorMap(MapController controller) {
    super("523px"); // XXX map needs explicit height in px
    getMapWidget().setStylePrimaryName("n52-sensorwebclient-stationselector-map");
    this.controller = controller;
    map.addLayer(markerLayer);
    try {
        if (isDefinedGlobalExtent()) {
            PropertiesManager propertiesMgr = getPropertiesManager();
            double lleftX = new Double(propertiesMgr.getParameterAsString("lleftX"));
            double lleftY = new Double(propertiesMgr.getParameterAsString("lleftY"));
            double urightX = new Double(propertiesMgr.getParameterAsString("urightX"));
            double urightY = new Double(propertiesMgr.getParameterAsString("urightY"));
            defaultExtent = new Bounds(lleftX, lleftY, urightX, urightY);
        }
        else {
            GWT.log("No global extent configured. Zooming to: " + FALLBACK_EXTENT);
            defaultExtent = FALLBACK_EXTENT;
        }
    }
    catch (NumberFormatException e) {
        GWT.log("Error while parsing configured bounding box. Zooming to: " + FALLBACK_EXTENT);
        defaultExtent = FALLBACK_EXTENT;
    }
    zoomToExtent(defaultExtent);
}
 
Example #3
Source File: MapPreviewWidget.java    From geofence with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates the map option.
 *
 * @param isGoogle
 *            the is google
 */
private void createMapOption(boolean isGoogle)
{
    // TODO Auto-generated method stub

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

    this.defaultMapOptions = new MapOptions();
    this.defaultMapOptions.setNumZoomLevels(18);
    if (isGoogle)
    {
        this.defaultMapOptions.setProjection("EPSG:900913");
        this.defaultMapOptions.setDisplayProjection(new Projection("EPSG:4326"));
        this.defaultMapOptions.setUnits(MapUnits.METERS);
        this.defaultMapOptions.setMaxExtent(new Bounds(-20037508, -20037508, 20037508,
                20037508.34));
        this.defaultMapOptions.setMaxResolution(new Double(156543.0339).floatValue());
    }
    else
    {
        this.defaultMapOptions.setProjection("EPSG:4326");
    }

    initMapWidget(this.defaultMapOptions, isGoogle);
}
 
Example #4
Source File: CustomExtentTool.java    From geowe-core with GNU General Public License v3.0 6 votes vote down vote up
@PostConstruct
private void initialize() {

	customExtentDialog.getAddToMapButton().addSelectHandler(
			new SelectHandler() {

				@Override
				public void onSelect(SelectEvent event) {
					if (!isBBoxEmpty() && has4Coordinates()) {
						Bounds bounds = getBounds();

						Geometry geom = bounds.toGeometry();
						geom.transform(new Projection("EPSG:4326"),
								new Projection(geoMap.getMap()
										.getProjection()));
						VectorFeature vf = new VectorFeature(geom);

						VectorLayer bboxLayer = VectorLayerFactory
								.createEmptyVectorLayer(createBBoxLayerConfig());
						bboxLayer.addFeature(vf);

						layerManager.addVector(bboxLayer);
					}
				}
			});
}
 
Example #5
Source File: CurrentExtentTool.java    From geowe-core with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onRelease() {
	Bounds bounds = geoMap.getMap().getExtent();		
	LonLat center = bounds.getCenterLonLat();
	
	LonLat lower = new LonLat(bounds.getLowerLeftX(), bounds.getLowerLeftY());
	LonLat upper = new LonLat(bounds.getUpperRightX(), bounds.getUpperRightY());
	
	lower = transformToWGS84(lower);
	upper = transformToWGS84(upper);
	
	CurrentExtentInfo model = new CurrentExtentInfo();
	model.setCenter(center.lat() + ", " + center.lon());
	model.setLowerLeftX(lower.lon());
	model.setLowerLeftY(lower.lat());
	model.setUpperRightX(upper.lon());
	model.setUpperRightY(upper.lat());
	
	model.setBounds(bounds);		
	model.setWkt(getWKT(bounds));
	model.setWktWGS84(getWKTToWGS84(bounds));
	
	currentExtentDialog.setModel(model);
	currentExtentDialog.setModal(true);
	currentExtentDialog.show();		
}
 
Example #6
Source File: OverviewMap.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
public void zoomToMarkers() {
    Bounds bbox = markerLayer.getDataExtent();
    if (bbox != null) {
        map.setCenter(bbox.getCenterLonLat());
        if (markersOnMap.size() > 1) {
            map.zoomToExtent(bbox);
        } else {
            map.zoomTo(DEFAULT_ZOOM_LEVEL);
        }
    }
}
 
Example #7
Source File: GeoMap.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
public Bounds getDefaultMapBound() {
	final double lowerLeftX = appClientProperties.getFloatValue("lowerLeftX");
	final double lowerLeftY = appClientProperties.getFloatValue("lowerLeftY");
	final double upperRightX = appClientProperties.getFloatValue("upperRightX");
	final double upperRightY = appClientProperties.getFloatValue("upperRightY");

	return new Bounds(lowerLeftX,lowerLeftY,upperRightX,upperRightY);
}
 
Example #8
Source File: ZoomToVectorLayerTool.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick() {
	Vector layer = (Vector) getSelectedLayer();
	Bounds layerExtent = layer.getDataExtent();
	if (layerExtent == null) {
		Info.display(UIMessages.INSTANCE.zoomToVectorLayerToolText(),
				UIMessages.INSTANCE.emptyVectorLayer());
	}
	geoMap.getMap().zoomToExtent(layerExtent);
}
 
Example #9
Source File: CurrentExtentTool.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private String getWKTToWGS84(Bounds bounds) {
	Geometry geom = bounds.toGeometry().clone();
	geom.transform(new Projection(geoMap.getMap().getProjection()), new Projection("EPSG:4326"));
	VectorFeature extentFeature = new VectorFeature(geom);
	WKT wktFormat = new WKT();
	return wktFormat.write(extentFeature);
}
 
Example #10
Source File: CustomExtentTool.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private Bounds getBounds() {
	String[] coordinates = customExtentDialog.getBbox().split("\\,");
	double lowerLeftX = Double.parseDouble(coordinates[0]);
	double lowerLeftY = Double.parseDouble(coordinates[1]);
	double upperRightX = Double.parseDouble(coordinates[2]);
	double upperRightY = Double.parseDouble(coordinates[3]);

	return new Bounds(lowerLeftX, lowerLeftY, upperRightX, upperRightY);
}
 
Example #11
Source File: LockCurrentExtentTool.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private void confirmClearMaxExtent(final boolean value) {

		ConfirmMessageBox messageBox = messageDialogBuilder.createConfirm(
				UIMessages.INSTANCE.edtAlertDialogTitle(),
				UIMessages.INSTANCE.confirmClearMaxExtent(),
				ImageProvider.INSTANCE.currentExtent24());
		messageBox.getButton(PredefinedButton.YES).addSelectHandler(
				new SelectHandler() {
					@Override
					public void onSelect(SelectEvent event) {

						Bounds defaultBounds = getGeoMap().getDefaultMapBound();
						getGeoMap().getMap().setRestrictedExtent(defaultBounds);
						getGeoMap().getMap().setMaxExtent(defaultBounds);
						setText(UIMessages.INSTANCE.nameLockCurrentExtentTool());
						setIcon(ImageProvider.INSTANCE.unlockedExtension24());

						getGeoMap().getMap().zoomToExtent(
								layer.getDataExtent(), true);

						getGeoMap().getMap().removeLayer(layer);
					}
				});

		messageBox.getButton(PredefinedButton.NO).addSelectHandler(
				getNoSelectHandler(value));
		messageBox.show();
	}
 
Example #12
Source File: LockCurrentExtentTool.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private void createVectorLayer(Bounds bounds) {
	if (layer == null) {
		layer = new VectorLayer("LockedBBox");
		layer.setStyleMap(new StyleMap(createStyle()));
	}
	layer.removeAllFeatures();
	Geometry geom = bounds.toGeometry();
	VectorFeature vf = new VectorFeature(geom);
	layer.addFeature(vf);
	getGeoMap().getMap().addLayer(layer);
}
 
Example #13
Source File: CurrentExtentInfo.java    From geowe-core with GNU General Public License v3.0 4 votes vote down vote up
public void setBounds(Bounds bounds) {
	this.bounds = bounds;
}
 
Example #14
Source File: CurrentExtentInfo.java    From geowe-core with GNU General Public License v3.0 4 votes vote down vote up
public Bounds getBounds() {
	return bounds;
}
 
Example #15
Source File: CurrentExtentTool.java    From geowe-core with GNU General Public License v3.0 4 votes vote down vote up
private String getWKT(Bounds bounds) {
	Geometry geom = bounds.toGeometry();		
	VectorFeature extentFeature = new VectorFeature(geom);
	WKT wktFormat = new WKT();
	return wktFormat.write(extentFeature);
}
 
Example #16
Source File: WfsVectorLayerDef.java    From geowe-core with GNU General Public License v3.0 4 votes vote down vote up
public void setBbox(Bounds bbox) {
	this.bbox = bbox;
}
 
Example #17
Source File: StationSelectorMap.java    From SensorWebClient with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param bounds an extent to zoom to.
 */
public void zoomToExtent(Bounds bounds) {
    map.zoomToExtent(bounds);
}
 
Example #18
Source File: WfsVectorLayerDef.java    From geowe-core with GNU General Public License v3.0 4 votes vote down vote up
public Bounds getBbox() {
	return bbox;
}
 
Example #19
Source File: StationSelectorMap.java    From SensorWebClient with GNU General Public License v2.0 2 votes vote down vote up
/**
 * @return the default extent if configured. If no extent is configured the default extent probably has
 *         been set to {@link FALLBACK_EXTENT}.
 */
public Bounds getDefaultExtent() {
    return defaultExtent;
}