use of gov.usgs.cida.coastalhazards.model.Bbox in project coastal-hazards by USGS-CIDA.
the class TemplateResource method templateItem.
private Item templateItem(Item template, String attr, Layer layer, Summary summary) {
String newId = IdGenerator.generate();
Item newItem = new Item();
newItem.setAttr(attr);
boolean isRibbonable = Attributes.getRibbonableAttrs().contains(attr);
List<Service> services = layer.getServices();
Bbox bbox = layer.getBbox();
List<Service> serviceCopies = new LinkedList<>();
for (Service service : services) {
serviceCopies.add(Service.copyValues(service, null));
}
newItem.setServices(serviceCopies);
newItem.setItemType(Item.ItemType.data);
newItem.setSummary(summary);
newItem.setId(newId);
newItem.setBbox(Bbox.copyValues(bbox, new Bbox()));
newItem.setActiveStorm(template.isActiveStorm());
newItem.setRibbonable(isRibbonable);
newItem.setType(template.getType());
newItem.setName(template.getName());
return newItem;
}
use of gov.usgs.cida.coastalhazards.model.Bbox in project coastal-hazards by USGS-CIDA.
the class MetadataUtil method getBoundingBoxFromFgdcMetadata.
public static Bbox getBoundingBoxFromFgdcMetadata(String inMetadata) throws JAXBException, UnsupportedEncodingException {
Bbox bbox = new Bbox();
// parse out the WGS84 bbox from the metadata xml
Metadata metadata = null;
// JAXB will require jaxb-api.jar and jaxb-impl.jar part of java 1.6. Much safer way to interrogate xml and maintain than regex
try {
JAXBContext jaxbContext = JAXBContext.newInstance(Metadata.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
metadata = (Metadata) jaxbUnmarshaller.unmarshal(new ByteArrayInputStream(inMetadata.getBytes("UTF-8")));
} catch (JAXBException e) {
// schema used https: www.fgdc.gov/schemas/metadata/fgdc-std-001-1998-sect01.xsd
log.error("Unable to parse xml file. Has the schema changed? https://www.fgdc.gov/schemas/metadata/fgdc-std-001-1998-sect01.xsd :" + e.getMessage());
throw e;
}
Idinfo idinfo = metadata.getIdinfo();
Spdom spdom = idinfo.getSpdom();
Bounding bounding = spdom.getBounding();
double minx = bounding.getWestbc();
double miny = bounding.getSouthbc();
double maxx = bounding.getEastbc();
double maxy = bounding.getNorthbc();
Bbox result = new Bbox();
result.setBbox(minx, miny, maxx, maxy);
bbox.setBbox(minx, miny, maxx, maxy);
return bbox;
}
Aggregations