use of com.vividsolutions.jts.geom.Envelope in project openems by OpenEMS.
the class SymmetricPower method getAsSVG.
public static String getAsSVG(Geometry geometrie) {
StringBuffer text = new StringBuffer();
Envelope env = geometrie.getEnvelopeInternal();
String viewBox = env.getMinX() + " " + env.getMinY() + " " + env.getMaxX() * 2 + " " + env.getMaxY() * 2;
text.append("<?xml version='1.0' standalone='no'?>\n");
text.append("<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>\n");
text.append("<svg width='400' height='400' viewBox='" + viewBox + "' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>\n");
String color = "#" + Integer.toHexString(COLORS[0].getRGB()).substring(2);
String a = writeGeometryStyled(geometrie, color, color);
text.append(a + "\n");
text.append("\n");
text.append("</svg>\n");
return text.toString();
}
use of com.vividsolutions.jts.geom.Envelope in project coastal-hazards by USGS-CIDA.
the class Bbox method makeEnvelope.
public Envelope makeEnvelope() {
Envelope envelope = null;
if (bbox != null) {
Pattern pattern = Pattern.compile("BOX\\(\\s*([-\\d\\.]+)\\s+([-\\d\\.]+)\\s*,\\s*([-\\d\\.]+)\\s+([-\\d\\.]+)\\s*\\)");
Matcher matcher = pattern.matcher(bbox);
if (matcher.matches()) {
double minX = Double.parseDouble(matcher.group(1));
double minY = Double.parseDouble(matcher.group(2));
double maxX = Double.parseDouble(matcher.group(3));
double maxY = Double.parseDouble(matcher.group(4));
envelope = new Envelope(minX, maxX, minY, maxY);
}
}
return envelope;
}
use of com.vividsolutions.jts.geom.Envelope in project coastal-hazards by USGS-CIDA.
the class BboxAdapter method serialize.
@Override
public JsonElement serialize(Bbox src, Type typeOfSrc, JsonSerializationContext context) {
JsonArray bboxArray = new JsonArray();
Envelope envelope = src.makeEnvelope();
if (envelope != null) {
JsonPrimitive minx = new JsonPrimitive(envelope.getMinX());
JsonPrimitive miny = new JsonPrimitive(envelope.getMinY());
JsonPrimitive maxx = new JsonPrimitive(envelope.getMaxX());
JsonPrimitive maxy = new JsonPrimitive(envelope.getMaxY());
bboxArray.add(minx);
bboxArray.add(miny);
bboxArray.add(maxx);
bboxArray.add(maxy);
}
return bboxArray;
}
use of com.vividsolutions.jts.geom.Envelope in project coastal-hazards by USGS-CIDA.
the class BboxTest method testMakeEnvelopeEmpty.
@Test
public void testMakeEnvelopeEmpty() {
Bbox instance = new Bbox();
instance.setBbox("");
Envelope expResult = null;
Envelope result = instance.makeEnvelope();
assertThat(expResult, is(equalTo(result)));
}
use of com.vividsolutions.jts.geom.Envelope in project coastal-hazards by USGS-CIDA.
the class BboxTest method testMakeEnvelopeNull.
@Test
public void testMakeEnvelopeNull() {
Bbox instance = new Bbox();
instance.setBbox(null);
Envelope expResult = null;
Envelope result = instance.makeEnvelope();
assertThat(expResult, is(equalTo(result)));
}
Aggregations