use of org.codice.alliance.nsili.common.UCO.Rectangle in project alliance by codice.
the class SampleNsiliClient method createFileOrder.
private OrderContents createFileOrder(Product product, String[] supportedPackagingSpecs, String filename) throws Exception {
NameName[] nameName = { new NameName("", "") };
String orderPackageId = UUID.randomUUID().toString();
TailoringSpec tailoringSpec = new TailoringSpec(nameName);
PackagingSpec pSpec = new PackagingSpec(orderPackageId, supportedPackagingSpecs[0]);
Calendar cal = Calendar.getInstance();
cal.setTime(new java.util.Date());
int year = cal.get(Calendar.YEAR);
year++;
AbsTime needByDate = new AbsTime(new Date((short) year, (short) 2, (short) 10), new Time((short) 10, (short) 0, (short) 0));
MediaType[] mTypes = { new MediaType("", (short) 1) };
String[] benums = new String[0];
Rectangle region = new Rectangle(new Coordinate2d(1.1, 1.1), new Coordinate2d(2.2, 2.2));
ImageSpec imageSpec = new ImageSpec();
imageSpec.encoding = SupportDataEncoding.ASCII;
imageSpec.rrds = new short[] { 1 };
imageSpec.algo = "";
imageSpec.bpp = 0;
imageSpec.comp = "A";
imageSpec.imgform = "A";
imageSpec.imageid = "1234abc";
imageSpec.geo_region_type = GeoRegionType.LAT_LON;
Rectangle subSection = new Rectangle();
subSection.lower_right = new Coordinate2d(0, 0);
subSection.upper_left = new Coordinate2d(1, 1);
imageSpec.sub_section = subSection;
Any imageSpecAny = orb.create_any();
ImageSpecHelper.insert(imageSpecAny, imageSpec);
AlterationSpec aSpec = new AlterationSpec("JPEG", imageSpecAny, region, GeoRegionType.NULL_REGION);
FileLocation fileLocation = new FileLocation("user", "pass", "localhost", "/nsili/file", filename);
Destination destination = new Destination();
destination.f_dest(fileLocation);
ProductDetails[] productDetails = { new ProductDetails(mTypes, benums, aSpec, product, ALLIANCE) };
DeliveryDetails[] deliveryDetails = { new DeliveryDetails(destination, "", "") };
return new OrderContents(ALLIANCE, tailoringSpec, pSpec, needByDate, "Give me an order!", (short) 1, productDetails, deliveryDetails);
}
use of org.codice.alliance.nsili.common.UCO.Rectangle in project alliance by codice.
the class DAGGenerator method getRandomRectangle.
private static Rectangle getRandomRectangle() {
int x = getRandomNumber(-75, 75);
int y = getRandomNumber(-175, 175);
return new Rectangle(new Coordinate2d(x, y), new Coordinate2d(x + 5, y + 5));
}
use of org.codice.alliance.nsili.common.UCO.Rectangle in project alliance by codice.
the class ResultDAGConverter method addSpatialGeoRefBoxAttribute.
private static void addSpatialGeoRefBoxAttribute(DirectedAcyclicGraph<Node, Edge> graph, Metacard metacard, ORB orb, List<String> resultAttributes, List<String> addedAttributes, String attribute, Node coverageNode) {
if (shouldAdd(buildAttr(attribute, NsiliConstants.SPATIAL_GEOGRAPHIC_REF_BOX), resultAttributes)) {
Attribute geoAttr = metacard.getAttribute(Core.LOCATION);
if (geoAttr != null) {
String wktGeo = String.valueOf(geoAttr.getValue());
try {
Geometry boundingGeo = WKTUtil.getWKTBoundingRectangle(wktGeo);
Rectangle rect = NsiliGeomUtil.getRectangle(boundingGeo);
addGeomAttribute(graph, coverageNode, NsiliConstants.SPATIAL_GEOGRAPHIC_REF_BOX, rect, orb);
addedAttributes.add(buildAttr(attribute, NsiliConstants.SPATIAL_GEOGRAPHIC_REF_BOX));
} catch (ParseException pe) {
LOGGER.debug("Unable to parse WKT for bounding box: {}", wktGeo, pe);
}
}
}
}
use of org.codice.alliance.nsili.common.UCO.Rectangle in project alliance by codice.
the class NsiliGeomUtil method getRectangle.
public static Rectangle getRectangle(Geometry boundingGeo) {
Rectangle boundingRect = null;
if (boundingGeo.getCoordinates().length == 5) {
// JTS bounding GEO is in the form of a Polygon whose points are (minx, miny), (maxx, miny),
// (maxx, maxy), (minx, maxy), (minx, miny).
Coordinate upperLeft = boundingGeo.getCoordinates()[3];
Coordinate lowerRight = boundingGeo.getCoordinates()[1];
boundingRect = new Rectangle();
boundingRect.lower_right = new Coordinate2d(lowerRight.x, lowerRight.y);
boundingRect.upper_left = new Coordinate2d(upperLeft.x, upperLeft.y);
}
return boundingRect;
}
use of org.codice.alliance.nsili.common.UCO.Rectangle in project alliance by codice.
the class SampleNsiliClient method createEmailOrder.
private OrderContents createEmailOrder(ORB orb, Product product, String[] supportedPackagingSpecs) throws Exception {
NameName[] nameName = { new NameName("", "") };
String orderPackageId = UUID.randomUUID().toString();
TailoringSpec tailoringSpec = new TailoringSpec(nameName);
PackagingSpec pSpec = new PackagingSpec(orderPackageId, supportedPackagingSpecs[0]);
Calendar cal = Calendar.getInstance();
cal.setTime(new java.util.Date());
int year = cal.get(Calendar.YEAR);
year++;
AbsTime needByDate = new AbsTime(new Date((short) year, (short) 2, (short) 10), new Time((short) 10, (short) 0, (short) 0));
MediaType[] mTypes = { new MediaType("", (short) 1) };
String[] benums = new String[0];
Rectangle region = new Rectangle(new Coordinate2d(1.1, 1.1), new Coordinate2d(2.2, 2.2));
ImageSpec imageSpec = new ImageSpec();
imageSpec.encoding = SupportDataEncoding.ASCII;
imageSpec.rrds = new short[] { 1 };
imageSpec.algo = "";
imageSpec.bpp = 0;
imageSpec.comp = "A";
imageSpec.imgform = "A";
imageSpec.imageid = "1234abc";
imageSpec.geo_region_type = GeoRegionType.LAT_LON;
Rectangle subSection = new Rectangle();
subSection.lower_right = new Coordinate2d(0, 0);
subSection.upper_left = new Coordinate2d(1, 1);
imageSpec.sub_section = subSection;
Any imageSpecAny = orb.create_any();
ImageSpecHelper.insert(imageSpecAny, imageSpec);
AlterationSpec aSpec = new AlterationSpec("JPEG", imageSpecAny, region, GeoRegionType.NULL_REGION);
Destination destination = new Destination();
destination.e_dest(emailAddress);
ProductDetails[] productDetails = { new ProductDetails(mTypes, benums, aSpec, product, ALLIANCE) };
DeliveryDetails[] deliveryDetails = { new DeliveryDetails(destination, "", "") };
return new OrderContents(ALLIANCE, tailoringSpec, pSpec, needByDate, "Give me an order!", (short) 1, productDetails, deliveryDetails);
}
Aggregations