|
|
|
@ -44,7 +44,7 @@ import ol.Coordinate;
|
|
|
|
|
*
|
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
|
|
|
*
|
|
|
|
|
* Oct 27, 2020
|
|
|
|
|
* Oct 27, 2020
|
|
|
|
|
*/
|
|
|
|
|
public class GeoportalDataViewer implements EntryPoint {
|
|
|
|
|
|
|
|
|
@ -52,37 +52,36 @@ public class GeoportalDataViewer implements EntryPoint {
|
|
|
|
|
public final static String APP_DIV = "geoportal-data-viewer";
|
|
|
|
|
|
|
|
|
|
/** The ol map. */
|
|
|
|
|
//private OpenLayerOSM olMap = null;
|
|
|
|
|
// private OpenLayerOSM olMap = null;
|
|
|
|
|
|
|
|
|
|
/** The main panel. */
|
|
|
|
|
private GeonaDataViewMainPanel mainPanel;
|
|
|
|
|
|
|
|
|
|
/** The param wms request. */
|
|
|
|
|
private String paramWmsRequest;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** The param UUID. */
|
|
|
|
|
//private String paramUUID;
|
|
|
|
|
|
|
|
|
|
// private String paramUUID;
|
|
|
|
|
|
|
|
|
|
private String paramGeonaItemType;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** The param layer title. */
|
|
|
|
|
private String paramLayerTitle;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private HandlerManager applicationBus = new HandlerManager("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** The layer manager. */
|
|
|
|
|
private LayerManager layerManager = new LayerManager(applicationBus);
|
|
|
|
|
|
|
|
|
|
private String paramGeonaItemID;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private GeoNaDataViewerProfile geonaDataViewerProfile;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private OLMapManager olMapMng = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int attempt = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//https://data.d4science.org/gis-viewer-app/?wmsrequest=https%3A%2F%2Fgeona-proto.d4science.org%2Fgeoserver%2Fconcessioni_conf%2Fwms%3Fservice%3DWMS%26version%3D1.1.0%26request%3DGetMap%26layers%3Dconcessioni_conf%3Acentroids_concessioni%26styles%3D%26bbox%3D8.476%2C39.179%2C17.391%2C45.772%26width%3D768%26height%3D567%26srs%3DEPSG%3A4326%26format%3Dapplication%2Fopenlayers&zoom=6¢ermap=12.45%2C42.98
|
|
|
|
|
|
|
|
|
|
// https://data.d4science.org/gis-viewer-app/?wmsrequest=https%3A%2F%2Fgeona-proto.d4science.org%2Fgeoserver%2Fconcessioni_conf%2Fwms%3Fservice%3DWMS%26version%3D1.1.0%26request%3DGetMap%26layers%3Dconcessioni_conf%3Acentroids_concessioni%26styles%3D%26bbox%3D8.476%2C39.179%2C17.391%2C45.772%26width%3D768%26height%3D567%26srs%3DEPSG%3A4326%26format%3Dapplication%2Fopenlayers&zoom=6¢ermap=12.45%2C42.98
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This is the entry point method.
|
|
|
|
@ -171,7 +170,7 @@ public class GeoportalDataViewer implements EntryPoint {
|
|
|
|
|
|
|
|
|
|
GWT.log("The layerItem is: " + layerItem);
|
|
|
|
|
layerManager.addLayer(theItemType, null, null, layerItem.getWmsLink(), false, false,
|
|
|
|
|
null, false);
|
|
|
|
|
null, false, null, null);
|
|
|
|
|
|
|
|
|
|
if (paramGeonaItemID != null) {
|
|
|
|
|
if (paramGeonaItemType == null) {
|
|
|
|
@ -193,9 +192,7 @@ public class GeoportalDataViewer implements EntryPoint {
|
|
|
|
|
bindEvents();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update window size.
|
|
|
|
|
*/
|
|
|
|
@ -204,91 +201,93 @@ public class GeoportalDataViewer implements EntryPoint {
|
|
|
|
|
int rootHeight = getClientHeight();
|
|
|
|
|
int height = rootHeight;
|
|
|
|
|
mainPanel.setPanelsHeight(height);
|
|
|
|
|
GWT.log("Set height: "+height);
|
|
|
|
|
|
|
|
|
|
GWT.log("Set height: " + height);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getClientHeight() {
|
|
|
|
|
RootPanel principalDiv = RootPanel.get(APP_DIV);
|
|
|
|
|
int topBorder = principalDiv.getAbsoluteTop();
|
|
|
|
|
int rootHeight = Window.getClientHeight() - topBorder;
|
|
|
|
|
return rootHeight;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Bind events.
|
|
|
|
|
*/
|
|
|
|
|
private void bindEvents() {
|
|
|
|
|
|
|
|
|
|
applicationBus.addHandler(ShowDetailsEvent.TYPE, new ShowDetailsEventHandler() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onShowDetails(ShowDetailsEvent showDetailsEvent) {
|
|
|
|
|
GWT.log("Fired event: "+showDetailsEvent);
|
|
|
|
|
|
|
|
|
|
GWT.log("Fired event: " + showDetailsEvent);
|
|
|
|
|
|
|
|
|
|
String geonaMongoId = showDetailsEvent.getGeonaMongoID();
|
|
|
|
|
|
|
|
|
|
if(geonaMongoId==null) {
|
|
|
|
|
if (geonaMongoId == null) {
|
|
|
|
|
Window.alert("Item Id not found");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO
|
|
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
boolean found = false;
|
|
|
|
|
GWT.log("Product with id: "+geonaMongoId+" found? "+found);
|
|
|
|
|
|
|
|
|
|
if(!found) {
|
|
|
|
|
|
|
|
|
|
if(showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) {
|
|
|
|
|
|
|
|
|
|
GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(geonaMongoId, new AsyncCallback<ConcessioneDV>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
Window.alert(caught.getMessage());
|
|
|
|
|
mainPanel.hidePanelDetails();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(ConcessioneDV concessioneDV) {
|
|
|
|
|
GWT.log("Showing: "+concessioneDV);
|
|
|
|
|
mainPanel.showAsDetails(concessioneDV, showDetailsEvent.getGeonaItemRef());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
GWT.log("Product with id: " + geonaMongoId + " found? " + found);
|
|
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
|
|
|
|
|
|
if (showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) {
|
|
|
|
|
|
|
|
|
|
GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(geonaMongoId,
|
|
|
|
|
new AsyncCallback<ConcessioneDV>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
Window.alert(caught.getMessage());
|
|
|
|
|
mainPanel.hidePanelDetails();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(ConcessioneDV concessioneDV) {
|
|
|
|
|
GWT.log("Showing: " + concessioneDV);
|
|
|
|
|
mainPanel.showAsDetails(concessioneDV, showDetailsEvent.getGeonaItemRef());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
applicationBus.addHandler(AddedLayerToMapEvent.TYPE, new AddedLayerToMapEventHandler() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onLayerRendered(AddedLayerToMapEvent addedLayerToMapEvent) {
|
|
|
|
|
GWT.log("Fired AddedLayerToMapEvent "+addedLayerToMapEvent.getLayerItem());
|
|
|
|
|
//GeoportalDataViewerConstants.print("Fired AddedLayerToMapEvent "+addedLayerToMapEvent.getLayerItem());
|
|
|
|
|
|
|
|
|
|
GWT.log("Fired AddedLayerToMapEvent " + addedLayerToMapEvent.getLayerItem());
|
|
|
|
|
// GeoportalDataViewerConstants.print("Fired AddedLayerToMapEvent
|
|
|
|
|
// "+addedLayerToMapEvent.getLayerItem());
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
attempt = 0;
|
|
|
|
|
|
|
|
|
|
if(paramGeonaItemID!=null) {
|
|
|
|
|
//waiting for record retrieved by service before calling the WFS
|
|
|
|
|
|
|
|
|
|
if (paramGeonaItemID != null) {
|
|
|
|
|
// waiting for record retrieved by service before calling the WFS
|
|
|
|
|
final int MAX_RETRY = 7;
|
|
|
|
|
Timer timer = new com.google.gwt.user.client.Timer() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
attempt++;
|
|
|
|
|
GWT.log("waiting got record tenative: "+attempt);
|
|
|
|
|
GWT.log("waiting got record tenative: " + attempt);
|
|
|
|
|
RecordDV record = mainPanel.getDisplyedRecord();
|
|
|
|
|
if(record!=null) {
|
|
|
|
|
if (record != null) {
|
|
|
|
|
this.cancel();
|
|
|
|
|
GWT.log("cancelled timer");
|
|
|
|
|
performWFSQueryOnCentroid(record);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(attempt>MAX_RETRY) {
|
|
|
|
|
|
|
|
|
|
if (attempt > MAX_RETRY) {
|
|
|
|
|
GWT.log("MAX_RETRY reached, cancelled timer");
|
|
|
|
|
this.cancel();
|
|
|
|
|
}
|
|
|
|
@ -296,65 +295,69 @@ public class GeoportalDataViewer implements EntryPoint {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
timer.scheduleRepeating(1000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
applicationBus.addHandler(ZoomOutOverMinimumEvent.TYPE, new ZoomOutOverMinimumEventHandler() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent) {
|
|
|
|
|
|
|
|
|
|
if(mainPanel.getDisplyedRecord()==null && !olMapMng.isQueryPointActive()) {
|
|
|
|
|
|
|
|
|
|
if (mainPanel.getDisplyedRecord() == null && !olMapMng.isQueryPointActive()) {
|
|
|
|
|
olMapMng.hidePopInfo();
|
|
|
|
|
olMapMng.removeDetailLayers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
applicationBus.addHandler(ClosedViewDetailsEvent.TYPE, new ClosedViewDetailsEventHandler() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClosed(ClosedViewDetailsEvent closedViewDetailsEvent) {
|
|
|
|
|
olMapMng.hidePopInfo();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
applicationBus.addHandler(MapExtentToEvent.TYPE, new MapExtentToEventHandler() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onExtentEvent(MapExtentToEvent mapExtentToEvent) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void performWFSQueryOnCentroid(RecordDV record) {
|
|
|
|
|
if(record!=null) {
|
|
|
|
|
GWT.log("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV) +" with mongo item id: "+record.getItemId());
|
|
|
|
|
//GeoportalDataViewerConstants.print("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV));
|
|
|
|
|
if(record instanceof ConcessioneDV) {
|
|
|
|
|
if (record != null) {
|
|
|
|
|
GWT.log("record instanceof ConcessioneDV: " + (record instanceof ConcessioneDV) + " with mongo item id: "
|
|
|
|
|
+ record.getItemId());
|
|
|
|
|
// GeoportalDataViewerConstants.print("record instanceof ConcessioneDV: "
|
|
|
|
|
// +(record instanceof ConcessioneDV));
|
|
|
|
|
if (record instanceof ConcessioneDV) {
|
|
|
|
|
ConcessioneDV concessioneDV = (ConcessioneDV) record;
|
|
|
|
|
Double x = concessioneDV.getCentroidLong();
|
|
|
|
|
Double y = concessioneDV.getCentroidLat();
|
|
|
|
|
GWT.log("X: "+x +", Y:"+y);
|
|
|
|
|
if(x!=null && y!=null) {
|
|
|
|
|
Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y), MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName());
|
|
|
|
|
GeoQuery select = olMapMng.toDataPointQuery(transfCoord,false);
|
|
|
|
|
GWT.log("GeoQuery: "+select);
|
|
|
|
|
//GeoportalDataViewerConstants.print("fireEvent QueryDataEvent");
|
|
|
|
|
layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getItemId(), true, MapEventType.ADDED_LAYER_TO_MAP));
|
|
|
|
|
}else {
|
|
|
|
|
GeoportalDataViewerConstants.printJs("I cannot select the point one or both coordiantes are null. X: "+x +", Y:"+y);
|
|
|
|
|
GWT.log("X: " + x + ", Y:" + y);
|
|
|
|
|
if (x != null && y != null) {
|
|
|
|
|
Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y),
|
|
|
|
|
MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName());
|
|
|
|
|
GeoQuery select = olMapMng.toDataPointQuery(transfCoord, false);
|
|
|
|
|
GWT.log("GeoQuery: " + select);
|
|
|
|
|
// GeoportalDataViewerConstants.print("fireEvent QueryDataEvent");
|
|
|
|
|
layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord,
|
|
|
|
|
record.getItemId(), true, MapEventType.ADDED_LAYER_TO_MAP));
|
|
|
|
|
} else {
|
|
|
|
|
GeoportalDataViewerConstants.printJs(
|
|
|
|
|
"I cannot select the point one or both coordiantes are null. X: " + x + ", Y:" + y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|