| 54 |
maesenka |
1 |
/**
|
|
|
2 |
* $Id: MultiMLineStringTest.java 244 2010-10-01 20:55:56Z maesenka $
|
|
|
3 |
*
|
|
|
4 |
* This file is part of Hibernate Spatial, an extension to the
|
|
|
5 |
* hibernate ORM solution for geographic data.
|
| 181 |
maesenka |
6 |
*
|
| 54 |
maesenka |
7 |
* Copyright © 2007 Geovise BVBA
|
|
|
8 |
* Copyright © 2007 K.U. Leuven LRD, Spatial Applications Division, Belgium
|
|
|
9 |
*
|
|
|
10 |
* This work was partially supported by the European Commission,
|
|
|
11 |
* under the 6th Framework Programme, contract IST-2-004688-STP.
|
|
|
12 |
*
|
|
|
13 |
* This library is free software; you can redistribute it and/or
|
|
|
14 |
* modify it under the terms of the GNU Lesser General Public
|
|
|
15 |
* License as published by the Free Software Foundation; either
|
|
|
16 |
* version 2.1 of the License, or (at your option) any later version.
|
|
|
17 |
*
|
|
|
18 |
* This library is distributed in the hope that it will be useful,
|
|
|
19 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
20 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
21 |
* Lesser General Public License for more details.
|
|
|
22 |
*
|
|
|
23 |
* You should have received a copy of the GNU Lesser General Public
|
|
|
24 |
* License along with this library; if not, write to the Free Software
|
|
|
25 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
26 |
*
|
|
|
27 |
* For more information, visit: http://www.hibernatespatial.org/
|
|
|
28 |
*/
|
|
|
29 |
package org.hibernatespatial.test.mgeom;
|
|
|
30 |
|
| 181 |
maesenka |
31 |
import com.vividsolutions.jts.geom.Coordinate;
|
|
|
32 |
import com.vividsolutions.jts.geom.CoordinateSequence;
|
|
|
33 |
import com.vividsolutions.jts.geom.GeometryFactory;
|
| 54 |
maesenka |
34 |
import junit.framework.TestCase;
|
|
|
35 |
import org.hibernatespatial.mgeom.MCoordinate;
|
|
|
36 |
import org.hibernatespatial.mgeom.MCoordinateSequenceFactory;
|
|
|
37 |
import org.hibernatespatial.mgeom.MLineString;
|
|
|
38 |
import org.hibernatespatial.mgeom.MultiMLineString;
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
* @author Karel Maesen
|
|
|
42 |
*/
|
|
|
43 |
public class MultiMLineStringTest extends TestCase {
|
|
|
44 |
|
| 181 |
maesenka |
45 |
private final MCoordinateSequenceFactory mcfactory = MCoordinateSequenceFactory
|
|
|
46 |
.instance();
|
| 54 |
maesenka |
47 |
|
| 181 |
maesenka |
48 |
private final GeometryFactory geomfactory = new GeometryFactory(mcfactory);
|
| 54 |
maesenka |
49 |
|
| 181 |
maesenka |
50 |
protected MLineString ml1;
|
| 54 |
maesenka |
51 |
|
| 181 |
maesenka |
52 |
protected MLineString ml2;
|
| 54 |
maesenka |
53 |
|
| 181 |
maesenka |
54 |
protected MultiMLineString mm1;
|
| 54 |
maesenka |
55 |
|
| 181 |
maesenka |
56 |
protected MultiMLineString mmsimple;
|
| 54 |
maesenka |
57 |
|
| 181 |
maesenka |
58 |
protected MCoordinate lastco;
|
| 54 |
maesenka |
59 |
|
| 181 |
maesenka |
60 |
public static void main(String[] args) {
|
|
|
61 |
junit.textui.TestRunner.run(MultiMLineStringTest.class);
|
|
|
62 |
}
|
| 54 |
maesenka |
63 |
|
| 181 |
maesenka |
64 |
/*
|
|
|
65 |
* @see TestCase#setUp()
|
|
|
66 |
*/
|
| 54 |
maesenka |
67 |
|
| 181 |
maesenka |
68 |
protected void setUp() throws Exception {
|
|
|
69 |
super.setUp();
|
| 54 |
maesenka |
70 |
|
| 181 |
maesenka |
71 |
MCoordinate mc0 = new MCoordinate(0.0, 0.0, 0.0, 0.0);
|
|
|
72 |
MCoordinate mc1 = new MCoordinate(1.0, 0.0, 0.0, 0.1);
|
|
|
73 |
MCoordinate mc2 = new MCoordinate(1.0, 1.0, 0.0, 0.2);
|
|
|
74 |
MCoordinate mc3 = new MCoordinate(5.0, 1.0, 0.0, 0.3);
|
|
|
75 |
MCoordinate mc4 = new MCoordinate(5.0, 3.0, 0.0, 0.4);
|
|
|
76 |
lastco = mc4;
|
| 54 |
maesenka |
77 |
|
| 181 |
maesenka |
78 |
MCoordinate[] m1 = {mc0, mc1, mc2};
|
|
|
79 |
MCoordinate[] m2 = {mc3, mc4};
|
| 54 |
maesenka |
80 |
|
| 181 |
maesenka |
81 |
CoordinateSequence mseq1 = mcfactory.create(m1);
|
|
|
82 |
ml1 = new MLineString(mseq1, geomfactory);
|
| 54 |
maesenka |
83 |
|
| 181 |
maesenka |
84 |
CoordinateSequence mseq2 = mcfactory.create(m2);
|
|
|
85 |
ml2 = new MLineString(mseq2, geomfactory);
|
| 54 |
maesenka |
86 |
|
| 181 |
maesenka |
87 |
mmsimple = new MultiMLineString(new MLineString[]{ml1}, 0.1,
|
|
|
88 |
geomfactory);
|
|
|
89 |
mm1 = new MultiMLineString(new MLineString[]{ml1, ml2}, 0.1,
|
|
|
90 |
geomfactory);
|
| 54 |
maesenka |
91 |
|
| 181 |
maesenka |
92 |
}
|
| 54 |
maesenka |
93 |
|
| 181 |
maesenka |
94 |
/*
|
|
|
95 |
* @see TestCase#tearDown()
|
|
|
96 |
*/
|
| 54 |
maesenka |
97 |
|
| 181 |
maesenka |
98 |
protected void tearDown() throws Exception {
|
|
|
99 |
super.tearDown();
|
|
|
100 |
}
|
| 54 |
maesenka |
101 |
|
| 181 |
maesenka |
102 |
public void testMaxM() {
|
|
|
103 |
assertEquals(0.4, mm1.getMaxM(), 0.000001);
|
|
|
104 |
}
|
| 54 |
maesenka |
105 |
|
| 181 |
maesenka |
106 |
/*
|
| 244 |
maesenka |
107 |
* Class under testsuite-suite for java.lang.String getGeometryType()
|
| 181 |
maesenka |
108 |
*/
|
| 54 |
maesenka |
109 |
|
| 181 |
maesenka |
110 |
public void testGetGeometryType() {
|
|
|
111 |
assertTrue("wrong type reported", mm1.getGeometryType()
|
|
|
112 |
.equalsIgnoreCase("multimlinestring"));
|
|
|
113 |
}
|
| 54 |
maesenka |
114 |
|
| 181 |
maesenka |
115 |
public void testGetDimension() {
|
|
|
116 |
// TODO Implement getDimension().
|
|
|
117 |
}
|
| 54 |
maesenka |
118 |
|
| 181 |
maesenka |
119 |
public void testGetBoundary() {
|
|
|
120 |
// TODO Implement getBoundary().
|
|
|
121 |
}
|
| 54 |
maesenka |
122 |
|
| 181 |
maesenka |
123 |
public void testGetBoundaryDimension() {
|
|
|
124 |
// TODO Implement getBoundaryDimension().
|
|
|
125 |
}
|
| 54 |
maesenka |
126 |
|
| 181 |
maesenka |
127 |
/*
|
| 244 |
maesenka |
128 |
* Class under testsuite-suite for boolean
|
| 181 |
maesenka |
129 |
* equalsExact(com.vividsolutions.jts.geom.Geometry, double)
|
|
|
130 |
*/
|
| 54 |
maesenka |
131 |
|
| 181 |
maesenka |
132 |
public void testEqualsExactGeometrydouble() {
|
|
|
133 |
// TODO Implement equalsExact().
|
|
|
134 |
}
|
| 54 |
maesenka |
135 |
|
| 181 |
maesenka |
136 |
/*
|
| 244 |
maesenka |
137 |
* Class under testsuite-suite for void
|
| 181 |
maesenka |
138 |
* MultiLineString(com.vividsolutions.jts.geom.LineString[],
|
|
|
139 |
* com.vividsolutions.jts.geom.PrecisionModel, int)
|
|
|
140 |
*/
|
| 54 |
maesenka |
141 |
|
| 181 |
maesenka |
142 |
public void testMultiLineStringLineStringArrayPrecisionModelint() {
|
|
|
143 |
// TODO Implement MultiLineString().
|
|
|
144 |
}
|
| 54 |
maesenka |
145 |
|
| 181 |
maesenka |
146 |
/*
|
| 244 |
maesenka |
147 |
* Class under testsuite-suite for void
|
| 181 |
maesenka |
148 |
* MultiLineString(com.vividsolutions.jts.geom.LineString[],
|
|
|
149 |
* com.vividsolutions.jts.geom.GeometryFactory)
|
|
|
150 |
*/
|
| 54 |
maesenka |
151 |
|
| 181 |
maesenka |
152 |
public void testMultiLineStringLineStringArrayGeometryFactory() {
|
|
|
153 |
// TODO Implement MultiLineString().
|
|
|
154 |
}
|
|
|
155 |
|
|
|
156 |
public void testIsClosed() {
|
|
|
157 |
// TODO Implement isClosed().
|
|
|
158 |
}
|
|
|
159 |
|
|
|
160 |
public void testClone() {
|
|
|
161 |
// TODO implement
|
|
|
162 |
|
|
|
163 |
}
|
|
|
164 |
|
|
|
165 |
public void testInterpolate() {
|
|
|
166 |
mm1.measureOnLength(false);
|
|
|
167 |
Coordinate[] ca = mm1.getCoordinates();
|
|
|
168 |
assertTrue("co 0 not OK", ((MCoordinate) ca[0]).m == 0.0);
|
|
|
169 |
assertTrue("co 1 not OK",
|
|
|
170 |
Math.abs(((MCoordinate) ca[1]).m - 1.0) < 0.00001);
|
|
|
171 |
assertTrue("co 2 not OK",
|
|
|
172 |
Math.abs(((MCoordinate) ca[2]).m - 2.0) < 0.00001);
|
|
|
173 |
assertTrue("co 3 not OK", Math.abs(((MCoordinate) ca[3]).m
|
|
|
174 |
- (2.0 + mm1.getMGap())) < 0.00001);
|
|
|
175 |
assertTrue("co 4 not OK", Math.abs(((MCoordinate) ca[4]).m
|
|
|
176 |
- (4.0 + mm1.getMGap())) < 0.00001);
|
|
|
177 |
|
|
|
178 |
double dist = mm1.getLength();
|
|
|
179 |
dist += (mm1.getNumGeometries() - 1) * mm1.getMGap();
|
|
|
180 |
assertTrue("interpolation not consistent with distance", Math
|
|
|
181 |
.abs(((MCoordinate) ca[4]).m - dist) < 0.00001);
|
|
|
182 |
|
|
|
183 |
}
|
|
|
184 |
|
| 54 |
maesenka |
185 |
}
|