1 | package org.openstreetmap.josm.testframework;
|
---|
2 |
|
---|
3 | import java.util.Arrays;
|
---|
4 | import java.util.Collection;
|
---|
5 | import java.util.LinkedList;
|
---|
6 |
|
---|
7 | import junit.framework.TestCase;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.Main;
|
---|
10 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
11 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
12 | import org.openstreetmap.josm.data.osm.Node;
|
---|
13 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
14 | import org.openstreetmap.josm.data.osm.Segment;
|
---|
15 | import org.openstreetmap.josm.data.osm.Way;
|
---|
16 | import org.openstreetmap.josm.data.projection.Epsg4326;
|
---|
17 |
|
---|
18 | public class MotherObject extends TestCase {
|
---|
19 |
|
---|
20 | @Override protected void setUp() throws Exception {
|
---|
21 | super.setUp();
|
---|
22 | Main.proj = new Epsg4326();
|
---|
23 | }
|
---|
24 |
|
---|
25 | public Node createNode(int id) {
|
---|
26 | return createNode(id, 0, 0);
|
---|
27 | }
|
---|
28 |
|
---|
29 | public Node createNode(int id, double lat, double lon) {
|
---|
30 | Node n = createNode(lat, lon);
|
---|
31 | n.id = id;
|
---|
32 | return n;
|
---|
33 | }
|
---|
34 |
|
---|
35 | public Node createNode() {
|
---|
36 | return createNode(Math.random()*360-180, Math.random()*180-90);
|
---|
37 | }
|
---|
38 |
|
---|
39 | public Node createNode(double lat, double lon) {
|
---|
40 | return new Node(new LatLon(lat,lon));
|
---|
41 | }
|
---|
42 |
|
---|
43 |
|
---|
44 | public Segment createSegment(long id) {
|
---|
45 | Segment s = createSegment();
|
---|
46 | s.id = id;
|
---|
47 | return s;
|
---|
48 | }
|
---|
49 | public Segment createSegment(long id, Node from, Node to) {
|
---|
50 | Segment s = new Segment(from, to);
|
---|
51 | s.id = id;
|
---|
52 | return s;
|
---|
53 | }
|
---|
54 | public Segment createSegment() {
|
---|
55 | return new Segment(createNode(), createNode());
|
---|
56 | }
|
---|
57 |
|
---|
58 |
|
---|
59 | public Way createWay() {
|
---|
60 | return createWay(0);
|
---|
61 | }
|
---|
62 | public Way createWay(Segment... segments) {
|
---|
63 | return createWay(0, segments);
|
---|
64 | }
|
---|
65 | public Way createWay(long id, Segment... segments) {
|
---|
66 | Way way = new Way();
|
---|
67 | way.segments.addAll(Arrays.asList(segments));
|
---|
68 | way.id = id;
|
---|
69 | return way;
|
---|
70 | }
|
---|
71 |
|
---|
72 | public DataSet createDataSet() {
|
---|
73 | DataSet ds = new DataSet();
|
---|
74 | Node node1 = createNode();
|
---|
75 | Node node2 = createNode();
|
---|
76 | Node node3 = createNode();
|
---|
77 | Segment segment = createSegment(23, node1, node2);
|
---|
78 | Way way = createWay(42, segment);
|
---|
79 | ds.nodes.add(node1);
|
---|
80 | ds.nodes.add(node2);
|
---|
81 | ds.nodes.add(node3);
|
---|
82 | ds.segments.add(segment);
|
---|
83 | ds.ways.add(way);
|
---|
84 | return ds;
|
---|
85 | }
|
---|
86 |
|
---|
87 | public void assertContainsSame(Collection<OsmPrimitive> data, OsmPrimitive... all) {
|
---|
88 | Collection<OsmPrimitive> copy = new LinkedList<OsmPrimitive>(data);
|
---|
89 | copy.removeAll(Arrays.asList(all));
|
---|
90 | assertEquals(0, copy.size());
|
---|
91 | }
|
---|
92 |
|
---|
93 | /**
|
---|
94 | * To have JUnit shut up.
|
---|
95 | */
|
---|
96 | public void test() {
|
---|
97 | }
|
---|
98 | }
|
---|