5
* The JTS Topology Suite is a collection of Java classes that
6
* implement the fundamental operations required to validate a given
7
* geo-spatial data set to a known topological specification.
9
* Copyright (C) 2001 Vivid Solutions
11
* This library is free software; you can redistribute it and/or
12
* modify it under the terms of the GNU Lesser General Public
13
* License as published by the Free Software Foundation; either
14
* version 2.1 of the License, or (at your option) any later version.
16
* This library is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
* Lesser General Public License for more details.
21
* You should have received a copy of the GNU Lesser General Public
22
* License along with this library; if not, write to the Free Software
23
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
* For more information, contact:
29
* 2328 Government Street
34
* www.vividsolutions.com
36
package com.vividsolutions.jts.noding;
39
* Represents a point on an
40
* edge which intersects with another edge.
42
* The intersection may either be a single point, or a line segment
43
* (in which case this point is the start of the line segment)
44
* The label attached to this intersection point applies to
45
* the edge from this point forwards, until the next
46
* intersection or the end of the edge.
47
* The intersection point must be precise.
50
import java.io.PrintStream;
51
import com.vividsolutions.jts.geom.Coordinate;
54
* Represents an intersection point between two {@link SegmentString}s.
58
public class SegmentNode
62
public Coordinate coord; // the point of intersection
63
public int segmentIndex; // the index of the containing line segment in the parent edge
64
public double dist; // the edge distance of this point along the containing line segment
67
public SegmentNode(Coordinate coord, int segmentIndex, double dist) {
69
this.coord = new Coordinate(coord);
70
this.segmentIndex = segmentIndex;
72
//label = new Label();
76
* @return -1 this EdgeIntersection is located before the argument location
77
* @return 0 this EdgeIntersection is at the argument location
78
* @return 1 this EdgeIntersection is located after the argument location
80
public int compare(int segmentIndex, double dist)
82
if (this.segmentIndex < segmentIndex) return -1;
83
if (this.segmentIndex > segmentIndex) return 1;
84
if (this.dist < dist) return -1;
85
if (this.dist > dist) return 1;
89
public boolean isEndPoint(int maxSegmentIndex)
91
if (segmentIndex == 0 && dist == 0.0) return true;
92
if (segmentIndex == maxSegmentIndex) return true;
96
public int compareTo(Object obj)
98
SegmentNode other = (SegmentNode) obj;
99
return compare(other.segmentIndex, other.dist);
102
public void print(PrintStream out)
105
out.print(" seg # = " + segmentIndex);
106
out.println(" dist = " + dist);