Search in sources :

Example 1 with JGeometry

use of oracle.spatial.geometry.JGeometry in project querydsl by querydsl.

the class JGeometryConverterTest method polygon.

@Test
public void polygon() {
    Polygon polygon = (org.geolatte.geom.Polygon) Wkt.fromWkt("POLYGON (" + "(30 10, 40 40, 20 40, 10 20, 30 10), " + "(20 30, 35 35, 30 20, 20 30))");
    JGeometry geo = JGeometryConverter.convert(polygon);
    double[] extRing = new double[] { 30, 10, 40, 40, 20, 40, 10, 20, 30, 10 };
    double[] intRing = new double[] { 20, 30, 35, 35, 30, 20, 20, 30 };
    JGeometry geo2 = JGeometry.createLinearPolygon(new Object[] { extRing, intRing }, polygon.getCoordinateDimension(), polygon.getSRID());
    assertEquals(geo2, geo);
}
Also used : JGeometry(oracle.spatial.geometry.JGeometry) Test(org.junit.Test)

Example 2 with JGeometry

use of oracle.spatial.geometry.JGeometry in project querydsl by querydsl.

the class JGeometryConverterTest method roundTrip.

@Test
public void roundTrip() {
    List<Geometry> geometries = getGeometries();
    for (Geometry geometry : geometries) {
        if (geometry instanceof MultiPolygon) {
            continue;
        }
        if (geometry instanceof GeometryCollection) {
            continue;
        }
        System.err.println(Wkt.toWkt(geometry));
        JGeometry converted = JGeometryConverter.convert(geometry);
        Geometry back = JGeometryConverter.convert(converted);
        assertEquals(geometry, back);
    }
}
Also used : JGeometry(oracle.spatial.geometry.JGeometry) JGeometry(oracle.spatial.geometry.JGeometry) Test(org.junit.Test)

Example 3 with JGeometry

use of oracle.spatial.geometry.JGeometry in project querydsl by querydsl.

the class JGeometryConverter method convertMultiCurve.

// FIXME
private static MultiLineString convertMultiCurve(JGeometry geometry) {
    JGeometry[] elements = geometry.getElements();
    if (elements == null || elements.length == 0) {
        return MultiLineString.createEmpty();
    }
    CrsId crs = CrsId.valueOf(geometry.getSRID());
    LineString[] lineStrings = new LineString[elements.length];
    for (int i = 0; i < elements.length; i++) {
        PointSequence points = getPoints(elements[i]);
        lineStrings[i] = new LineString(points);
    }
    return new MultiLineString(lineStrings);
}
Also used : JGeometry(oracle.spatial.geometry.JGeometry) CrsId(org.geolatte.geom.crs.CrsId) Point(org.geolatte.geom.Point)

Example 4 with JGeometry

use of oracle.spatial.geometry.JGeometry in project querydsl by querydsl.

the class JGeometryConverter method convert.

private static JGeometry convert(MultiPoint geometry) {
    int srid = geometry.getSRID();
    int dim = geometry.getCoordinateDimension();
    double[] points = getPoints(geometry.getPoints());
    int[] elemInfo = new int[] { 1, 1, geometry.getNumPoints() };
    int gtype = dim * 1000 + (geometry.isMeasured() ? dim : 0) * 100 + GTYPE_MULTIPOINT;
    return new JGeometry(gtype, srid, elemInfo, points);
}
Also used : JGeometry(oracle.spatial.geometry.JGeometry) Point(org.geolatte.geom.Point)

Example 5 with JGeometry

use of oracle.spatial.geometry.JGeometry in project querydsl by querydsl.

the class JGeometryConverter method convertMultiPolygon.

// FIXME
private static MultiPolygon convertMultiPolygon(JGeometry geometry) {
    JGeometry[] elements = geometry.getElements();
    if (elements == null || elements.length == 0) {
        return MultiPolygon.createEmpty();
    }
    Polygon[] polygons = new Polygon[elements.length];
    for (int i = 0; i < elements.length; i++) {
        polygons[i] = convertPolygon(elements[i]);
    }
    return new MultiPolygon(polygons);
}
Also used : JGeometry(oracle.spatial.geometry.JGeometry) Point(org.geolatte.geom.Point)

Aggregations

JGeometry (oracle.spatial.geometry.JGeometry)65 PersistenceManager (javax.jdo.PersistenceManager)46 Transaction (javax.jdo.Transaction)46 List (java.util.List)37 Query (javax.jdo.Query)37 SampleGeometry (org.datanucleus.samples.jgeometry.SampleGeometry)25 Point (org.geolatte.geom.Point)8 ConverterException (ch.ehi.ili2db.converter.ConverterException)4 IomObject (ch.interlis.iom.IomObject)4 Iom_jObject (ch.interlis.iom_j.Iom_jObject)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 CrsId (org.geolatte.geom.crs.CrsId)2 SQLException (java.sql.SQLException)1 STRUCT (oracle.sql.STRUCT)1 SampleGeometry3D (org.datanucleus.samples.jgeometry.SampleGeometry3D)1 SampleGeometryM (org.datanucleus.samples.jgeometry.SampleGeometryM)1