Subversion Repositories hibernate-spatial

Rev

Rev 155 | Rev 159 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 155 Rev 156
Line 1... Line 1...
1
/*
1
/*
2
 * $Id: MultiPointDecoder.java 155 2010-01-13 21:00:35Z maesenka $
2
 * $Id: MultiPointDecoder.java 156 2010-01-28 22:59:30Z maesenka $
3
 *
3
 *
4
 * This file is part of Hibernate Spatial, an extension to the
4
 * This file is part of Hibernate Spatial, an extension to the
5
 * hibernate ORM solution for geographic data.
5
 * hibernate ORM solution for geographic data.
6
 *
6
 *
7
 * Copyright © 2009 Geovise BVBA
7
 * Copyright © 2009 Geovise BVBA
Line 29... Line 29...
29
import com.vividsolutions.jts.geom.MultiPoint;
29
import com.vividsolutions.jts.geom.MultiPoint;
30
import com.vividsolutions.jts.geom.Point;
30
import com.vividsolutions.jts.geom.Point;
31
 
31
 
32
public class MultiPointDecoder extends AbstractDecoder<MultiPoint> {
32
public class MultiPointDecoder extends AbstractDecoder<MultiPoint> {
33
 
33
 
-
 
34
 
-
 
35
    @Override
34
    public boolean accepts(SqlGeometryV1 nativeGeom) {
36
    protected OpenGisType getOpenGisType() {
35
        return nativeGeom.openGisType() == OpenGisType.MULTIPOINT;
37
         return OpenGisType.MULTIPOINT;
36
    }
38
    }
37
 
39
 
38
    protected MultiPoint createNullGeometry() {
40
    protected MultiPoint createNullGeometry() {
39
        return getGeometryFactory().createMultiPoint(new Point[]{});
41
        return getGeometryFactory().createMultiPoint(new Point[]{});
40
    }
42
    }
41
 
43
 
42
    protected MultiPoint createGeometry(SqlGeometryV1 nativeGeom) {
44
    protected MultiPoint createGeometry(SqlGeometryV1 nativeGeom) {
-
 
45
        //optimized multipoint decoding
43
        Coordinate[] coords = new Coordinate[nativeGeom.getNumPoints()];
46
        Coordinate[] coords = new Coordinate[nativeGeom.getNumPoints()];
44
        for (int cIdx = 0; cIdx < nativeGeom.getNumPoints(); cIdx++) {
47
        for (int cIdx = 0; cIdx < nativeGeom.getNumPoints(); cIdx++) {
45
            coords[cIdx] = nativeGeom.getCoordinate(cIdx);
48
            coords[cIdx] = nativeGeom.getCoordinate(cIdx);
46
        }
49
        }
47
        return getGeometryFactory().createMultiPoint(coords);
50
        return getGeometryFactory().createMultiPoint(coords);
48
    }
51
    }
49
 
52
 
-
 
53
    @Override
-
 
54
    protected MultiPoint createGeometry(SqlGeometryV1 nativeGeom, int shapeIndex) {
-
 
55
        int startChildIdx = shapeIndex + 1;
-
 
56
        int endchildIdx = nativeGeom.getEndChildShape(shapeIndex);
-
 
57
        Coordinate[] coordinates = new Coordinate[endchildIdx - startChildIdx];
-
 
58
        for (int i = 0 ; i < coordinates.length; i++){
-
 
59
            int figureOffset = nativeGeom.getStartFigureForShape(startChildIdx++);
-
 
60
            int pntIdx = nativeGeom.getStartPointForFigure(figureOffset);
-
 
61
            coordinates[i]  = nativeGeom.getCoordinate(pntIdx);
-
 
62
        }
-
 
63
        return getGeometryFactory().createMultiPoint(coordinates);
-
 
64
    }
-
 
65
 
50
 
66
 
51
}
67
}