bug fixing the geojson feature
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@178828 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
0460fad0a6
commit
4dd754f601
|
@ -10,6 +10,7 @@
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
|
@ -25,6 +26,7 @@
|
||||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
|
|
|
@ -10,4 +10,5 @@ org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.release=disabled
|
||||||
org.eclipse.jdt.core.compiler.source=1.7
|
org.eclipse.jdt.core.compiler.source=1.7
|
||||||
|
|
|
@ -31,6 +31,7 @@ public class GeoJsonAreaSelectionDialog extends AreaSelectionDialog{
|
||||||
* Instantiates a new geo json area selection dialog.
|
* Instantiates a new geo json area selection dialog.
|
||||||
*/
|
*/
|
||||||
public GeoJsonAreaSelectionDialog() {
|
public GeoJsonAreaSelectionDialog() {
|
||||||
|
super();
|
||||||
|
|
||||||
//THE HANDLER
|
//THE HANDLER
|
||||||
SelectAreaDialogEventHandler handler = new SelectAreaDialogEventHandler() {
|
SelectAreaDialogEventHandler handler = new SelectAreaDialogEventHandler() {
|
||||||
|
@ -82,22 +83,22 @@ public class GeoJsonAreaSelectionDialog extends AreaSelectionDialog{
|
||||||
var ol = $wnd.ol;
|
var ol = $wnd.ol;
|
||||||
var geojson_options = {};
|
var geojson_options = {};
|
||||||
var wkt_format = new ol.format.WKT();
|
var wkt_format = new ol.format.WKT();
|
||||||
var testFeature = wkt_format.readFeature(wktData);
|
var wktFeature = wkt_format.readFeature(wktData);
|
||||||
|
//console.log('WKT feature: '+wktFeature);
|
||||||
var wkt_options = {};
|
var wkt_options = {};
|
||||||
var geojson_format = new ol.format.GeoJSON(wkt_options);
|
var geojson_format = new ol.format.GeoJSON(wkt_options);
|
||||||
var out = geojson_format.writeFeature(testFeature);
|
console.log('geojson_format: '+geojson_format);
|
||||||
//window.getELementById("my-id").innerhtml(out);
|
var geoJsonFeature = geojson_format.writeFeature(wktFeature);
|
||||||
//alert(out);
|
//console.log('GeoJSON Feature: '+geoJsonFeature);
|
||||||
console.log(out)
|
return geoJsonFeature;
|
||||||
return out;
|
|
||||||
}catch(err) {
|
}catch(err) {
|
||||||
console.log(err.message);
|
console.log(err.message);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}-*/;
|
}-*/;
|
||||||
|
|
||||||
public static native String print(String data) /*-{
|
public static native String print(String txt) /*-{
|
||||||
console.log(out)
|
console.log(txt)
|
||||||
}-*/;
|
}-*/;
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,32 +107,39 @@ public class GeoJsonAreaSelectionDialog extends AreaSelectionDialog{
|
||||||
*
|
*
|
||||||
* @param wktTxt the wkt txt
|
* @param wktTxt the wkt txt
|
||||||
* @return the string
|
* @return the string
|
||||||
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public String wktToGeoJSON(String wktTxt){
|
public String wktToGeoJSON(String wktTxt) throws Exception{
|
||||||
String geoJSON = convertWKTToGeoJSON(wktTxt);
|
try {
|
||||||
//Window.alert("geoJSON: "+geoJSON);
|
String geoJSON = convertWKTToGeoJSON(wktTxt);
|
||||||
print("geoJSON: "+geoJSON);
|
//Window.alert("geoJSON: "+geoJSON);
|
||||||
|
print("geoJSON: "+geoJSON);
|
||||||
if(geoJSON==null)
|
|
||||||
return null;
|
if(geoJSON==null)
|
||||||
|
throw new Exception();
|
||||||
JavaScriptObject toJSON = JsonUtils.safeEval(geoJSON);
|
|
||||||
JSONObject objJson = new JSONObject(toJSON);
|
JavaScriptObject toJSON = JsonUtils.safeEval(geoJSON);
|
||||||
return objJson.get("geometry").toString();
|
JSONObject objJson = new JSONObject(toJSON);
|
||||||
|
return objJson.get("geometry").toString();
|
||||||
|
}catch(Exception e) {
|
||||||
|
//silent
|
||||||
|
throw new Exception("Sorry, an error occurred while getting GeoJSON format for the drawn Geometry");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the WKT to geo json.
|
* Gets the WKT to geo json.
|
||||||
*
|
*
|
||||||
* @return the WKT to geo json
|
* @return the WKT to geo json
|
||||||
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public String getWKTToGeoJSON(){
|
public String getWKTToGeoJSON() throws Exception{
|
||||||
|
|
||||||
if(wktArea==null){
|
if(wktArea==null){
|
||||||
print("wktArea is null");
|
print("wktArea is null");
|
||||||
return null;
|
throw new Exception("Sorry, an error occurred while reading the drawn Geometry");
|
||||||
}
|
}
|
||||||
|
//print("wktArea is: "+wktArea);
|
||||||
return wktToGeoJSON(wktArea);
|
return wktToGeoJSON(wktArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,6 @@ public class MetaDataFieldSkeleton extends Composite{
|
||||||
|
|
||||||
case GeoJSON:
|
case GeoJSON:
|
||||||
//MANAGED By FRANCESCO
|
//MANAGED By FRANCESCO
|
||||||
// start and end range date
|
|
||||||
final VerticalPanel containerGeoJSON = new VerticalPanel();
|
final VerticalPanel containerGeoJSON = new VerticalPanel();
|
||||||
//containerGeoJSON.setWidth("100%");
|
//containerGeoJSON.setWidth("100%");
|
||||||
|
|
||||||
|
@ -150,12 +149,16 @@ public class MetaDataFieldSkeleton extends Composite{
|
||||||
Command fillGeoJSONArea = new Command() {
|
Command fillGeoJSONArea = new Command() {
|
||||||
public void execute() {
|
public void execute() {
|
||||||
|
|
||||||
String geoJsonGeom = dialog.getWKTToGeoJSON();
|
try {
|
||||||
if(geoJsonGeom!=null)
|
String geoJsonGeom = dialog.getWKTToGeoJSON();
|
||||||
textArea.setText(geoJsonGeom);
|
if(geoJsonGeom!=null)
|
||||||
else{
|
textArea.setText(geoJsonGeom);
|
||||||
textArea.setText("");
|
else{
|
||||||
containerGeoJSON.add(new Alert("Error on drawing the Geometry", AlertType.WARNING, true));
|
textArea.setText("");
|
||||||
|
containerGeoJSON.add(new Alert("Sorry, an error occurred by reading the Geometry", AlertType.ERROR, true));
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
containerGeoJSON.add(new Alert(e.getMessage(), AlertType.ERROR, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue