Subversion Repositories hibernate-spatial

Rev

Rev 142 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
141 maesenka 1
/*
2
 * $Id$
3
 *
4
 * This file is part of Hibernate Spatial, an extension to the
5
 * hibernate ORM solution for geographic data.
6
 *
7
 * Copyright © 2009 Geovise BVBA
8
 *
9
 * This work was partially supported by the European Commission,
10
 * under the 6th Framework Programme, contract IST-2-004688-STP.
11
 *
12
 * This library is free software; you can redistribute it and/or
13
 * modify it under the terms of the GNU Lesser General Public
14
 * License as published by the Free Software Foundation; either
15
 * version 2.1 of the License, or (at your option) any later version.
16
 *
17
 * This library is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20
 * Lesser General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU Lesser General Public
23
 * License along with this library; if not, write to the Free Software
24
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
 *
26
 * For more information, visit: http://www.hibernatespatial.org/
27
 */
28
 
29
package org.hibernatespatial.sqlserver.convertors;
30
 
31
import org.junit.Test;
32
import org.junit.Before;
33
import static org.junit.Assert.assertTrue;
34
import static org.junit.Assert.fail;
35
import org.hibernatespatial.mgeom.MCoordinate;
36
 
37
import com.vividsolutions.jts.geom.Point;
38
import com.vividsolutions.jts.geom.Coordinate;
39
import static junit.framework.Assert.assertEquals;
40
 
41
import java.util.Arrays;
42
 
43
/**
44
 * @author Karel Maesen, Geovise BVBA.
45
 *         Date: Nov 2, 2009
46
 */
47
public class PointConvertorTest extends AbstractConvertorTest {
48
 
49
    @Before
50
    public void setup() {
51
        doDecoding(OpenGisType.POINT);
52
        doEncoding();
53
    }
54
 
55
    @Test
56
    public void test_verify_srid() {
57
        assertEquals(0, decodedGeoms.get(1).getSRID());
58
        assertEquals(4326, decodedGeoms.get(2).getSRID());
59
        assertEquals(31370, decodedGeoms.get(3).getSRID());
60
    }
61
 
62
    @Test
63
    public void test_class() {
64
        for (Integer id : decodedGeoms.keySet()) {
65
            assertEquals(Point.class, decodedGeoms.get(id).getClass());
66
        }
67
    }
68
 
69
    @Test
70
    public void test_coordinates() {
71
        Coordinate expected;
72
        Coordinate received;
73
        expected = new Coordinate(10.0, 5.0);
74
        assertEquals(expected, decodedGeoms.get(1).getCoordinate());
75
        expected = new Coordinate(52.25, 2.53);
76
        assertEquals(expected, decodedGeoms.get(2).getCoordinate());
77
        expected = new Coordinate(150000.0, 200000.0);
78
        assertEquals(expected, decodedGeoms.get(3).getCoordinate());
79
        expected = new MCoordinate(10.0, 2.0, 1.0, 3.0);
80
        assertEquals(expected, decodedGeoms.get(4).getCoordinate());
81
    }
82
 
83
    @Test
84
    public void test_encoding() {
85
        for (Integer id : encodedGeoms.keySet()) {
86
            assertTrue(Arrays.equals(rawResults.get(id), encodedGeoms.get(id)));
87
        }
88
    }
89
 
90
    @Test
91
    public void test_test_empty_point() {
92
        //TODO  -- How?
93
    }
94
 
95
    @Test
96
    public void test_no_srid() {
97
        //TODO -- How?
98
    }
99
 
100
 
101
}