adding new objects

This commit is contained in:
Francesco Mangiacrapa 2020-10-29 17:48:20 +01:00
parent 5aa24f6198
commit 7f56579113
6 changed files with 119 additions and 13 deletions

View File

@ -76,15 +76,19 @@ public class LayerManager {
*/
//THE FOLLOWING SHOULD BE NOT NEEDED BUT THE GETFEATURE WITH EPSG_3857 SEEMS NOT WORK IN OUR GEOSERVER
double minX = olMap.getExtent().getLowerLeftX();
double minY = olMap.getExtent().getLowerLeftY();
// double minX = olMap.getExtent().getLowerLeftX();
// double minY = olMap.getExtent().getLowerLeftY();
double minX = queryEvent.getGeoQuery().getX1();
double minY = queryEvent.getGeoQuery().getY1();
Coordinate centerCoordinate = new Coordinate(minX, minY);
centerCoordinate = olMap.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_3857, GeoportalDataViewerConstants.EPSG_4326);
mapBBOX.setLowerLeftX(centerCoordinate.getX());
mapBBOX.setLowerLeftY(centerCoordinate.getY());
double maxX = olMap.getExtent().getUpperRightX();
double maxY = olMap.getExtent().getUpperRightY();
// double maxX = olMap.getExtent().getUpperRightX();
// double maxY = olMap.getExtent().getUpperRightY();
double maxX = queryEvent.getGeoQuery().getX2();
double maxY = queryEvent.getGeoQuery().getY2();
centerCoordinate = new Coordinate(maxX,maxY);
centerCoordinate = olMap.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_3857, GeoportalDataViewerConstants.EPSG_4326);
mapBBOX.setUpperRightX(centerCoordinate.getX());

View File

@ -155,7 +155,7 @@ public class OpenLayerOSM {
// ratio - mapPixelWeight : bboxWeight = 10px : geoRectangleWidth
// where 10px is the pixel diameter dimension of the clicked point
double bboxWidth = Math.abs(getExtent().getLowerLeftX() - getExtent().getUpperRightX());
double geoWidth = bboxWidth / w * 10 / 2;
double geoWidth = (bboxWidth / w) * (20 / 2);
double x1 = Math.min(lon+geoWidth, lon-geoWidth);
double x2 = Math.max(lon+geoWidth, lon-geoWidth);
double y1 = Math.min(lat+geoWidth, lat-geoWidth);

View File

@ -20,6 +20,7 @@ import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.FeatureRow;
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.FeatureGeometry;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.json.JSONArray;
import org.json.JSONException;
@ -57,9 +58,15 @@ public class FeatureParser {
maxWFSFeature = GeoportalDataViewerConstants.MAX_WFS_FEATURES;
}
List<GeoNaDataObject> listGeonaDO = new ArrayList<GeoNaDataObject>();
//IF WFS IS AVAILABLE USE WFS REQUEST OTHERWHISE TRY TO USE WPS SERVICE
for (LayerItem layerItem : layerItems){
List<FeatureRow> rows = getWFSFeatureProperties(layerItem, mapSrsName, mapBBOX, maxWFSFeature);
GeoNaDataObject gdo = new GeoNaDataObject();
gdo.setLayerItem(layerItem);
for (FeatureRow featureRow : rows) {
}
}
return null;
}
@ -115,6 +122,17 @@ public class FeatureParser {
final FeatureRow row = new FeatureRow();
JSONObject theFeature = ((JSONObject)features.get(i));
LOG.debug("Building at index: "+i);
try {
JSONObject geometry = theFeature.getJSONObject("geometry");
String typeValue = geometry.getString("type");
JSONArray coordinates = geometry.getJSONArray("coordinates");
String toCoordinates = coordinates.toString();
row.setGeometry(new FeatureGeometry(typeValue, toCoordinates));
}catch (Exception e) {
LOG.debug("Unable to pase geometry at index: "+i);
}
// // iterate properties
JSONObject properties = theFeature.getJSONObject("properties");
Map<String,List<String>> mapProperties = new HashMap<String,List<String>>();

View File

@ -7,13 +7,14 @@ import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.FeatureGeometry;
/**
* The Class FeatureRow.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 29, 2020
* Oct 29, 2020
*/
public class FeatureRow implements Serializable {
@ -24,30 +25,45 @@ public class FeatureRow implements Serializable {
private Map<String, List<String>> mapProperties;
private FeatureGeometry geometry;
public FeatureRow() {
}
public FeatureRow(Map<String, List<String>> mapProperties, FeatureGeometry geometry) {
super();
this.mapProperties = mapProperties;
this.setGeometry(geometry);
}
public Map<String, List<String>> getMapProperties() {
return mapProperties;
}
public void setMapProperties(Map<String, List<String>> mapProperties) {
this.mapProperties = mapProperties;
}
public FeatureGeometry getGeometry() {
return geometry;
}
public void setGeometry(FeatureGeometry geometry) {
this.geometry = geometry;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("FeatureRow [mapValues=");
builder.append("FeatureRow [mapProperties=");
builder.append(mapProperties);
builder.append(", geometry=");
builder.append(geometry);
builder.append("]");
return builder.toString();
}
}

View File

@ -4,6 +4,8 @@ import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
/**
* The Class GeoNaDataObject.
@ -21,6 +23,7 @@ public class GeoNaDataObject implements Serializable{
/** The form data entry fields. */
private Map<String, List<String>> dataEntryFields;
private String geonaDataType;
private LayerItem layerItem;
/**
* Instantiates a new geo na data object.
@ -55,6 +58,15 @@ public class GeoNaDataObject implements Serializable{
public String getGeonaDataType() {
return geonaDataType;
}
public LayerItem getLayerItem() {
return layerItem;
}
public void setLayerItem(LayerItem layerItem) {
this.layerItem = layerItem;
}
/**
* Sets the geona data type.

View File

@ -0,0 +1,56 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
import java.io.Serializable;
/**
* The Class FeatureGeoemtry.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 29, 2020
*/
public class FeatureGeometry implements Serializable{
String type;
String coordinates;
public FeatureGeometry() {
}
public FeatureGeometry(String type, String coordinates) {
super();
this.type = type;
this.coordinates = coordinates;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getCoordinates() {
return coordinates;
}
public void setCoordinates(String coordinates) {
this.coordinates = coordinates;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("FeatureGeometry [type=");
builder.append(type);
builder.append(", coordinates=");
builder.append(coordinates);
builder.append("]");
return builder.toString();
}
}