Search in sources :

Example 41 with JGeometry

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

the class JGeometryConverter method convert.

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

Example 42 with JGeometry

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

the class JGeometryConverter method convertCollection.

// FIXME
private static GeometryCollection convertCollection(JGeometry geometry) {
    JGeometry[] elements = geometry.getElements();
    if (elements == null || elements.length == 0) {
        return GeometryCollection.createEmpty();
    }
    Geometry[] geometries = new Geometry[elements.length];
    for (int i = 0; i < elements.length; i++) {
        geometries[i] = convert(elements[i]);
    }
    return new GeometryCollection(geometries);
}
Also used : JGeometry(oracle.spatial.geometry.JGeometry) JGeometry(oracle.spatial.geometry.JGeometry) Point(org.geolatte.geom.Point)

Example 43 with JGeometry

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

the class JGeometryConverter method convertMultiPoint.

private static MultiPoint convertMultiPoint(JGeometry geometry) {
    CrsId crs = CrsId.valueOf(geometry.getSRID());
    JGeometry[] elements = geometry.getElements();
    if (elements == null || elements.length == 0) {
        return MultiPoint.createEmpty();
    }
    Point[] points = new Point[elements.length];
    int dimensions = geometry.getDimensions();
    double[] ordinates = geometry.getOrdinatesArray();
    boolean measured = geometry.isLRSGeometry();
    DimensionalFlag flag = DimensionalFlag.valueOf(dimensions > (measured ? 3 : 2), measured);
    int offset = 0;
    for (int i = 0; i < points.length; i++) {
        double[] coords = new double[dimensions];
        System.arraycopy(ordinates, offset, coords, 0, coords.length);
        points[i] = new Point(PointCollectionFactory.create(coords, flag, crs));
        offset += dimensions;
    }
    return new MultiPoint(points);
}
Also used : JGeometry(oracle.spatial.geometry.JGeometry) CrsId(org.geolatte.geom.crs.CrsId) Point(org.geolatte.geom.Point) Point(org.geolatte.geom.Point)

Example 44 with JGeometry

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

the class JGeometryConverter method convert.

private static JGeometry convert(Polygon geometry) {
    int srid = geometry.getSRID();
    int dim = geometry.getCoordinateDimension();
    double[] points = getPoints(geometry.getPoints());
    int[] elemInfo = new int[3 + geometry.getNumInteriorRing() * 3];
    int offset = 0;
    int pointOffset = 1;
    elemInfo[offset++] = pointOffset;
    // exterior
    elemInfo[offset++] = 1003;
    elemInfo[offset++] = 1;
    pointOffset += geometry.getExteriorRing().getNumPoints() * dim;
    for (int i = 0; i < geometry.getNumInteriorRing(); i++) {
        elemInfo[offset++] = pointOffset;
        elemInfo[offset++] = 2003;
        elemInfo[offset++] = 1;
        pointOffset += geometry.getInteriorRingN(i).getNumPoints() * dim;
    }
    int gtype = dim * 1000 + (geometry.isMeasured() ? dim : 0) * 100 + GTYPE_POLYGON;
    return new JGeometry(gtype, srid, elemInfo, points);
}
Also used : JGeometry(oracle.spatial.geometry.JGeometry) Point(org.geolatte.geom.Point)

Example 45 with JGeometry

use of oracle.spatial.geometry.JGeometry in project ili2db by claeis.

the class OracleColumnConverter method toIomCoord.

@Override
public IomObject toIomCoord(Object geomobj, String sqlAttrName, boolean is3D) throws java.sql.SQLException, ConverterException {
    JGeometry geometry = JGeometry.load((oracle.sql.STRUCT) geomobj);
    if (geometry.getType() != JGeometry.GTYPE_POINT) {
        throw new ConverterException("unexpected GTYPE (" + OracleUtility.gtype2str(geometry.getType()) + ")");
    } else {
        int dim = geometry.getDimensions();
        boolean isCurrentValue3D = (dim == 3);
        if (isCurrentValue3D != is3D) {
            throw new ConverterException("unexpected dimension (" + Integer.toString(dim) + ")");
        } else {
            double[] valuev = geometry.getFirstPoint();
            IomObject coord = new Iom_jObject("COORD", null);
            coord.setattrvalue("C1", Double.toString(valuev[0]));
            coord.setattrvalue("C2", Double.toString(valuev[1]));
            if (dim == 3) {
                coord.setattrvalue("C3", Double.toString(valuev[2]));
            }
            return coord;
        }
    }
}
Also used : ConverterException(ch.ehi.ili2db.converter.ConverterException) IomObject(ch.interlis.iom.IomObject) JGeometry(oracle.spatial.geometry.JGeometry) Iom_jObject(ch.interlis.iom_j.Iom_jObject)

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