Search in sources :

Example 16 with Envelope

use of org.locationtech.jts.geom.Envelope in project arctic-sea by 52North.

the class ReferencedEnvelopeTest method testEquals.

@Test
public void testEquals() {
    assertThat(new ReferencedEnvelope().equals(null), is(false));
    assertThat(new ReferencedEnvelope().equals(new Object()), is(false));
    assertThat(new ReferencedEnvelope().equals(emptyReferencedEnvelope), is(true));
    assertThat(originEnvelope.equals(emptyReferencedEnvelope), is(false));
    final ReferencedEnvelope otherEnvelope = new ReferencedEnvelope(extensionEnvelope, 52);
    final ReferencedEnvelope myEnvelope = new ReferencedEnvelope(extensionEnvelope, 1024);
    assertThat(otherEnvelope.equals(myEnvelope), is(false));
    final ReferencedEnvelope anEnvelope = new ReferencedEnvelope(new Envelope(1.0, 2.0, 3.0, 4.0), 52);
    final ReferencedEnvelope anotherEnvelope = new ReferencedEnvelope(null, 52);
    assertThat(anEnvelope.equals(anotherEnvelope), is(false));
    assertThat(anEnvelope.equals(anEnvelope), is(true));
    assertThat(anotherEnvelope.equals(anEnvelope), is(false));
}
Also used : ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) Envelope(org.locationtech.jts.geom.Envelope) Test(org.junit.Test)

Example 17 with Envelope

use of org.locationtech.jts.geom.Envelope in project arctic-sea by 52North.

the class ReferencedEnvelopeTest method testExpandToIncludeEnvelopeWithNull.

@Test
public void testExpandToIncludeEnvelopeWithNull() throws Exception {
    final Envelope e = null;
    originEnvelope.expandToInclude(e);
    assertThat(originEnvelope.isSetSrid(), is(true));
    assertThat(originEnvelope.getSrid(), is(srid));
    assertThat(originEnvelope.isSetEnvelope(), is(true));
    final Envelope envelope = originEnvelope.getEnvelope();
    assertThat(envelope.getArea(), is(1.0));
    assertThat(envelope.getMinX(), is(0.0));
    assertThat(envelope.getMaxX(), is(1.0));
    assertThat(envelope.getMinY(), is(0.0));
    assertThat(envelope.getMaxY(), is(1.0));
}
Also used : ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) Envelope(org.locationtech.jts.geom.Envelope) Test(org.junit.Test)

Example 18 with Envelope

use of org.locationtech.jts.geom.Envelope in project arctic-sea by 52North.

the class ReferencedEnvelopeTest method setUpEnvelopes.

@Before
public void setUpEnvelopes() {
    extensionEnvelope = new Envelope(x21, x22, y21, y22);
    originEnvelope = new ReferencedEnvelope(new Envelope(x11, x12, y11, y12), srid);
    emptyReferencedEnvelope = new ReferencedEnvelope();
    emptyEnvelope = new Envelope();
}
Also used : ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) Envelope(org.locationtech.jts.geom.Envelope) Before(org.junit.Before)

Example 19 with Envelope

use of org.locationtech.jts.geom.Envelope in project arctic-sea by 52North.

the class SweEnvelopeTest method should_create_valid_sosSweEnvelope_from_sosEnvelope.

@Test
public void should_create_valid_sosSweEnvelope_from_sosEnvelope() {
    final int srid = 52;
    final double x1 = 1;
    final double y1 = 2;
    final double y2 = 3;
    final double x2 = 4;
    final BigDecimal bx1 = new BigDecimal(x1);
    final BigDecimal by1 = new BigDecimal(y1);
    final BigDecimal by2 = new BigDecimal(y2);
    final BigDecimal bx2 = new BigDecimal(x2);
    final String uom = "deg";
    final ReferencedEnvelope sosEnvelope = new ReferencedEnvelope(new Envelope(x1, x2, y1, y2), srid);
    final SweEnvelope sweEnvelope = new SweEnvelope(sosEnvelope, uom, false);
    // srid
    assertThat(sweEnvelope.getReferenceFrame(), is(Integer.toString(srid)));
    // x1
    final List<? extends SweCoordinate<?>> lcCoordinates = sweEnvelope.getLowerCorner().getCoordinates();
    assertThat(((BigDecimal) lcCoordinates.get(0).getValue().getValue()), is(bx1));
    // y1
    assertThat(((BigDecimal) lcCoordinates.get(1).getValue().getValue()), is(by1));
    // x2
    final List<? extends SweCoordinate<?>> ucCoordinates = sweEnvelope.getUpperCorner().getCoordinates();
    assertThat(((BigDecimal) ucCoordinates.get(0).getValue().getValue()), is(bx2));
    // y2
    assertThat(((BigDecimal) ucCoordinates.get(1).getValue().getValue()), is(by2));
    // uom
    assertThat(((SweQuantity) lcCoordinates.get(0).getValue()).getUom(), is(uom));
    assertThat(((SweQuantity) lcCoordinates.get(1).getValue()).getUom(), is(uom));
    assertThat(((SweQuantity) ucCoordinates.get(0).getValue()).getUom(), is(uom));
    assertThat(((SweQuantity) ucCoordinates.get(1).getValue()).getUom(), is(uom));
    // northing
    assertThat(lcCoordinates.get(0).getName(), is(SweCoordinateNames.EASTING));
    assertThat(ucCoordinates.get(0).getName(), is(SweCoordinateNames.EASTING));
    // easting
    assertThat(lcCoordinates.get(1).getName(), is(SweCoordinateNames.NORTHING));
    assertThat(ucCoordinates.get(1).getName(), is(SweCoordinateNames.NORTHING));
}
Also used : ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) Envelope(org.locationtech.jts.geom.Envelope) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 20 with Envelope

