Search in sources :

Example 31 with Envelope

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();
}
Also used : LineString(com.vividsolutions.jts.geom.LineString) Envelope(com.vividsolutions.jts.geom.Envelope)

Example 32 with Envelope

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;
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Envelope(com.vividsolutions.jts.geom.Envelope)

Example 33 with 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;
}
Also used : JsonArray(com.google.gson.JsonArray) JsonPrimitive(com.google.gson.JsonPrimitive) Envelope(com.vividsolutions.jts.geom.Envelope)

Example 34 with Envelope

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)));
}
Also used : Envelope(com.vividsolutions.jts.geom.Envelope) Test(org.junit.Test)

Example 35 with Envelope

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)));
}
Also used : Envelope(com.vividsolutions.jts.geom.Envelope) Test(org.junit.Test)

Aggregations

Envelope (com.vividsolutions.jts.geom.Envelope)111 Coordinate (com.vividsolutions.jts.geom.Coordinate)21 Node (org.locationtech.geogig.api.Node)16 Geometry (com.vividsolutions.jts.geom.Geometry)13 ObjectId (org.locationtech.geogig.api.ObjectId)13 ReferencedEnvelope (org.geotools.geometry.jts.ReferencedEnvelope)12 STRtree (com.vividsolutions.jts.index.strtree.STRtree)11 ArrayList (java.util.ArrayList)11 Vertex (org.opentripplanner.routing.graph.Vertex)11 Test (org.junit.Test)9 NodeRef (org.locationtech.geogig.api.NodeRef)9 Edge (org.opentripplanner.routing.graph.Edge)9 LineString (com.vividsolutions.jts.geom.LineString)8 RevTree (org.locationtech.geogig.api.RevTree)8 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)7 Map (java.util.Map)6 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)6 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)6 RevFeature (org.locationtech.geogig.api.RevFeature)5 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)5