119 lines
3.5 KiB
Java
119 lines
3.5 KiB
Java
package org.gcube.application.cms.sdi.model;
|
|
|
|
import freemarker.core.PlainTextOutputFormat;
|
|
import lombok.Getter;
|
|
import org.bson.Document;
|
|
import org.gcube.application.geoportal.common.model.document.filesets.GCubeSDILayer;
|
|
import org.gcube.application.geoportal.common.model.document.filesets.Materialization;
|
|
import sun.misc.GC;
|
|
|
|
import javax.print.Doc;
|
|
import java.util.*;
|
|
|
|
public class GCubeSDILayerBuilder {
|
|
|
|
public static enum OGC_TYPE{
|
|
wms,wfs,wcs,csw
|
|
}
|
|
|
|
|
|
public static final String EPSG_4326="EPSG:4326";
|
|
public static final String WGS84_FULL="GEOGCS[\"WGS 84\", DATUM[\"World Geodetic System 1984\", SPHEROID[\"WGS 84\", 6378137.0, 298.257223563, AUTHORITY[\"EPSG\",\"7030\"]],"+
|
|
"AUTHORITY[\"EPSG\",\"6326\"]], PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]], UNIT[\"degree\", 0.017453292519943295],"+
|
|
"AXIS[\"Geodetic longitude\", EAST], AXIS[\"Geodetic latitude\", NORTH], AUTHORITY[\"EPSG\",\"4326\"]]";
|
|
|
|
|
|
|
|
public static final String GS_PLATFORM="Geoserver";
|
|
|
|
|
|
GCubeSDILayer theObject = new GCubeSDILayer();
|
|
|
|
@Getter
|
|
Document platformInfo= new Document(Materialization.TYPE,GS_PLATFORM);
|
|
|
|
@Getter
|
|
GCubeSDILayer.BBOX bbox = GCubeSDILayer.BBOX.WORLD;
|
|
|
|
@Getter
|
|
Map<OGC_TYPE,Document> ogcLinks = new HashMap<>();
|
|
|
|
public GCubeSDILayerBuilder(){
|
|
}
|
|
|
|
|
|
public GCubeSDILayer getLayer(){
|
|
theObject.put(GCubeSDILayer.PLATFORM_INFO, Collections.singleton(platformInfo));
|
|
theObject.put(GCubeSDILayer.B_BOX,bbox);
|
|
|
|
prepareOGCLinks();
|
|
theObject.put(GCubeSDILayer.OGC_LINKS,ogcLinks);
|
|
return theObject;
|
|
}
|
|
|
|
|
|
// @@@@@@@@@@@@@@@@@@ Platform info
|
|
public GCubeSDILayerBuilder setWorkspace(String ws){
|
|
platformInfo.put("workspace",ws);
|
|
return this;
|
|
}
|
|
|
|
public GCubeSDILayerBuilder setHost(String ws){
|
|
platformInfo.put("host",ws);
|
|
return this;
|
|
}
|
|
|
|
public GCubeSDILayerBuilder setEngineVersion(String ws){
|
|
platformInfo.put("engineVersion",ws);
|
|
return this;
|
|
}
|
|
|
|
public GCubeSDILayerBuilder setLayerName(String ws){
|
|
platformInfo.put("layerName",ws);
|
|
return this;
|
|
}
|
|
|
|
public GCubeSDILayerBuilder setPersistencePath(String ws){
|
|
platformInfo.put("persistencePath",ws);
|
|
return this;
|
|
}
|
|
|
|
public GCubeSDILayerBuilder setStoreName(String ws){
|
|
platformInfo.put("storeName",ws);
|
|
return this;
|
|
}
|
|
|
|
public GCubeSDILayerBuilder setFiles(List<String> ws){
|
|
platformInfo.put("files",ws);
|
|
return this;
|
|
}
|
|
|
|
|
|
private void prepareOGCLinks(){
|
|
if(!ogcLinks.containsKey(OGC_TYPE.wms)){
|
|
addLink(OGC_TYPE.wms,String.format("https://%1$s/geoserver/%2$s/wms?"
|
|
+ "service=WMS&version=1.1.0&request=GetMap&layers=%2$s:%3$s&"
|
|
+ "styles=&bbox=%4$f,%5$f,%6$f,%7$f&srs=%8$s&format=application/openlayers&width=%9$d&height=%10$d",
|
|
platformInfo.get("host"),
|
|
platformInfo.get("workspace"),
|
|
platformInfo.get("layerName"),
|
|
bbox.getMinX(),
|
|
bbox.getMinY(),
|
|
bbox.getMaxX(),
|
|
bbox.getMaxY(),
|
|
EPSG_4326,
|
|
400,
|
|
400));
|
|
}
|
|
}
|
|
|
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@ OGC
|
|
public GCubeSDILayerBuilder addLink(OGC_TYPE type,String link){
|
|
ogcLinks.put(type,new Document(type.name(),link));
|
|
return this;
|
|
}
|
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@ BBOX
|
|
|
|
|
|
}
|