fixed css and center to extent by reading BBOX from wmsLink
This commit is contained in:
parent
42cdd1f7aa
commit
f1f6c42b08
|
@ -2,6 +2,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.gis;
|
|||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE;
|
||||
|
||||
|
@ -173,13 +174,18 @@ import ol.style.TextOptions;
|
|||
*
|
||||
* @param mapServerHost the map server host
|
||||
* @param layerName the layer name
|
||||
* @param bbox
|
||||
* @return the image
|
||||
*/
|
||||
public Image addWMSLayer(String mapServerHost, String layerName) {
|
||||
public Image addWMSLayer(String mapServerHost, String layerName, BoundsMap bbox) {
|
||||
GWT.log("Adding wmsLayer with mapServerHost: "+mapServerHost+", layerName: "+layerName);
|
||||
|
||||
ImageWmsParams imageWMSParams = OLFactory.createOptions();
|
||||
imageWMSParams.setLayers(layerName);
|
||||
//imageWMSParams.setSize(new Size(400,400));
|
||||
//imageWMSParams.setVersion("1.1.0");
|
||||
// if(bbox!=null)
|
||||
// imageWMSParams.set("BBOX", bbox.getLowerLeftX()+","+bbox.getLowerLeftY()+","+bbox.getUpperRightX()+","+bbox.getUpperRightY());
|
||||
|
||||
ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
|
||||
imageWMSOptions.setUrl(mapServerHost);
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.github.gwtbootstrap.client.ui.Paragraph;
|
|||
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
||||
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Style.TextAlign;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
|
@ -40,6 +41,9 @@ public class ImageView extends Composite {
|
|||
@UiField
|
||||
Paragraph paragraph1;
|
||||
|
||||
@UiField
|
||||
Paragraph paragraph2;
|
||||
|
||||
@UiField
|
||||
Button openImage;
|
||||
|
||||
|
@ -54,6 +58,12 @@ public class ImageView extends Composite {
|
|||
|
||||
heading.setText(imageDV.getTitolo());
|
||||
paragraph1.setText(imageDV.getDidascalia());
|
||||
paragraph1.getElement().getStyle().setTextAlign(TextAlign.LEFT);
|
||||
|
||||
if(!showView && imageDV.getLicenseID()!=null) {
|
||||
paragraph2.setVisible(true);
|
||||
paragraph2.setText("ID Licenza: "+imageDV.getLicenseID());
|
||||
}
|
||||
|
||||
if(imageDV.getListWsContent()!=null && imageDV.getListWsContent().size()>0) {
|
||||
latest = imageDV.getListWsContent().get(imageDV.getListWsContent().size()-1);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<b:Heading size="4" ui:field="heading"></b:Heading>
|
||||
<b:Paragraph ui:field="paragraph1">
|
||||
</b:Paragraph>
|
||||
<b:Paragraph ui:field="paragraph2">
|
||||
<b:Paragraph ui:field="paragraph2" visible="false">
|
||||
</b:Paragraph>
|
||||
</b:Caption>
|
||||
</g:HTMLPanel>
|
||||
|
|
|
@ -45,7 +45,7 @@ public class ThumbnailImageView extends Composite {
|
|||
initWidget(uiBinder.createAndBindUi(this));
|
||||
|
||||
ImageView imageView = new ImageView(imageDV, showView, showOpen);
|
||||
String title = StringUtil.ellipsize(imageDV.getTitolo(), 20);
|
||||
String title = StringUtil.ellipsize(imageDV.getTitolo(), 25);
|
||||
imageView.setHeading(title);
|
||||
|
||||
String didascalia = StringUtil.ellipsize(imageDV.getDidascalia(), 50);
|
||||
|
|
|
@ -128,10 +128,12 @@ import ol.OLFactory;
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
olsm.addWMSLayer(mapServerHost, layerName);
|
||||
|
||||
if (bbox != null) {
|
||||
|
||||
ExtentWrapped ew = null;
|
||||
BoundsMap theBBOX = bbox;
|
||||
|
||||
if (bbox != null) {
|
||||
|
||||
|
||||
Coordinate lower = OLFactory.createCoordinate(bbox.getLowerLeftX(), bbox.getLowerLeftY());
|
||||
Coordinate lowerCoord = MapUtils.transformCoordiante(lower, GeoportalDataViewerConstants.EPSG_4326,
|
||||
|
@ -141,12 +143,14 @@ import ol.OLFactory;
|
|||
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);
|
||||
ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY());
|
||||
theBBOX = new BoundsMap(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY(), null);
|
||||
}
|
||||
|
||||
olsm.addWMSLayer(mapServerHost, layerName, theBBOX);
|
||||
|
||||
if (ew != null) {
|
||||
|
||||
olsm.getMap().getView().fit(ew);
|
||||
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class RelazioneScavoView extends Composite {
|
|||
abstractParagraph.setText(relazioneScavoDV.getAbstractSection());
|
||||
|
||||
//customTable.addNextKeyValue("Created", relazioneScavoDV.getCreationTime());
|
||||
customTable.addNextKeyValue("ID Licenza", relazioneScavoDV.getLicenseID());
|
||||
//customTable.addNextKeyValue("ID Licenza", relazioneScavoDV.getLicenseID());
|
||||
customTable.addNextKeyValues("Responsabili", relazioneScavoDV.getResponsabili(), GeoportalDataViewerConstants.NEW_LINE_BR);
|
||||
relazioneScavoPanel.add(customTable);
|
||||
}
|
||||
|
|
|
@ -306,10 +306,16 @@ public class ConvertToDataViewModel {
|
|||
|
||||
String wmsLink = layerConcessione.getWmsLink();
|
||||
String layerName = null;
|
||||
BoundsMap bounds = null;
|
||||
|
||||
//reading layer name from wmsLink
|
||||
//string bbox
|
||||
if(wmsLink!=null) {
|
||||
layerName = URLParserUtil.extractValueOfParameterFromURL("layers", wmsLink);
|
||||
String bbox = URLParserUtil.extractValueOfParameterFromURL("bbox", wmsLink);
|
||||
String wmsVersion = URLParserUtil.extractValueOfParameterFromURL("version", wmsLink);
|
||||
bounds = toBoundMap(wmsVersion, bbox, ",");
|
||||
LOG.debug("Built bounds from wmsLInk: "+bounds);
|
||||
}
|
||||
|
||||
if(layerName!=null)
|
||||
|
@ -322,7 +328,10 @@ public class ConvertToDataViewModel {
|
|||
theLayerConessione.setLayerID(layerConcessione.getLayerID());
|
||||
theLayerConessione.setLayerUUID(layerConcessione.getLayerUUID());
|
||||
theLayerConessione.setAuthors(layerConcessione.getAuthors());
|
||||
BoundsMap bounds = toBoundMap(layerConcessione.getBbox());
|
||||
|
||||
if(bounds==null)
|
||||
bounds = toBoundMap(layerConcessione.getBbox());
|
||||
|
||||
theLayerConessione.setBbox(bounds);
|
||||
theLayerConessione.setCreationTime(toDateFormatString(layerConcessione.getCreationTime()));
|
||||
theLayerConessione.setId(layerConcessione.getId());
|
||||
|
@ -378,5 +387,50 @@ public class ConvertToDataViewModel {
|
|||
|
||||
return new BoundsMap(bbox.getMinLong(), bbox.getMinLat(), bbox.getMaxLong(), bbox.getMaxLat(), null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To bound map.
|
||||
*
|
||||
* @param bbox the bbox
|
||||
* @return the bounds map
|
||||
*/
|
||||
public static BoundsMap toBoundMap(String wmsVersion, String bbox, String separator) {
|
||||
|
||||
if (bbox == null)
|
||||
return null;
|
||||
|
||||
if(wmsVersion==null)
|
||||
return null;
|
||||
|
||||
if(separator==null)
|
||||
separator = ",";
|
||||
|
||||
try {
|
||||
|
||||
String[] bboxArr = bbox.split(separator);
|
||||
|
||||
if(wmsVersion.startsWith("1.3")) {
|
||||
//is 1.3.x
|
||||
return new BoundsMap(toDouble(bboxArr[1]), toDouble(bboxArr[0]), toDouble(bboxArr[3]), toDouble(bboxArr[2]), wmsVersion);
|
||||
}else {
|
||||
//should be 1.1.X
|
||||
return new BoundsMap(toDouble(bboxArr[0]), toDouble(bboxArr[1]), toDouble(bboxArr[2]), toDouble(bboxArr[3]), wmsVersion);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
LOG.warn("Error on creating Bounds for wmsVersion "+wmsVersion+" and bbox "+bbox+" : ",e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Double toDouble(String value) {
|
||||
try {
|
||||
return Double.parseDouble(value);
|
||||
}catch (Exception e) {
|
||||
LOG.warn("Error on parsing "+value+" as double: ",e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue