geoportal-data-viewer-app/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstant...

178 lines
4.3 KiB
Java
Raw Normal View History

2020-10-23 18:18:06 +02:00
package org.gcube.portlets.user.geoportaldataviewer.client;
2021-08-04 16:10:11 +02:00
import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
2020-10-27 16:04:34 +01:00
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayersMapParameters;
2021-08-04 16:10:11 +02:00
import com.google.gwt.i18n.client.DateTimeFormat;
2020-11-24 12:26:38 +01:00
/**
* The Class GeoportalDataViewerConstants.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
2021-09-01 12:51:06 +02:00
* Nov 24, 2020
2020-11-24 12:26:38 +01:00
*/
2020-10-23 18:18:06 +02:00
public class GeoportalDataViewerConstants {
public static final String MAP_DIV = "map";
2021-09-01 12:51:06 +02:00
2020-10-27 16:04:34 +01:00
public static final String GET_WMS_PARAMETER = "wmsrequest";
2020-11-19 15:19:27 +01:00
public static final String GET_GEONA_ITEM_TYPE = "git";
public static final String GET_GEONA_ITEM_ID = "gid";
2020-10-27 16:04:34 +01:00
public static final String GET_UUID_PARAMETER = "uuid";
public static final String GET_LAYER_TITLE = "layertitle";
public static final String GET_MAX_ZOOM_LEVEL = OpenLayersMapParameters.OL_MAP_PARAM.maxzoomlevel.name();
public static final String GET_ZOOM = OpenLayersMapParameters.OL_MAP_PARAM.zoom.name();
public static final String GET_CENTER_MAP_TO_LONG_LAT = OpenLayersMapParameters.OL_MAP_PARAM.centermap.name();
2021-09-01 12:51:06 +02:00
public static enum MapEventType {
2021-09-08 17:13:59 +02:00
MOUSE_CLICK, MAP_ZOOM_END, MOVE_END, ADDED_CENTROID_LAYER_TO_MAP
2021-09-01 12:51:06 +02:00
}
2020-11-24 12:26:38 +01:00
/**
* The Enum LayerType.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
2021-09-01 12:51:06 +02:00
* Nov 24, 2020
2020-11-24 12:26:38 +01:00
*/
2021-09-01 12:51:06 +02:00
public enum LayerType {
RASTER_BASELAYER, FEATURE_TYPE
};
public static DateTimeFormat DT_FORMAT = DateTimeFormat.getFormat(ConvertToDataViewModel.DATE_FORMAT);
2021-09-09 15:55:33 +02:00
public static final int MAX_WFS_FEATURES = 10; // zero for no limit
2021-09-01 12:51:06 +02:00
2020-11-19 15:19:27 +01:00
public static final String NEW_LINE_BR = "<br/>";
2021-09-01 12:51:06 +02:00
public static enum MAP_PROJECTION {
EPSG_4326("4326", "EPSG:4326"), EPSG_3857("3857", "EPSG:3857");
2021-09-01 12:51:06 +02:00
String id;
2021-09-01 12:51:06 +02:00
String name;
MAP_PROJECTION(String id, String name) {
this.id = id;
2021-09-01 12:51:06 +02:00
this.name = name;
}
public String getId() {
return id;
}
2021-09-01 12:51:06 +02:00
public String getName() {
return name;
}
}
2021-12-07 17:13:20 +01:00
public enum RECORD_TYPE {
CONCESSIONE
}
2021-09-01 12:51:06 +02:00
2020-11-19 15:19:27 +01:00
public static final double ITALY_CENTER_LONG = 12.45;
2021-09-01 12:51:06 +02:00
2020-11-19 15:19:27 +01:00
public static final double ITALY_CENTER_LAT = 42.98;
2021-09-01 12:51:06 +02:00
public static final int LIGHT_MAP_ITALY_FIT_ZOOM_ON = 5;
2021-09-01 12:51:06 +02:00
2021-09-07 17:29:56 +02:00
public static final int MAP_ITALY_FIT_ZOOM_ON = 5;
2020-11-24 12:26:38 +01:00
/**
* Prints the.
*
* @param msg the msg
*/
public static native void printJs(String msg)/*-{
2021-09-01 12:51:06 +02:00
console.log("js console: " + msg);
}-*/;
2021-09-02 18:15:15 +02:00
/**
* Prints the.
*
* @param msg the msg
*/
public static native void printJsObj(Object object)/*-{
console.log("js obj: " + JSON.stringify(object, null, 4));
2021-09-02 18:15:15 +02:00
}-*/;
2021-09-02 18:15:15 +02:00
/**
* Prints the.
*
* @param msg the msg
*/
public static native String toJsonObj(Object object)/*-{
return JSON.stringify(object);
}-*/;
2022-10-11 15:00:39 +02:00
/**
* Json to HTML.
*
* @param jsonTxt the json txt
* @return the string
*/
public static native String jsonToTableHTML(String jsonTxt)/*-{
try {
var jsonObj = JSON.parse(jsonTxt);
if (jsonObj.length == undefined)
jsonObj = [ jsonObj ]
//console.log(jsonObj.length)
// EXTRACT VALUE FOR HTML HEADER.
var col = [];
for (var i = 0; i < jsonObj.length; i++) {
for ( var key in jsonObj[i]) {
//console.log('key json' +key)
if (col.indexOf(key) === -1) {
col.push(key);
}
}
}
// CREATE DYNAMIC TABLE.
var table = document.createElement("table");
try {
table.classList.add("my-html-table");
} catch (e) {
console.log('invalid css add', e);
}
// ADD JSON DATA TO THE TABLE AS ROWS.
for (var i = 0; i < col.length; i++) {
tr = table.insertRow(-1);
var firstCell = tr.insertCell(-1);
//firstCell.style.cssText="font-weight: bold; text-align: center; vertical-align: middle;";
firstCell.innerHTML = col[i];
for (var j = 0; j < jsonObj.length; j++) {
var tabCell = tr.insertCell(-1);
var theValue = jsonObj[j][col[i]];
//console.log("the value: "+theValue);
if (Object.prototype.toString.call(theValue) === '[object Array]') {
var formattedValueArray = "";
for (var k = 0; k < theValue.length; k++) {
var theValueArray = theValue[k];
//console.log(theValueArray);
formattedValueArray += theValueArray + "<br>";
}
tabCell.innerHTML = formattedValueArray;
} else {
tabCell.innerHTML = theValue;
}
}
}
return table.outerHTML;
} catch (e) {
console.log('invalid json', e);
return jsonTxt;
}
}-*/;
2020-10-23 18:18:06 +02:00
}