use of org.locationtech.jts.geom.Envelope in project arctic-sea by 52North.

the class GetCapabilitiesResponseEncoder method encodeOffering.

private JsonNode encodeOffering(SosObservationOffering soo) throws EncodingException {
    if (soo == null) {
        return nodeFactory().nullNode();
    }
    ObjectNode jsoo = nodeFactory().objectNode();
    SosOffering offering = soo.getOffering();
    jsoo.put(JSONConstants.IDENTIFIER, offering.getIdentifier());
    if (offering.isSetName()) {
        jsoo.put(JSONConstants.NAME, offering.getFirstName().getValue());
    }
    if (soo.isSetProcedures()) {
        jsoo.set(JSONConstants.PROCEDURE, soo.getProcedures().stream().map(nodeFactory()::textNode).collect(toJsonArray()));
    }
    if (soo.isSetObservableProperties()) {
        jsoo.set(JSONConstants.OBSERVABLE_PROPERTY, soo.getObservableProperties().stream().map(nodeFactory()::textNode).collect(toJsonArray()));
    }
    if (soo.isSetRelatedFeature()) {
        ArrayNode jrf = jsoo.putArray(JSONConstants.RELATED_FEATURE);
        soo.getRelatedFeatures().forEach((feature, roles) -> {
            jrf.addObject().put(JSONConstants.FEATURE_OF_INTEREST, feature).set(JSONConstants.ROLE, roles.stream().map(nodeFactory()::textNode).collect(toJsonArray()));
        });
    }
    if (soo.isSetObservedArea() && soo.getObservedArea().isSetEnvelope() && soo.getObservedArea().isSetSrid()) {
        Envelope e = soo.getObservedArea().getEnvelope();
        ObjectNode oa = jsoo.putObject(JSONConstants.OBSERVED_AREA);
        oa.putArray(JSONConstants.LOWER_LEFT).add(e.getMinX()).add(e.getMinY());
        oa.putArray(JSONConstants.UPPER_RIGHT).add(e.getMaxX()).add(e.getMaxY());
        oa.putObject(JSONConstants.CRS).put(JSONConstants.TYPE, JSONConstants.LINK).putObject(JSONConstants.PROPERTIES).put(JSONConstants.HREF, GeoJSONEncoder.SRID_LINK_PREFIX + soo.getObservedArea().getSrid());
    }
    if (soo.isSetPhenomenonTime()) {
        jsoo.set(JSONConstants.PHENOMENON_TIME, encodeObjectToJson(soo.getPhenomenonTime()));
    }
    if (soo.isSetResultTime()) {
        jsoo.set(JSONConstants.RESULT_TIME, encodeObjectToJson(soo.getResultTime()));
    }
    if (soo.isSetResponseFormats()) {
        jsoo.set(JSONConstants.RESPONSE_FORMAT, soo.getResponseFormats().stream().map(nodeFactory()::textNode).collect(toJsonArray()));
    }
    if (soo.isSetObservationTypes()) {
        jsoo.set(JSONConstants.OBSERVATION_TYPE, soo.getObservationTypes().stream().map(nodeFactory()::textNode).collect(toJsonArray()));
    }
    if (soo.isSetFeatureOfInterestTypes()) {
        jsoo.set(JSONConstants.FEATURE_OF_INTEREST_TYPE, soo.getFeatureOfInterestTypes().stream().map(nodeFactory()::textNode).collect(toJsonArray()));
    }
    if (soo.isSetProcedureDescriptionFormats()) {
        jsoo.set(JSONConstants.PROCEDURE_DESCRIPTION_FORMAT, soo.getProcedureDescriptionFormats().stream().map(nodeFactory()::textNode).collect(toJsonArray()));
    }
    // TODO soo.getResponseModes();
    return jsoo;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SosOffering(org.n52.shetland.ogc.sos.SosOffering) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Envelope(org.locationtech.jts.geom.Envelope)

Aggregations

Envelope (org.locationtech.jts.geom.Envelope)20 ReferencedEnvelope (org.n52.shetland.util.ReferencedEnvelope)13 Test (org.junit.Test)11 Geometry (org.locationtech.jts.geom.Geometry)4 ValueGeometry (org.h2.value.ValueGeometry)3 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)3 XmlObject (org.apache.xmlbeans.XmlObject)2 SpatialKey (org.h2.mvstore.rtree.SpatialKey)2 Value (org.h2.value.Value)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 BigDecimal (java.math.BigDecimal)1 Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 BBOXType (net.opengis.fes.x20.BBOXType)1 EnvelopeType (net.opengis.swe.x101.EnvelopeType)1 Coordinate (net.opengis.swe.x101.VectorType.Coordinate)1 VersionedValue (org.h2.mvstore.db.TransactionStore.VersionedValue)1 SimpleResultSet (org.h2.tools.SimpleResultSet)1