Search in sources :

Example 51 with DirectPositionType

use of org.geotoolkit.gml.xml.v311.DirectPositionType in project geotoolkit by Geomatys.

the class OGC200toGTTransformer method visitEnv.

public Expression visitEnv(final EnvelopeType entry) throws FactoryException {
    final String srs = entry.getSrsName();
    final DirectPositionType lower = entry.getLowerCorner();
    final DirectPositionType upper = entry.getUpperCorner();
    GeneralEnvelope genv = new GeneralEnvelope(CRS.forCode(srs));
    genv.setRange(0, lower.getOrdinate(0), upper.getOrdinate(0));
    genv.setRange(1, lower.getOrdinate(1), upper.getOrdinate(1));
    return filterFactory.literal(genv);
}
Also used : DirectPositionType(org.geotoolkit.gml.xml.v321.DirectPositionType) GeneralEnvelope(org.apache.sis.geometry.GeneralEnvelope)

Example 52 with DirectPositionType

use of org.geotoolkit.gml.xml.v311.DirectPositionType in project geotoolkit by Geomatys.

the class VectorType method getGeometry.

@Override
public AbstractGeometry getGeometry(final URI crs) {
    final org.geotoolkit.swe.xml.v100.CoordinateType lat = getLatitude();
    final org.geotoolkit.swe.xml.v100.CoordinateType lon = getLongitude();
    if (lat != null && lon != null) {
        final DirectPositionType dp = new DirectPositionType(lat.getQuantity().getValue(), lon.getQuantity().getValue());
        final PointType pt = new PointType(dp);
        if (crs != null) {
            pt.setSrsName(crs.toString());
        }
        return pt;
    }
    return null;
}
Also used : DirectPositionType(org.geotoolkit.gml.xml.v311.DirectPositionType) PointType(org.geotoolkit.gml.xml.v311.PointType)

Example 53 with DirectPositionType

use of org.geotoolkit.gml.xml.v311.DirectPositionType in project geotoolkit by Geomatys.

the class WmtsXmlBindingTest method marshallingTest.

/**
 * Test simple Record Marshalling.
 *
 * @throws java.lang.Exception
 */
@Test
public void marshallingTest() throws Exception {
    PointType pt = new PointType("p1", new DirectPositionType(-90.080000, 29.982000));
    TileMatrix matrix = new TileMatrix(new CodeType("16d"), 55218.001386, 256, 256, 3, 3);
    StringWriter sw = new StringWriter();
    marshaller.marshal(matrix, sw);
    String result = sw.toString();
    // System.out.println("RESULT:" + result);
    String expResult = "<TileMatrix xmlns=\"http://www.opengis.net/wmts/1.0\" xmlns:ows=\"http://www.opengis.net/ows/1.1\">" + '\n' + "    <ows:Identifier>16d</ows:Identifier>" + '\n' + "    <ScaleDenominator>55218.001386</ScaleDenominator>" + '\n' + "    <TileWidth>256</TileWidth>" + '\n' + "    <TileHeight>256</TileHeight>" + '\n' + "    <MatrixWidth>3</MatrixWidth>" + '\n' + "    <MatrixHeight>3</MatrixHeight>" + '\n' + "</TileMatrix>" + '\n';
    assertXmlEquals(expResult, result, "xmlns:*");
}
Also used : DirectPositionType(org.geotoolkit.gml.xml.v311.DirectPositionType) StringWriter(java.io.StringWriter) PointType(org.geotoolkit.gml.xml.v311.PointType) CodeType(org.geotoolkit.ows.xml.v110.CodeType)

Example 54 with DirectPositionType

use of org.geotoolkit.gml.xml.v311.DirectPositionType in project geotoolkit by Geomatys.

the class GmlXMLBindingTest method marshallingTest.

/**
 * Test simple Record Marshalling.
 *
 * @throws JAXBException
 */
