Integrated Pianta Fine Scavo
This commit is contained in:
parent
2ba6472e10
commit
7a36ef5ed5
|
@ -1,119 +0,0 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
||||
|
||||
import com.google.gwt.dom.client.Document;
|
||||
import com.google.gwt.dom.client.LinkElement;
|
||||
import com.google.gwt.dom.client.Style.Display;
|
||||
import com.google.gwt.dom.client.Style.Overflow;
|
||||
import com.google.gwt.dom.client.Style.Position;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
|
||||
import ol.Collection;
|
||||
import ol.Coordinate;
|
||||
import ol.OLFactory;
|
||||
import ol.OLUtil;
|
||||
import ol.control.Control;
|
||||
import ol.control.ControlOptions;
|
||||
import ol.control.FullScreen;
|
||||
import ol.control.MousePosition;
|
||||
import ol.control.ZoomSlider;
|
||||
import ol.geom.Polygon;
|
||||
import ol.layer.Base;
|
||||
import ol.layer.LayerOptions;
|
||||
import ol.layer.Tile;
|
||||
import ol.source.Osm;
|
||||
import ol.source.XyzOptions;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tino Desjardins
|
||||
*
|
||||
*/
|
||||
public final class DemoUtils {
|
||||
|
||||
private DemoUtils() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates some default controls and adds it to the collection.
|
||||
*
|
||||
* @param controls collection with controls
|
||||
*/
|
||||
public static void addDefaultControls(final Collection<Control> controls) {
|
||||
|
||||
controls.push(new FullScreen());
|
||||
controls.push(new ZoomSlider());
|
||||
MousePosition mousePosition = new MousePosition();
|
||||
mousePosition.setCoordinateFormat(Coordinate.createStringXY(5));
|
||||
controls.push(mousePosition);
|
||||
//controls.push(new ZoomToExtent());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a MapBox logo.
|
||||
*
|
||||
* @return MapBox logo
|
||||
*/
|
||||
public static Control createMapboxLogo() {
|
||||
|
||||
ControlOptions controlOptions = new ControlOptions();
|
||||
|
||||
LinkElement mapboxLogo = Document.get().createLinkElement();
|
||||
mapboxLogo.setHref("https://mapbox.com/about/maps");
|
||||
mapboxLogo.setTarget("_blank");
|
||||
|
||||
mapboxLogo.getStyle().setPosition(Position.ABSOLUTE);
|
||||
mapboxLogo.getStyle().setLeft(2, Unit.PX);
|
||||
mapboxLogo.getStyle().setBottom(5, Unit.PX);
|
||||
mapboxLogo.getStyle().setWidth(126, Unit.PX);
|
||||
mapboxLogo.getStyle().setHeight(40, Unit.PX);
|
||||
mapboxLogo.getStyle().setDisplay(Display.BLOCK);
|
||||
mapboxLogo.getStyle().setOverflow(Overflow.HIDDEN);
|
||||
|
||||
mapboxLogo.getStyle().setBackgroundImage("url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIIAAAAoCAMAAAAFWtJHAAAAwFBMVEUAAAAAAAAAAABtbW0AAAAAAAAAAAAAAAAAAAAAAAClpaUAAADp6ekAAAD5+fna2toAAAAMDAzv7+/Nzc0AAAA2Njb8/Pz9/f3T09MAAAAAAAD7+/sAAAArKyuxsbH39/fs7OwbGxuIiIjz8/N8fHyenp7u7u74+PgAAAC8vLxWVlbx8fF1dXXl5eVcXFyUlJTQ0NDFxcVCQkLAwMC4uLj19fXo6OjW1tarq6ve3t77+/vi4uL6+vrKysrNzc3///8w7gSSAAAAP3RSTlMAOQNdPSYBPywKexLLGPCxNEHXnzFL+v2nGwf1IEiE6dBFad9jd9PuLo1V2mDDV3Cjl06SiuXIq4C3973ym6BQMVUPAAAEXElEQVR4Ae2WCVP6OBiH05L0l1IqrVbkKHJ54I0oHn+PfP9vtUle0z/YdhbH2XVnd58ZnRJIeHiPJOx//mH4vQSAN+8FjAhFxgHIaPvJeZ99hxwEElon5iAQbj85Y98g8ODwjEOMAvGFyeE3FEKgodTBqj0BJGN9DhyNd5Ta3ean9QEopfaA+LsKhnEKRExqg4FSP6Og7oEkAjBWnxSCgBX4xF+kcLoPcOBQrSv0e5kH7s1j37jECQieCTPiFGxL5VHw2zQWCeeJiPt6kjRQw0XSkIdVChf67xGa4alSnZlT6HEQ8CK9ANbhvXUF9xlDkBfTuHDWScgC9+z5FQpPI12TlwC6+sV7ixR8CUMKiwjm2GQeOQWHMGuHGdbnObJAwCEqFJpNU5H6uaPUaEIKiQfg+PHk1+u4OwW9PlWW2ctbA4BHCtp+cNK+H8Jos4gDmC5ar4Nx9waaG/2B13NgDqS7+vm2RgEtEws82P+kwIHhs/pgkQKcFIhfd7CogtGNjYMHTLpurD0ERbYFw4JaD3GlQuNAL/JEsSAF4HqlCnaHACk4WhOn4OgCkMD5hSpYNYDJTD8Y46n+jsE1kPhVCuR6QBXhFK7MUOu9O6b1SWF3b+/9ZVWMGOlu93E8UDaAhgc7bfH+0DHqKXCkHzoNDFfU+zxiVQrUC9QXTuHYtKpN59OA3IxCG4b7jh6ZFuVockaNTW09mkJzOaPU49a6mE9cAchZpQJNpUWcwgV9r6FJswsFKrITp2B5pMBMdnS0z2HZNy2+BNKxSZxZfglkrFYBJxQnpzA5sN/HheR2aFQoZBLAi149dQoyAYYjW0hHlHguBAdMcR0DuDZ5omevX6+AI8qcU7ikKT3GBHCnXwydgmCC0tRwCnGQ2Wp6Be71yNIWfQSkOl9vAI1SBCNWrwC01RROgX7BuT2HI4r7tFAw086p/NwZEdOEa7R1uAFuNmQPuKAEAjYNQ0CyeoUEWHYBnpQVQgpvc0Ph+gsKlAnKg1+vEHsw5LKciLKCAJobiWBzYFGbCKpHqkZZrxBFHEASyFI59vJPCskcwNVGOWZAOqsrR+pKbaNeAMT1CixMEtlnsqopNxUMzVJT3tY35aXZm6a6Y9QhwMN6BUJWbE1lhbMO1WehkO7poO0sK7em9MJGxp1XSbC1gtugzzSLQmGsX7VntJGSwsPZ2d2z3bIPKzdoOp3Wzqt8G4XyMVUoFIxLx1S7+piaHtCvR3FeRVsq0GFdp9C5TbGpcNqsPqyHKxcfd14h21KhuLKUFU4f3osrC7F6uV3WXFnadL7wyAPeKDXw2RoJCO5GY4DouYvb/gepVXheLoewzPseQG9N/vzilrMIjoStE3++zvle4eSurw7XEe76ynI4aq+v7lEyt1x5awiFlFLQbHKIpabnM3eJLym4Szzzc/du7SU+zOXv9UNpECH7IoH/gecURPlN9vdQpeD47yhIFNX0U0QgvID9nENm+yxk/xb+AGAjNfRZuk9qAAAAAElFTkSuQmCC)");
|
||||
|
||||
controlOptions.setElement(mapboxLogo);
|
||||
|
||||
return new Control(controlOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a test polygon geometry (triangle).
|
||||
*
|
||||
* @return test polygon geometry (EPSG:3857)
|
||||
*/
|
||||
public static Polygon createTestPolygon() {
|
||||
|
||||
Coordinate[][] coordinates = new Coordinate[1][4];
|
||||
|
||||
Coordinate point1 = new Coordinate(13.36, 52.53);
|
||||
Coordinate point2 = new Coordinate(13.36, 52.51);
|
||||
Coordinate point3 = new Coordinate(13.37, 52.52);
|
||||
Coordinate point4 = new Coordinate(13.36, 52.53);
|
||||
|
||||
coordinates[0][0] = point1;
|
||||
coordinates[0][1] = point2;
|
||||
coordinates[0][2] = point3;
|
||||
coordinates[0][3] = point4;
|
||||
|
||||
Coordinate[][] tranformedCoordinates = new Coordinate[coordinates.length][];
|
||||
|
||||
tranformedCoordinates[0] = OLUtil.transform(coordinates[0], GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
|
||||
return OLFactory.createPolygon(tranformedCoordinates);
|
||||
|
||||
}
|
||||
|
||||
public static Base createOsmLayer() {
|
||||
XyzOptions osmSourceOptions = OLFactory.createOptions();
|
||||
|
||||
Osm osmSource = new Osm(osmSourceOptions);
|
||||
LayerOptions osmLayerOptions = OLFactory.createOptions();
|
||||
osmLayerOptions.setSource(osmSource);
|
||||
|
||||
return new Tile(osmLayerOptions);
|
||||
}
|
||||
|
||||
}
|
|
@ -7,7 +7,6 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE;
|
|||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
||||
import ol.Collection;
|
||||
import ol.Coordinate;
|
||||
import ol.Feature;
|
||||
import ol.Map;
|
||||
|
@ -21,7 +20,6 @@ import ol.event.EventListener;
|
|||
import ol.geom.Point;
|
||||
import ol.interaction.KeyboardPan;
|
||||
import ol.interaction.KeyboardZoom;
|
||||
import ol.layer.Base;
|
||||
import ol.layer.Image;
|
||||
import ol.layer.LayerOptions;
|
||||
import ol.layer.Tile;
|
||||
|
@ -305,17 +303,5 @@ import ol.style.TextOptions;
|
|||
return this.map.getView().calculateExtent(map.getSize());
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform.
|
||||
*
|
||||
* @param centerCoordinate the center coordinate
|
||||
* @param source the source
|
||||
* @param target the target
|
||||
* @return the coordinate
|
||||
*/
|
||||
public Coordinate transform (Coordinate centerCoordinate, String source, String target){
|
||||
return Projection.transform(centerCoordinate, source, target);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
|
||||
|
||||
import ol.Collection;
|
||||
import ol.Coordinate;
|
||||
import ol.control.Control;
|
||||
import ol.control.FullScreen;
|
||||
import ol.control.MousePosition;
|
||||
import ol.control.ZoomSlider;
|
||||
import ol.proj.Projection;
|
||||
|
||||
|
||||
/**
|
||||
* The Class MapUtils.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Nov 12, 2020
|
||||
*/
|
||||
public final class MapUtils {
|
||||
|
||||
|
||||
/**
|
||||
* Creates some default controls and adds it to the collection.
|
||||
*
|
||||
* @param controls collection with controls
|
||||
*/
|
||||
public static void addDefaultControls(final Collection<Control> controls) {
|
||||
|
||||
controls.push(new FullScreen());
|
||||
controls.push(new ZoomSlider());
|
||||
MousePosition mousePosition = new MousePosition();
|
||||
mousePosition.setCoordinateFormat(Coordinate.createStringXY(5));
|
||||
controls.push(mousePosition);
|
||||
//controls.push(new ZoomToExtent());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform coordiante.
|
||||
*
|
||||
* @param centerCoordinate the center coordinate
|
||||
* @param source the source
|
||||
* @param target the target
|
||||
* @return the coordinate
|
||||
*/
|
||||
public static Coordinate transformCoordiante(Coordinate centerCoordinate, String source, String target) {
|
||||
return Projection.transform(centerCoordinate, source, target);
|
||||
}
|
||||
}
|
|
@ -115,7 +115,7 @@ public class OpenLayerOSM {
|
|||
|
||||
//EPSG_4326_TO_ITALY
|
||||
Coordinate centerCoordinate = OLFactory.createCoordinate(12.45, 42.98);
|
||||
Coordinate transformedCenterCoordinate = Projection.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
|
||||
Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
|
||||
|
||||
view.setCenter(transformedCenterCoordinate);
|
||||
view.setZoom(5);
|
||||
|
@ -132,7 +132,7 @@ public class OpenLayerOSM {
|
|||
|
||||
// add some controls
|
||||
map.addControl(OLFactory.createScaleLine());
|
||||
DemoUtils.addDefaultControls(map.getControls());
|
||||
MapUtils.addDefaultControls(map.getControls());
|
||||
|
||||
Attribution attribution = new Attribution();
|
||||
attribution.setCollapsed(true);
|
||||
|
@ -182,6 +182,8 @@ public class OpenLayerOSM {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void showPopup(String html, Coordinate coordinate) {
|
||||
if(popupOverlay==null) {
|
||||
Element elPopup = DOM.getElementById("popup");
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client.ui.map;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.gis.LightOpenLayerOSM;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.core.client.Scheduler;
|
||||
|
@ -15,8 +18,7 @@ import com.google.gwt.user.client.ui.HorizontalPanel;
|
|||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
import ol.Coordinate;
|
||||
import ol.Extent;
|
||||
import ol.layer.Image;
|
||||
import ol.OLFactory;
|
||||
|
||||
/**
|
||||
* The Class MapView.
|
||||
|
@ -46,26 +48,6 @@ import ol.layer.Image;
|
|||
HorizontalPanel coordinatePanel;
|
||||
|
||||
private LightOpenLayerOSM olsm;
|
||||
|
||||
// public MapView(Double x, Double y, boolean showCoordinate) {
|
||||
// initWidget(uiBinder.createAndBindUi(this));
|
||||
// String theMapId = "map"+Random.nextInt();
|
||||
// theMap.getElement().setId(theMapId);
|
||||
// //theMap.setSize("300px", "300px");
|
||||
//
|
||||
// Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
//
|
||||
// @Override
|
||||
// public void execute() {
|
||||
// olsm = new LightOpenLayerOSM(theMapId);
|
||||
// if(x!=null && y!=null) {
|
||||
// Coordinate point = new Coordinate(x, y);
|
||||
// addPoint(point);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
/**
|
||||
* Instantiates a new map view.
|
||||
|
@ -108,32 +90,39 @@ import ol.layer.Image;
|
|||
* Adds the WMS layer.
|
||||
*
|
||||
* @param mapServerHost the map server host
|
||||
* @param layerName the layer name
|
||||
* @param layerName the layer name
|
||||
* @param bbox the bbox
|
||||
*/
|
||||
public void addWMSLayer(String mapServerHost, String layerName){
|
||||
public void addWMSLayer(String mapServerHost, String layerName, BoundsMap bbox) {
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
olsm.addWMSLayer(mapServerHost, layerName);
|
||||
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
olsm.addWMSLayer(mapServerHost, layerName);
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
Extent ext = olsm.getFirstLayer().getExtent();
|
||||
GWT.log("WMS layer extent: "+ext);
|
||||
// if(ext!=null) {
|
||||
// ExtentWrapped ew = new ExtentWrapped(ext.getLowerLeftX(), ext.getLowerLeftY(), ext.getUpperRightX(), ext.getUpperRightY());
|
||||
// Coordinate center = ew.getCenter();
|
||||
// olsm.getMap().getView().setCenter(center);
|
||||
// }
|
||||
}
|
||||
|
||||
});
|
||||
if (bbox != null) {
|
||||
|
||||
Coordinate lower = OLFactory.createCoordinate(bbox.getLowerLeftX(), bbox.getLowerLeftY());
|
||||
Coordinate lowerCoord = MapUtils.transformCoordiante(lower, GeoportalDataViewerConstants.EPSG_4326,
|
||||
GeoportalDataViewerConstants.EPSG_3857);
|
||||
|
||||
Coordinate upper = OLFactory.createCoordinate(bbox.getUpperRightX(), bbox.getUpperRightY());
|
||||
Coordinate upperCoord = MapUtils.transformCoordiante(upper, GeoportalDataViewerConstants.EPSG_4326,
|
||||
GeoportalDataViewerConstants.EPSG_3857);
|
||||
|
||||
ExtentWrapped ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(),
|
||||
upperCoord.getY());
|
||||
Coordinate center = ew.getCenter();
|
||||
GWT.log("center: "+center);
|
||||
Coordinate invertCoordinate = new Coordinate(center.getY(), center.getX());
|
||||
// Size size = new Size(300, 300);
|
||||
//olsm.getMap().getView().setCenter(invertCoordinate);
|
||||
olsm.getMap().getView().fit(ew);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
xmlns:g="urn:import:com.google.gwt.user.client.ui">
|
||||
<ui:style>
|
||||
.internalMap {
|
||||
width: 400px;
|
||||
height: 400px;
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
}
|
||||
</ui:style>
|
||||
<g:HTMLPanel>
|
||||
|
|
|
@ -42,7 +42,7 @@ public class LayerConcessioneView extends Composite {
|
|||
MapView mapView = new MapView();
|
||||
mapViewPanel.add(mapView);
|
||||
String mapServerHost = layerDV.getWmsLink().contains("?")? layerDV.getWmsLink().substring(0,layerDV.getWmsLink().indexOf("?")):layerDV.getWmsLink();
|
||||
mapView.addWMSLayer(mapServerHost, layerDV.getLayerName());
|
||||
mapView.addWMSLayer(mapServerHost, layerDV.getLayerName(), layerDV.getBbox());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,18 @@
|
|||
.important {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.style-layer {
|
||||
display: inline-block;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.055);
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
width: 673px;
|
||||
}
|
||||
</ui:style>
|
||||
<g:HTMLPanel>
|
||||
<g:HTMLPanel addStyleNames="{style.style-layer}">
|
||||
<g:HorizontalPanel>
|
||||
<g:HTMLPanel ui:field="layerConcessionePanel"></g:HTMLPanel>
|
||||
<g:HTMLPanel ui:field="mapViewPanel">
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerSer
|
|||
import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
||||
|
@ -152,6 +153,33 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the parameters from URL.
|
||||
*
|
||||
* @param theURL the the URL
|
||||
* @param parameters the parameters
|
||||
* @return a map with couple (paramKey, paramValue)
|
||||
*/
|
||||
|
||||
public Map<String, String> getParametersFromURL(String theURL, List<String> parameters) {
|
||||
|
||||
if (theURL == null)
|
||||
return null;
|
||||
|
||||
if (parameters == null || parameters.size() == 0)
|
||||
return null;
|
||||
|
||||
Map<String, String> hashParameters = new HashMap<String, String>(parameters.size());
|
||||
for (String paramKey : parameters) {
|
||||
String paramValue = URLParserUtil.extractValueOfParameterFromURL(paramKey, theURL);
|
||||
hashParameters.put(paramKey, paramValue);
|
||||
}
|
||||
|
||||
return hashParameters;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the my login.
|
||||
*
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.gcube.application.geoportal.model.concessioni.RelazioneScavo;
|
|||
import org.gcube.application.geoportal.model.content.PersistedContent;
|
||||
import org.gcube.application.geoportal.model.content.UploadedImage;
|
||||
import org.gcube.application.geoportal.model.content.WorkspaceContent;
|
||||
import org.gcube.application.geoportal.model.gis.BBOX;
|
||||
|
||||
public class TestModel {
|
||||
|
||||
|
@ -111,6 +112,8 @@ public class TestModel {
|
|||
pianta.setLayerName("gna_conc_12:pos");
|
||||
pianta.setWmsLink(
|
||||
"https://geoserver1.dev.d4science.org/geoserver/gna_conc_12/wms?service=WMS&version=1.1.0&request=GetMap&layers=gna_conc_12:pos&styles=&bbox=8.62091913167495,40.62975046683799,8.621178639172953,40.630257904721645&width=392&height=768&srs=EPSG:4326&format=application/openlayers#toggle");
|
||||
|
||||
pianta.setBbox(new BBOX(40.630257904721645,8.621178639172953,40.62975046683799,8.62091913167495));
|
||||
piante.add(pianta);
|
||||
}
|
||||
concessione.setPianteFineScavo(piante);
|
||||
|
|
|
@ -3,20 +3,21 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.geoportaldataviewer.server.gis;
|
||||
|
||||
|
||||
/**
|
||||
* The Class GeoserverBaseUri.
|
||||
* The Class WebMapServerHost.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Jan 28, 2016
|
||||
*
|
||||
* Nov 12, 2020
|
||||
*/
|
||||
public class WebMapServerHost {
|
||||
|
||||
private String host = "";
|
||||
private String scope = "";
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new geoserver base uri.
|
||||
* Instantiates a new web map server host.
|
||||
*/
|
||||
public WebMapServerHost() {
|
||||
}
|
||||
|
@ -34,6 +35,8 @@ public class WebMapServerHost {
|
|||
|
||||
|
||||
/**
|
||||
* Gets the host.
|
||||
*
|
||||
* @return the host
|
||||
*/
|
||||
public String getHost() {
|
||||
|
@ -43,6 +46,8 @@ public class WebMapServerHost {
|
|||
|
||||
|
||||
/**
|
||||
* Gets the scope.
|
||||
*
|
||||
* @return the scope
|
||||
*/
|
||||
public String getScope() {
|
||||
|
@ -52,6 +57,8 @@ public class WebMapServerHost {
|
|||
|
||||
|
||||
/**
|
||||
* Sets the host.
|
||||
*
|
||||
* @param host the host to set
|
||||
*/
|
||||
public void setHost(String host) {
|
||||
|
@ -61,6 +68,8 @@ public class WebMapServerHost {
|
|||
|
||||
|
||||
/**
|
||||
* Sets the scope.
|
||||
*
|
||||
* @param scope the scope to set
|
||||
*/
|
||||
public void setScope(String scope) {
|
||||
|
@ -68,6 +77,11 @@ public class WebMapServerHost {
|
|||
this.scope = scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
|
|
|
@ -1,65 +1,48 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.server.util;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The Class URLUtil.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Oct 29, 2020
|
||||
* Oct 29, 2020
|
||||
*/
|
||||
public class URLParserUtil {
|
||||
|
||||
/**
|
||||
* Gets the value of parameter.
|
||||
*
|
||||
* @param paramName the param name
|
||||
* @param url the url
|
||||
* @return the value of parameter
|
||||
*/
|
||||
public static String getValueOfParameter(String paramName, String url) {
|
||||
// logger.trace("finding: "+wmsParam +" into "+url);
|
||||
int index = url.toLowerCase().indexOf(paramName.toLowerCase()+"="); //ADDING CHAR "=" IN TAIL TO BE SECURE IT IS A PARAMETER
|
||||
// logger.trace("start index of "+wmsParam+ " is: "+index);
|
||||
String value = "";
|
||||
if(index > -1){
|
||||
int start = index + paramName.length()+1; //add +1 for char '='
|
||||
String sub = url.substring(start, url.length());
|
||||
int indexOfSeparator = sub.indexOf("&");
|
||||
int end = indexOfSeparator!=-1?indexOfSeparator:sub.length();
|
||||
value = sub.substring(0, end);
|
||||
}else
|
||||
return null;
|
||||
|
||||
// logger.trace("return value: "+value);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds the parameter to query string.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @param prefixAmpersand the prefix ampersand
|
||||
* @param suffixAmpersand the suffix ampersand
|
||||
* @return the string
|
||||
*/
|
||||
public static String addParameterToQueryString(String key, String value, boolean prefixAmpersand, boolean suffixAmpersand) {
|
||||
|
||||
public static String addParameterToQueryString(String key, String value, boolean prefixAmpersand,
|
||||
boolean suffixAmpersand) {
|
||||
|
||||
String queryParameter = "";
|
||||
|
||||
if(prefixAmpersand)
|
||||
queryParameter+="&";
|
||||
|
||||
queryParameter+=key+"="+value;
|
||||
|
||||
if(suffixAmpersand)
|
||||
queryParameter+="&";
|
||||
|
||||
|
||||
if (prefixAmpersand)
|
||||
queryParameter += "&";
|
||||
|
||||
queryParameter += key + "=" + value;
|
||||
|
||||
if (suffixAmpersand)
|
||||
queryParameter += "&";
|
||||
|
||||
return queryParameter;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract value of parameter from URL.
|
||||
*
|
||||
|
@ -68,7 +51,8 @@ public class URLParserUtil {
|
|||
* @return the string
|
||||
*/
|
||||
public static String extractValueOfParameterFromURL(String paramName, String url) {
|
||||
int index = url.toLowerCase().indexOf(paramName.toLowerCase() + "="); // ADDING CHAR "=" IN TAIL TO BE SURE THAT IT
|
||||
int index = url.toLowerCase().indexOf(paramName.toLowerCase() + "="); // ADDING CHAR "=" IN TAIL TO BE SURE THAT
|
||||
// IT
|
||||
// IS A PARAMETER
|
||||
String value = "";
|
||||
if (index > -1) {
|
||||
|
@ -84,5 +68,29 @@ public class URLParserUtil {
|
|||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Split query.
|
||||
*
|
||||
* @param url the url
|
||||
* @return the map
|
||||
* @throws UnsupportedEncodingException the unsupported encoding exception
|
||||
*/
|
||||
public static Map<String, List<String>> splitQuery(URL url) throws UnsupportedEncodingException {
|
||||
final Map<String, List<String>> query_pairs = new LinkedHashMap<String, List<String>>();
|
||||
final String[] pairs = url.getQuery().split("&");
|
||||
for (String pair : pairs) {
|
||||
final int idx = pair.indexOf("=");
|
||||
final String key = idx > 0 ? URLDecoder.decode(pair.substring(0, idx), "UTF-8") : pair;
|
||||
if (!query_pairs.containsKey(key)) {
|
||||
query_pairs.put(key, new LinkedList<String>());
|
||||
}
|
||||
final String value = idx > 0 && pair.length() > idx + 1
|
||||
? URLDecoder.decode(pair.substring(idx + 1), "UTF-8")
|
||||
: null;
|
||||
query_pairs.get(key).add(value);
|
||||
}
|
||||
return query_pairs;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue