Search in sources :

Example 1 with Tiny

use of gov.usgs.cida.coastalhazards.model.summary.Tiny in project coastal-hazards by USGS-CIDA.

the class StormUtil method buildStormTemplateSummary.

public static Summary buildStormTemplateSummary(Layer layer) {
    Summary summary = new Summary();
    Document cswDoc = getStormCswDocument(layer);
    if (cswDoc != null) {
        String title = MetadataUtil.extractFirstStringFromCswDoc(cswDoc, "/*/metadata/idinfo/citation/citeinfo/title");
        Map<String, String> titleParts = parseTitleParts(title);
        String cswAbstract = MetadataUtil.extractFirstStringFromCswDoc(cswDoc, "/*/metadata/idinfo/descript/abstract");
        List<String> dataSrcList = MetadataUtil.extractStringsFromCswDoc(cswDoc, "/*/metadata/dataqual/lineage/srcinfo/srccite/citeinfo/title");
        String surgeDescription = buildSurgeDescription(cswDoc);
        Tiny tiny = buildTinyText(titleParts);
        Medium medium = buildMediumText(titleParts);
        Full full = buildFullText(titleParts, title, surgeDescription);
        Legend legend = buildLegendText(titleParts);
        summary.setTiny(tiny);
        summary.setMedium(medium);
        summary.setFull(full);
        summary.setLegend(legend);
    }
    return summary;
}
Also used : Legend(gov.usgs.cida.coastalhazards.model.summary.Legend) Medium(gov.usgs.cida.coastalhazards.model.summary.Medium) Tiny(gov.usgs.cida.coastalhazards.model.summary.Tiny) Summary(gov.usgs.cida.coastalhazards.model.summary.Summary) Document(org.w3c.dom.Document) Full(gov.usgs.cida.coastalhazards.model.summary.Full)

Example 2 with Tiny

use of gov.usgs.cida.coastalhazards.model.summary.Tiny 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();
}
Also used : Response(javax.ws.rs.core.Response) Item(gov.usgs.cida.coastalhazards.model.Item) Tiny(gov.usgs.cida.coastalhazards.model.summary.Tiny) Viewable(org.glassfish.jersey.server.mvc.Viewable) Service(gov.usgs.cida.coastalhazards.model.Service) Summary(gov.usgs.cida.coastalhazards.model.summary.Summary) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 3 with Tiny

use of gov.usgs.cida.coastalhazards.model.summary.Tiny 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");
}
Also used : Tiny(gov.usgs.cida.coastalhazards.model.summary.Tiny) Service(gov.usgs.cida.coastalhazards.model.Service) Gson(com.google.gson.Gson) LinkedList(java.util.LinkedList) Response(javax.ws.rs.core.Response) Item(gov.usgs.cida.coastalhazards.model.Item) Summary(gov.usgs.cida.coastalhazards.model.summary.Summary) List(java.util.List) LinkedList(java.util.LinkedList) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 4 with Tiny

use of gov.usgs.cida.coastalhazards.model.summary.Tiny 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();
}
Also used : Response(javax.ws.rs.core.Response) Item(gov.usgs.cida.coastalhazards.model.Item) Tiny(gov.usgs.cida.coastalhazards.model.summary.Tiny) Viewable(org.glassfish.jersey.server.mvc.Viewable) Service(gov.usgs.cida.coastalhazards.model.Service) Summary(gov.usgs.cida.coastalhazards.model.summary.Summary) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 5 with Tiny

use of gov.usgs.cida.coastalhazards.model.summary.Tiny in project coastal-hazards by USGS-CIDA.

the class ShorelineTest method testGenerateSLDInfo.

/**
 * Test of generateSLDInfo method, of class Shoreline.
 */
@Test
public void testGenerateSLDInfo() {
    Item item = new Item();
    item.setAttr("Date_");
    item.setId("abcde");
    item.setType(Item.Type.historical);
    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("Shoreline");
    summary.setTiny(tiny);
    item.setSummary(summary);
    SLDGenerator shoreline = new SLDGenerator(item, item.getId(), null, Shorelines.shorelines);
    Response response = shoreline.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 year0 = ((List<Double>) bin.get("years")).get(0);
    String color = (String) bin.get("color");
    assertEquals(year0, 0.0f, 0.01f);
    assertEquals(color, "#ff0000");
}
Also used : Tiny(gov.usgs.cida.coastalhazards.model.summary.Tiny) Service(gov.usgs.cida.coastalhazards.model.Service) Gson(com.google.gson.Gson) LinkedList(java.util.LinkedList) Response(javax.ws.rs.core.Response) Item(gov.usgs.cida.coastalhazards.model.Item) Summary(gov.usgs.cida.coastalhazards.model.summary.Summary) List(java.util.List) LinkedList(java.util.LinkedList) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Tiny (gov.usgs.cida.coastalhazards.model.summary.Tiny)8 Summary (gov.usgs.cida.coastalhazards.model.summary.Summary)7 Item (gov.usgs.cida.coastalhazards.model.Item)6 Service (gov.usgs.cida.coastalhazards.model.Service)6 LinkedList (java.util.LinkedList)6 Response (javax.ws.rs.core.Response)6 Test (org.junit.Test)6 Gson (com.google.gson.Gson)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 Viewable (org.glassfish.jersey.server.mvc.Viewable)3 Full (gov.usgs.cida.coastalhazards.model.summary.Full)1 Legend (gov.usgs.cida.coastalhazards.model.summary.Legend)1 Medium (gov.usgs.cida.coastalhazards.model.summary.Medium)1 Document (org.w3c.dom.Document)1