@Test
public void marshallingTest() throws Exception {
    DirectPositionType lower = new DirectPositionType(-30.711, 134.196);
    DirectPositionType upper = new DirectPositionType(-30.702, 134.205);
    EnvelopeType env = new EnvelopeType("bound-1", lower, upper, "urn:ogc:def:crs:EPSG:6.8:4283");
    StringWriter sw = new StringWriter();
    marshaller.marshal(FACTORY.createEnvelope(env), sw);
    String result = sw.toString();
    // we remove the first line
    result = result.substring(result.indexOf("?>") + 2).trim();
    String expResult = "<gml:Envelope xmlns:gml=\"" + GML + '"' + " srsName=\"urn:ogc:def:crs:EPSG:6.8:4283\">" + '\n' + "  <gml:lowerCorner>-30.711 134.196</gml:lowerCorner>" + '\n' + "  <gml:upperCorner>-30.702 134.205</gml:upperCorner>" + '\n' + "</gml:Envelope>" + '\n';
    assertXmlEquals(expResult, result, "xmlns:*");
    Duration d1 = javax.xml.datatype.DatatypeFactory.newInstance().newDuration("P2D");
    TimePeriodType tp = new TimePeriodType(d1);
    marshaller.marshal(FACTORY.createTimePeriod(tp), sw);
    TimePositionType tpos = new TimePositionType("2002-08-15");
    tp = new TimePeriodType(tpos);
    marshaller.marshal(FACTORY.createTimePeriod(tp), sw);
    // System.out.println(sw.toString());
    LineStringSegmentType ls = new LineStringSegmentType();
    DirectPositionListType posList = new DirectPositionListType();
    posList.setValue(Arrays.asList(1.0, 1.1, 1.2));
    ls.setPosList(posList);
    sw = new StringWriter();
    marshaller.marshal(FACTORY.createLineStringSegment(ls), sw);
    result = sw.toString();
    // we remove the first line
    result = result.substring(result.indexOf("?>") + 2).trim();
    expResult = "<gml:LineStringSegment xmlns:gml=\"" + GML + "\">\n" + "  <gml:posList>1.0 1.1 1.2</gml:posList>" + '\n' + "</gml:LineStringSegment>" + '\n';
    assertXmlEquals(expResult, result, "xmlns:*");
    ls = new LineStringSegmentType();
    DirectPositionType pos1 = new DirectPositionType(Arrays.asList(1.1, 1.2));
    DirectPositionType pos2 = new DirectPositionType(Arrays.asList(2.3, 48.1));
    ls.getPos().add(pos1);
    ls.getPos().add(pos2);
    sw = new StringWriter();
    marshaller.marshal(FACTORY.createLineStringSegment(ls), sw);
    result = sw.toString();
    // we remove the first line
    result = result.substring(result.indexOf("?>") + 2).trim();
    expResult = "<gml:LineStringSegment xmlns:gml=\"" + GML + "\">\n" + "  <gml:pos>1.1 1.2</gml:pos>" + '\n' + "  <gml:pos>2.3 48.1</gml:pos>" + '\n' + "</gml:LineStringSegment>" + '\n';
    assertXmlEquals(expResult, result, "xmlns:*");
}
Also used : EnvelopeType(org.geotoolkit.gml.xml.v311.EnvelopeType) LineStringSegmentType(org.geotoolkit.gml.xml.v311.LineStringSegmentType) DirectPositionType(org.geotoolkit.gml.xml.v311.DirectPositionType) StringWriter(java.io.StringWriter) TimePeriodType(org.geotoolkit.gml.xml.v311.TimePeriodType) DirectPositionListType(org.geotoolkit.gml.xml.v311.DirectPositionListType) Duration(javax.xml.datatype.Duration) TimePositionType(org.geotoolkit.gml.xml.v311.TimePositionType)

Example 55 with DirectPositionType

use of org.geotoolkit.gml.xml.v311.DirectPositionType in project geotoolkit by Geomatys.

the class GeometrytoJTSTest method gmlPointToJTSTest3D.

@Test
public void gmlPointToJTSTest3D() throws Exception {
    Point expected = GF.createPoint(new Coordinate(0, 1, 1));
    expected.setSRID(2154);
    PointType gml = new PointType(new DirectPositionType(0.0, 1.0, 1.0));
    final Geometry result = GeometrytoJTS.toJTS(gml);
    Assert.assertEquals(expected, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) DirectPositionType(org.geotoolkit.gml.xml.v321.DirectPositionType) Coordinate(org.locationtech.jts.geom.Coordinate) PointType(org.geotoolkit.gml.xml.v321.PointType) ArcByCenterPointType(org.geotoolkit.gml.xml.v321.ArcByCenterPointType) Point(org.locationtech.jts.geom.Point) Test(org.junit.Test)

Aggregations

DirectPositionType (org.geotoolkit.gml.xml.v311.DirectPositionType)24 ArrayList (java.util.ArrayList)14 PointType (org.geotoolkit.gml.xml.v311.PointType)14 Test (org.junit.Test)11 StringWriter (java.io.StringWriter)10 DirectPositionType (net.opengis.gml.v_3_1_1.DirectPositionType)10 DirectPositionType (org.geotoolkit.gml.xml.v321.DirectPositionType)10 EnvelopeType (org.geotoolkit.gml.xml.v311.EnvelopeType)9 StringReader (java.io.StringReader)8 JAXBElement (javax.xml.bind.JAXBElement)8 EnvelopeType (net.opengis.gml.v_3_1_1.EnvelopeType)7 Geometry (org.locationtech.jts.geom.Geometry)7 Coordinate (org.locationtech.jts.geom.Coordinate)6 BBOXType (net.opengis.filter.v_1_1_0.BBOXType)5 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)5 DirectPositionType (net.opengis.gml.x32.DirectPositionType)4 FeaturePropertyType (org.geotoolkit.gml.xml.v311.FeaturePropertyType)4 SamplingPointType (org.geotoolkit.sampling.xml.v100.SamplingPointType)4 FilterType (net.opengis.filter.v_1_1_0.FilterType)3 DirectPositionType (net.opengis.gml.v_3_2_1.DirectPositionType)3