Added temporary console.log and check
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@177250 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d1ced8f867
commit
0460fad0a6
|
@ -8,7 +8,6 @@ import org.gcube.portlets.widgets.openlayerbasicwidgets.client.event.SelectAreaD
|
||||||
import org.gcube.portlets.widgets.openlayerbasicwidgets.client.event.SelectAreaDialogEventType;
|
import org.gcube.portlets.widgets.openlayerbasicwidgets.client.event.SelectAreaDialogEventType;
|
||||||
import org.gcube.portlets.widgets.openlayerbasicwidgets.client.widgets.AreaSelectionDialog;
|
import org.gcube.portlets.widgets.openlayerbasicwidgets.client.widgets.AreaSelectionDialog;
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
|
||||||
import com.google.gwt.core.client.JavaScriptObject;
|
import com.google.gwt.core.client.JavaScriptObject;
|
||||||
import com.google.gwt.core.client.JsonUtils;
|
import com.google.gwt.core.client.JsonUtils;
|
||||||
import com.google.gwt.json.client.JSONObject;
|
import com.google.gwt.json.client.JSONObject;
|
||||||
|
@ -38,9 +37,16 @@ public class GeoJsonAreaSelectionDialog extends AreaSelectionDialog{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(SelectAreaDialogEvent event) {
|
public void onResponse(SelectAreaDialogEvent event) {
|
||||||
GWT.log("SelectAreaDialog Response: "+event);
|
print("SelectAreaDialog Response: "+event);
|
||||||
|
|
||||||
|
if(event==null)
|
||||||
|
return;
|
||||||
|
|
||||||
SelectAreaDialogEventType closedType = event.getSelectAreaDialogEventType();
|
SelectAreaDialogEventType closedType = event.getSelectAreaDialogEventType();
|
||||||
|
|
||||||
|
if(closedType==null)
|
||||||
|
return;
|
||||||
|
|
||||||
wktArea = null;
|
wktArea = null;
|
||||||
if(closedType.equals(SelectAreaDialogEventType.Completed)){
|
if(closedType.equals(SelectAreaDialogEventType.Completed)){
|
||||||
wktArea = event.getArea();
|
wktArea = event.getArea();
|
||||||
|
@ -72,17 +78,26 @@ public class GeoJsonAreaSelectionDialog extends AreaSelectionDialog{
|
||||||
* @return the string
|
* @return the string
|
||||||
*/
|
*/
|
||||||
private static native String convertWKTToGeoJSON(String wktData) /*-{
|
private static native String convertWKTToGeoJSON(String wktData) /*-{
|
||||||
var ol = $wnd.ol;
|
try {
|
||||||
var geojson_options = {};
|
var ol = $wnd.ol;
|
||||||
var wkt_format = new ol.format.WKT();
|
var geojson_options = {};
|
||||||
var testFeature = wkt_format.readFeature(wktData);
|
var wkt_format = new ol.format.WKT();
|
||||||
var wkt_options = {};
|
var testFeature = wkt_format.readFeature(wktData);
|
||||||
var geojson_format = new ol.format.GeoJSON(wkt_options);
|
var wkt_options = {};
|
||||||
var out = geojson_format.writeFeature(testFeature);
|
var geojson_format = new ol.format.GeoJSON(wkt_options);
|
||||||
//window.getELementById("my-id").innerhtml(out);
|
var out = geojson_format.writeFeature(testFeature);
|
||||||
//alert(out);
|
//window.getELementById("my-id").innerhtml(out);
|
||||||
//console.log(out)
|
//alert(out);
|
||||||
return out;
|
console.log(out)
|
||||||
|
return out;
|
||||||
|
}catch(err) {
|
||||||
|
console.log(err.message);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}-*/;
|
||||||
|
|
||||||
|
public static native String print(String data) /*-{
|
||||||
|
console.log(out)
|
||||||
}-*/;
|
}-*/;
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,7 +110,11 @@ public class GeoJsonAreaSelectionDialog extends AreaSelectionDialog{
|
||||||
public String wktToGeoJSON(String wktTxt){
|
public String wktToGeoJSON(String wktTxt){
|
||||||
String geoJSON = convertWKTToGeoJSON(wktTxt);
|
String geoJSON = convertWKTToGeoJSON(wktTxt);
|
||||||
//Window.alert("geoJSON: "+geoJSON);
|
//Window.alert("geoJSON: "+geoJSON);
|
||||||
GWT.log("geoJSON: "+geoJSON);
|
print("geoJSON: "+geoJSON);
|
||||||
|
|
||||||
|
if(geoJSON==null)
|
||||||
|
return null;
|
||||||
|
|
||||||
JavaScriptObject toJSON = JsonUtils.safeEval(geoJSON);
|
JavaScriptObject toJSON = JsonUtils.safeEval(geoJSON);
|
||||||
JSONObject objJson = new JSONObject(toJSON);
|
JSONObject objJson = new JSONObject(toJSON);
|
||||||
return objJson.get("geometry").toString();
|
return objJson.get("geometry").toString();
|
||||||
|
@ -108,6 +127,11 @@ public class GeoJsonAreaSelectionDialog extends AreaSelectionDialog{
|
||||||
*/
|
*/
|
||||||
public String getWKTToGeoJSON(){
|
public String getWKTToGeoJSON(){
|
||||||
|
|
||||||
|
if(wktArea==null){
|
||||||
|
print("wktArea is null");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return wktToGeoJSON(wktArea);
|
return wktToGeoJSON(wktArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,8 +149,10 @@ public class MetaDataFieldSkeleton extends Composite{
|
||||||
|
|
||||||
Command fillGeoJSONArea = new Command() {
|
Command fillGeoJSONArea = new Command() {
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if(dialog.getWKTToGeoJSON()!=null)
|
|
||||||
textArea.setText(dialog.getWKTToGeoJSON());
|
String geoJsonGeom = dialog.getWKTToGeoJSON();
|
||||||
|
if(geoJsonGeom!=null)
|
||||||
|
textArea.setText(geoJsonGeom);
|
||||||
else{
|
else{
|
||||||
textArea.setText("");
|
textArea.setText("");
|
||||||
containerGeoJSON.add(new Alert("Error on drawing the Geometry", AlertType.WARNING, true));
|
containerGeoJSON.add(new Alert("Error on drawing the Geometry", AlertType.WARNING, true));
|
||||||
|
|
Loading…
Reference in New Issue