fixed css and center to extent by reading BBOX from wmsLink

This commit is contained in:
Francesco Mangiacrapa 2020-12-09 12:45:30 +01:00
parent 42cdd1f7aa
commit f1f6c42b08
7 changed files with 88 additions and 14 deletions

View File

@ -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.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images; 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;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE; 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 mapServerHost the map server host
* @param layerName the layer name * @param layerName the layer name
* @param bbox
* @return the image * @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); GWT.log("Adding wmsLayer with mapServerHost: "+mapServerHost+", layerName: "+layerName);
ImageWmsParams imageWMSParams = OLFactory.createOptions(); ImageWmsParams imageWMSParams = OLFactory.createOptions();
imageWMSParams.setLayers(layerName); 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 imageWMSOptions = OLFactory.createOptions();
imageWMSOptions.setUrl(mapServerHost); imageWMSOptions.setUrl(mapServerHost);

View File

@ -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.ButtonType;
import com.github.gwtbootstrap.client.ui.constants.IconType; import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT; 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.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiBinder;
@ -40,6 +41,9 @@ public class ImageView extends Composite {
@UiField @UiField
Paragraph paragraph1; Paragraph paragraph1;
@UiField
Paragraph paragraph2;
@UiField @UiField
Button openImage; Button openImage;
@ -54,6 +58,12 @@ public class ImageView extends Composite {
heading.setText(imageDV.getTitolo()); heading.setText(imageDV.getTitolo());
paragraph1.setText(imageDV.getDidascalia()); 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) { if(imageDV.getListWsContent()!=null && imageDV.getListWsContent().size()>0) {
latest = imageDV.getListWsContent().get(imageDV.getListWsContent().size()-1); latest = imageDV.getListWsContent().get(imageDV.getListWsContent().size()-1);

View File

@ -21,7 +21,7 @@
<b:Heading size="4" ui:field="heading"></b:Heading> <b:Heading size="4" ui:field="heading"></b:Heading>
<b:Paragraph ui:field="paragraph1"> <b:Paragraph ui:field="paragraph1">
</b:Paragraph> </b:Paragraph>
<b:Paragraph ui:field="paragraph2"> <b:Paragraph ui:field="paragraph2" visible="false">
</b:Paragraph> </b:Paragraph>
</b:Caption> </b:Caption>
</g:HTMLPanel> </g:HTMLPanel>

View File

@ -45,7 +45,7 @@ public class ThumbnailImageView extends Composite {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
ImageView imageView = new ImageView(imageDV, showView, showOpen); ImageView imageView = new ImageView(imageDV, showView, showOpen);
String title = StringUtil.ellipsize(imageDV.getTitolo(), 20); String title = StringUtil.ellipsize(imageDV.getTitolo(), 25);
imageView.setHeading(title); imageView.setHeading(title);
String didascalia = StringUtil.ellipsize(imageDV.getDidascalia(), 50); String didascalia = StringUtil.ellipsize(imageDV.getDidascalia(), 50);

View File

@ -128,10 +128,12 @@ import ol.OLFactory;
@Override @Override
public void execute() { 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 lower = OLFactory.createCoordinate(bbox.getLowerLeftX(), bbox.getLowerLeftY());
Coordinate lowerCoord = MapUtils.transformCoordiante(lower, GeoportalDataViewerConstants.EPSG_4326, Coordinate lowerCoord = MapUtils.transformCoordiante(lower, GeoportalDataViewerConstants.EPSG_4326,
@ -141,12 +143,14 @@ import ol.OLFactory;
Coordinate upperCoord = MapUtils.transformCoordiante(upper, GeoportalDataViewerConstants.EPSG_4326, Coordinate upperCoord = MapUtils.transformCoordiante(upper, GeoportalDataViewerConstants.EPSG_4326,
GeoportalDataViewerConstants.EPSG_3857); GeoportalDataViewerConstants.EPSG_3857);
ExtentWrapped ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY()); ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY());
//Coordinate center = ew.getCenter(); theBBOX = new BoundsMap(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY(), null);
//GWT.log("center: "+center); }
//Coordinate invertCoordinate = new Coordinate(center.getY(), center.getX());
// Size size = new Size(300, 300); olsm.addWMSLayer(mapServerHost, layerName, theBBOX);
//olsm.getMap().getView().setCenter(invertCoordinate);
if (ew != null) {
olsm.getMap().getView().fit(ew); olsm.getMap().getView().fit(ew);
} }

View File

@ -35,7 +35,7 @@ public class RelazioneScavoView extends Composite {
abstractParagraph.setText(relazioneScavoDV.getAbstractSection()); abstractParagraph.setText(relazioneScavoDV.getAbstractSection());
//customTable.addNextKeyValue("Created", relazioneScavoDV.getCreationTime()); //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); customTable.addNextKeyValues("Responsabili", relazioneScavoDV.getResponsabili(), GeoportalDataViewerConstants.NEW_LINE_BR);
relazioneScavoPanel.add(customTable); relazioneScavoPanel.add(customTable);
} }

View File

@ -306,10 +306,16 @@ public class ConvertToDataViewModel {
String wmsLink = layerConcessione.getWmsLink(); String wmsLink = layerConcessione.getWmsLink();
String layerName = null; String layerName = null;
BoundsMap bounds = null;
//reading layer name from wmsLink //reading layer name from wmsLink
//string bbox
if(wmsLink!=null) { if(wmsLink!=null) {
layerName = URLParserUtil.extractValueOfParameterFromURL("layers", wmsLink); 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) if(layerName!=null)
@ -322,7 +328,10 @@ public class ConvertToDataViewModel {
theLayerConessione.setLayerID(layerConcessione.getLayerID()); theLayerConessione.setLayerID(layerConcessione.getLayerID());
theLayerConessione.setLayerUUID(layerConcessione.getLayerUUID()); theLayerConessione.setLayerUUID(layerConcessione.getLayerUUID());
theLayerConessione.setAuthors(layerConcessione.getAuthors()); theLayerConessione.setAuthors(layerConcessione.getAuthors());
BoundsMap bounds = toBoundMap(layerConcessione.getBbox());
if(bounds==null)
bounds = toBoundMap(layerConcessione.getBbox());
theLayerConessione.setBbox(bounds); theLayerConessione.setBbox(bounds);
theLayerConessione.setCreationTime(toDateFormatString(layerConcessione.getCreationTime())); theLayerConessione.setCreationTime(toDateFormatString(layerConcessione.getCreationTime()));
theLayerConessione.setId(layerConcessione.getId()); theLayerConessione.setId(layerConcessione.getId());
@ -378,5 +387,50 @@ public class ConvertToDataViewModel {
return new BoundsMap(bbox.getMinLong(), bbox.getMinLat(), bbox.getMaxLong(), bbox.getMaxLat(), null); 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;
}
}
} }