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>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<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">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<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.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
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.
|
||||
*/
|
||||
public GeoJsonAreaSelectionDialog() {
|
||||
super();
|
||||
|
||||
//THE HANDLER
|
||||
SelectAreaDialogEventHandler handler = new SelectAreaDialogEventHandler() {
|
||||
|
@ -82,22 +83,22 @@ public class GeoJsonAreaSelectionDialog extends AreaSelectionDialog{
|
|||
var ol = $wnd.ol;
|
||||
var geojson_options = {};
|
||||
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 geojson_format = new ol.format.GeoJSON(wkt_options);
|
||||
var out = geojson_format.writeFeature(testFeature);
|
||||
//window.getELementById("my-id").innerhtml(out);
|
||||
//alert(out);
|
||||
console.log(out)
|
||||
return out;
|
||||
console.log('geojson_format: '+geojson_format);
|
||||
var geoJsonFeature = geojson_format.writeFeature(wktFeature);
|
||||
//console.log('GeoJSON Feature: '+geoJsonFeature);
|
||||
return geoJsonFeature;
|
||||
}catch(err) {
|
||||
console.log(err.message);
|
||||
return null;
|
||||
}
|
||||
}-*/;
|
||||
|
||||
public static native String print(String data) /*-{
|
||||
console.log(out)
|
||||
public static native String print(String txt) /*-{
|
||||
console.log(txt)
|
||||
}-*/;
|
||||
|
||||
|
||||
|
@ -106,32 +107,39 @@ public class GeoJsonAreaSelectionDialog extends AreaSelectionDialog{
|
|||
*
|
||||
* @param wktTxt the wkt txt
|
||||
* @return the string
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public String wktToGeoJSON(String wktTxt){
|
||||
public String wktToGeoJSON(String wktTxt) throws Exception{
|
||||
try {
|
||||
String geoJSON = convertWKTToGeoJSON(wktTxt);
|
||||
//Window.alert("geoJSON: "+geoJSON);
|
||||
print("geoJSON: "+geoJSON);
|
||||
|
||||
if(geoJSON==null)
|
||||
return null;
|
||||
throw new Exception();
|
||||
|
||||
JavaScriptObject toJSON = JsonUtils.safeEval(geoJSON);
|
||||
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.
|
||||
*
|
||||
* @return the WKT to geo json
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public String getWKTToGeoJSON(){
|
||||
public String getWKTToGeoJSON() throws Exception{
|
||||
|
||||
if(wktArea==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);
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,6 @@ public class MetaDataFieldSkeleton extends Composite{
|
|||
|
||||
case GeoJSON:
|
||||
//MANAGED By FRANCESCO
|
||||
// start and end range date
|
||||
final VerticalPanel containerGeoJSON = new VerticalPanel();
|
||||
//containerGeoJSON.setWidth("100%");
|
||||
|
||||
|
@ -150,12 +149,16 @@ public class MetaDataFieldSkeleton extends Composite{
|
|||
Command fillGeoJSONArea = new Command() {
|
||||
public void execute() {
|
||||
|
||||
try {
|
||||
String geoJsonGeom = dialog.getWKTToGeoJSON();
|
||||
if(geoJsonGeom!=null)
|
||||
textArea.setText(geoJsonGeom);
|
||||
else{
|
||||
textArea.setText("");
|
||||
containerGeoJSON.add(new Alert("Error on drawing the Geometry", AlertType.WARNING, true));
|
||||
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