Search in sources :

Example 11 with ReferencedEnvelope

use of org.n52.shetland.util.ReferencedEnvelope 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 12 with ReferencedEnvelope

use of org.n52.shetland.util.ReferencedEnvelope 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 13 with ReferencedEnvelope

use of org.n52.shetland.util.ReferencedEnvelope 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 14 with ReferencedEnvelope

use of org.n52.shetland.util.ReferencedEnvelope in project arctic-sea by 52North.

the class OmEncoderv100 method getEnvelope.

private ReferencedEnvelope getEnvelope(List<OmObservation> sosObservationCollection) {
    ReferencedEnvelope sosEnvelope = new ReferencedEnvelope();
    sosObservationCollection.stream().map(o -> (SamplingFeature) o.getObservationConstellation().getFeatureOfInterest()).forEach(f -> {
        sosEnvelope.setSrid(f.getGeometry().getSRID());
        sosEnvelope.expandToInclude(f.getGeometry().getEnvelopeInternal());
    });
    return sosEnvelope;
}
Also used : SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) BooleanValue(org.n52.shetland.ogc.om.values.BooleanValue) GeometryObservationDocument(net.opengis.om.x10.GeometryObservationDocument) LoggerFactory(org.slf4j.LoggerFactory) SosConstants(org.n52.shetland.ogc.sos.SosConstants) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) Time(org.n52.shetland.ogc.gml.time.Time) MultiObservationValues(org.n52.shetland.ogc.om.MultiObservationValues) MeasurementDocument(net.opengis.om.x10.MeasurementDocument) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) TruthObservationType(net.opengis.om.x10.TruthObservationType) Map(java.util.Map) ObservationStream(org.n52.shetland.ogc.om.ObservationStream) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty) BigInteger(java.math.BigInteger) MeasurementType(net.opengis.om.x10.MeasurementType) ObservationCollectionDocument(net.opengis.om.x10.ObservationCollectionDocument) EncodingException(org.n52.svalbard.encode.exception.EncodingException) N52XmlHelper(org.n52.svalbard.util.N52XmlHelper) ImmutableSet(com.google.common.collect.ImmutableSet) XmlBoolean(org.apache.xmlbeans.XmlBoolean) XmlInteger(org.apache.xmlbeans.XmlInteger) Set(java.util.Set) CountValue(org.n52.shetland.ogc.om.values.CountValue) ObservationPropertyType(net.opengis.om.x10.ObservationPropertyType) GetObservationByIdResponse(org.n52.shetland.ogc.sos.response.GetObservationByIdResponse) Sets(com.google.common.collect.Sets) List(java.util.List) CountObservationDocument(net.opengis.om.x10.CountObservationDocument) GmlConstants(org.n52.shetland.ogc.gml.GmlConstants) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) SchemaLocation(org.n52.shetland.w3c.SchemaLocation) GeometryValue(org.n52.shetland.ogc.om.values.GeometryValue) CategoryValue(org.n52.shetland.ogc.om.values.CategoryValue) CollectionHelper(org.n52.shetland.util.CollectionHelper) ObservationType(net.opengis.om.x10.ObservationType) SweHelper(org.n52.svalbard.util.SweHelper) SupportedType(org.n52.shetland.ogc.SupportedType) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) Joiner(com.google.common.base.Joiner) GetObservationResponse(org.n52.shetland.ogc.sos.response.GetObservationResponse) OmConstants(org.n52.shetland.ogc.om.OmConstants) CategoryObservationType(net.opengis.om.x10.CategoryObservationType) StreamingValue(org.n52.shetland.ogc.om.StreamingValue) XmlHelper(org.n52.svalbard.util.XmlHelper) MediaType(org.n52.janmayen.http.MediaType) ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) OmObservation(org.n52.shetland.ogc.om.OmObservation) GmlHelper(org.n52.svalbard.util.GmlHelper) ObservationCollectionType(net.opengis.om.x10.ObservationCollectionType) ArrayList(java.util.ArrayList) TruthObservationDocument(net.opengis.om.x10.TruthObservationDocument) Inject(javax.inject.Inject) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) Strings(com.google.common.base.Strings) ObservationDocument(net.opengis.om.x10.ObservationDocument) OmCompositePhenomenon(org.n52.shetland.ogc.om.OmCompositePhenomenon) OMHelper(org.n52.shetland.util.OMHelper) SweConstants(org.n52.shetland.ogc.swe.SweConstants) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException) XmlObject(org.apache.xmlbeans.XmlObject) TextValue(org.n52.shetland.ogc.om.values.TextValue) LinkedList(java.util.LinkedList) CountObservationType(net.opengis.om.x10.CountObservationType) Sos2Constants(org.n52.shetland.ogc.sos.Sos2Constants) Logger(org.slf4j.Logger) DateTime(org.joda.time.DateTime) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport) GeometryObservationType(net.opengis.om.x10.GeometryObservationType) Sos1Constants(org.n52.shetland.ogc.sos.Sos1Constants) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) XmlString(org.apache.xmlbeans.XmlString) CodingHelper(org.n52.svalbard.util.CodingHelper) CategoryObservationDocument(net.opengis.om.x10.CategoryObservationDocument) Collections(java.util.Collections) ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)

Aggregations

ReferencedEnvelope (org.n52.shetland.util.ReferencedEnvelope)14 Test (org.junit.Test)9 Envelope (org.locationtech.jts.geom.Envelope)8 XmlObject (org.apache.xmlbeans.XmlObject)5 LinkedList (java.util.LinkedList)2 ObservationCollectionDocument (net.opengis.om.x10.ObservationCollectionDocument)2 ObservationCollectionType (net.opengis.om.x10.ObservationCollectionType)2 ObservationPropertyType (net.opengis.om.x10.ObservationPropertyType)2 XmlString (org.apache.xmlbeans.XmlString)2 DateTime (org.joda.time.DateTime)2 Geometry (org.locationtech.jts.geom.Geometry)2 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)2 EncodingException (org.n52.svalbard.encode.exception.EncodingException)2 Joiner (com.google.common.base.Joiner)1 Strings (com.google.common.base.Strings)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Sets (com.google.common.collect.Sets)1 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1