Last change
on this file since 5075 was 5075, checked in by gabriel, 18 years ago |
Import the latest upstream version of utilsplugin.
|
File size:
2.2 KB
|
Line | |
---|
1 | package UtilsPlugin.JosmLint;
|
---|
2 |
|
---|
3 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
4 | import org.openstreetmap.josm.data.osm.Node;
|
---|
5 | import org.openstreetmap.josm.data.osm.Segment;
|
---|
6 | import org.openstreetmap.josm.data.osm.Way;
|
---|
7 |
|
---|
8 | public class ConsistancyTest implements JosmLintTest {
|
---|
9 | private class NullSegmentResult extends JosmLintTestResult
|
---|
10 | {
|
---|
11 | public NullSegmentResult( Segment o, ConsistancyTest c )
|
---|
12 | {
|
---|
13 | super( o, c );
|
---|
14 | }
|
---|
15 | public String toString()
|
---|
16 | {
|
---|
17 | return "Null segment: "+ObjectDescr(obj);
|
---|
18 | }
|
---|
19 | }
|
---|
20 | private class DuplicateSegmentResult extends JosmLintTestResult
|
---|
21 | {
|
---|
22 | private Segment seg;
|
---|
23 | public DuplicateSegmentResult( Way o, ConsistancyTest c, Segment bad )
|
---|
24 | {
|
---|
25 | super( o, c );
|
---|
26 | seg = bad;
|
---|
27 | }
|
---|
28 | public String toString()
|
---|
29 | {
|
---|
30 | return "Duplicate segment: "+ObjectDescr(obj);
|
---|
31 | }
|
---|
32 | public void cloneFrom(DuplicateSegmentResult res)
|
---|
33 | {
|
---|
34 | this.obj = res.obj;
|
---|
35 | this.test = res.test;
|
---|
36 | this.seg = res.seg;
|
---|
37 | }
|
---|
38 | }
|
---|
39 | public ConsistancyTest() {}
|
---|
40 |
|
---|
41 | public JosmLintTestResult runTest( OsmPrimitive o )
|
---|
42 | {
|
---|
43 | if( o instanceof Node )
|
---|
44 | return null;
|
---|
45 | if( o instanceof Segment )
|
---|
46 | {
|
---|
47 | Segment s = (Segment)o;
|
---|
48 | if( !s.incomplete && s.from == s.to )
|
---|
49 | return new NullSegmentResult( s, this );
|
---|
50 | }
|
---|
51 | if( o instanceof Way )
|
---|
52 | {
|
---|
53 | Way w = (Way)o;
|
---|
54 | for ( Segment s : w.segments )
|
---|
55 | {
|
---|
56 | if( w.segments.indexOf(s) != w.segments.lastIndexOf(s) )
|
---|
57 | return new DuplicateSegmentResult( w, this, s );
|
---|
58 | }
|
---|
59 | }
|
---|
60 | return null;
|
---|
61 | }
|
---|
62 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.