use of gov.usgs.cida.coastalhazards.model.summary.Summary in project coastal-hazards by USGS-CIDA.
the class TemplateResource method makeSummary.
private Summary makeSummary(Layer layer, String attr) throws JsonSyntaxException {
OGCService cswService = Service.ogcHelper(Service.ServiceType.csw, layer.getServices());
log.debug("cswService {}", cswService);
String cswEndpoint = cswService.getEndpoint();
log.debug("cswEndpoint {}", cswEndpoint);
String summaryJson = null;
try {
summaryJson = MetadataUtil.getSummaryFromWPS(cswEndpoint, attr);
log.debug("summaryJsonMetadataUtil {}", summaryJson);
} catch (IOException | ParserConfigurationException | SAXException | URISyntaxException ex) {
log.error("Problem getting summary from item", ex);
}
Gson gson = GsonUtil.getDefault();
log.debug(String.valueOf(gson));
Summary summary = gson.fromJson(summaryJson, Summary.class);
log.debug(String.valueOf(summary));
return summary;
}
use of gov.usgs.cida.coastalhazards.model.summary.Summary in project coastal-hazards by USGS-CIDA.
the class TemplateResource method makeItemsFromLayer.
private List<Item> makeItemsFromLayer(Item template, String layerId, LayerManager layerMan) throws IOException {
List<Item> items = new LinkedList<>();
Layer layer = layerMan.load(layerId);
WFSService wfs = (WFSService) Service.ogcHelper(Service.ServiceType.proxy_wfs, layer.getServices());
List<String> attrs = WFSIntrospector.getAttrs(wfs);
for (String attr : attrs) {
if (Attributes.contains(attr)) {
Summary summary = makeSummary(layer, attr);
Item item = templateItem(template, attr, layer, summary);
items.add(item);
}
}
return items;
}
use of gov.usgs.cida.coastalhazards.model.summary.Summary in project coastal-hazards by USGS-CIDA.
the class PcoiTest method testGenerateSLD.
@Test
public void testGenerateSLD() {
Item item = new Item();
item.setAttr("PCOL1");
item.setId("abcde");
item.setType(Item.Type.storms);
List<Service> services = new LinkedList<>();
Service wmsService = new Service();
wmsService.setEndpoint("http://test");
wmsService.setServiceParameter("0");
wmsService.setType(ServiceType.source_wms);
services.add(wmsService);
item.setServices(services);
Summary summary = new Summary();
Tiny tiny = new Tiny();
tiny.setText("Pcoi");
summary.setTiny(tiny);
item.setSummary(summary);
SLDGenerator pcoi = new SLDGenerator(item, item.getId(), null, Pcoi.pcoi);
Response response = pcoi.generateSLD();
// TODO?
Viewable sld = (Viewable) response.getEntity();
}
use of gov.usgs.cida.coastalhazards.model.summary.Summary in project coastal-hazards by USGS-CIDA.
the class PcoiTest method testGenerateSLDInfo.
/**
* Test of generateSLDInfo method, of class Pcoi.
*/
@Test
public void testGenerateSLDInfo() {
Item item = new Item();
item.setAttr("PCOL1");
item.setId("abcde");
item.setType(Item.Type.storms);
List<Service> services = new LinkedList<>();
Service wmsService = new Service();
wmsService.setEndpoint("http://test");
wmsService.setServiceParameter("0");
wmsService.setType(ServiceType.source_wms);
services.add(wmsService);
item.setServices(services);
Summary summary = new Summary();
Tiny tiny = new Tiny();
tiny.setText("Pcoi");
summary.setTiny(tiny);
item.setSummary(summary);
SLDGenerator pcoi = new SLDGenerator(item, item.getId(), null, Pcoi.pcoi);
Response response = pcoi.generateSLDInfo();
String json = (String) response.getEntity();
Map<String, Object> sldInfo = new Gson().fromJson(json, HashMap.class);
List<Object> bins = (List) sldInfo.get("bins");
Map<String, Object> bin = (Map) bins.get(0);
Double lowerBound = (Double) bin.get("lowerBound");
String color = (String) bin.get("color");
assertEquals(lowerBound, 0.0f, 0.01f);
assertEquals(color, "#FFFFFE");
}
use of gov.usgs.cida.coastalhazards.model.summary.Summary in project coastal-hazards by USGS-CIDA.
the class RasterTest method testGenerateSLD.
@Test
public void testGenerateSLD() {
Item item = new Item();
// for rasters, this will stay the same. We may need a way to manage the type for a raster(ramp, intervals) etc as that is the volatile piece of data.
item.setAttr("GRAY_INDEX");
// may want h
item.setId("EHr6oLT5");
item.setType(Item.Type.vulnerability);
List<Service> services = new LinkedList<>();
Service wmsService = new Service();
wmsService.setEndpoint("http://test");
wmsService.setServiceParameter("0");
wmsService.setType(Service.ServiceType.source_wms);
services.add(wmsService);
item.setServices(services);
Summary summary = new Summary();
Tiny tiny = new Tiny();
tiny.setText("Coastal response to Sea Level");
summary.setTiny(tiny);
item.setSummary(summary);
SLDGenerator raster = new SLDGenerator(item, item.getId(), null, RasterAE.rasterConfig);
Response response = raster.generateSLD();
Viewable sld = (Viewable) response.getEntity();
}
Aggregations