Class TaggedLineSegment

 1 /*
 2  * Copyright (c) 2016 Vivid Solutions.
 3  *
 4  * All rights reserved. This program and the accompanying materials
 5  * are made available under the terms of the Eclipse Public License 2.0
 6  * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
 7  * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v20.html
 8  * and the Eclipse Distribution License is available at
 9  *
10  * http://www.eclipse.org/org/documents/edl-v10.php.
11  */
12  
13 package org.locationtech.jts.simplify;
14  
15 import org.locationtech.jts.geom.Coordinate;
16 import org.locationtech.jts.geom.Geometry;
17 import org.locationtech.jts.geom.LineSegment;
18  
19 /**
20  * A {@link LineSegment} which is tagged with its location in a parent {@link Geometry}.
21  * Used to index the segments in a geometry and recover the segment locations
22  * from the index.
23  */
24 class TaggedLineSegment
25     extends LineSegment
26 {
27   private Geometry parent;
28   private int index;
29  
30   public TaggedLineSegment(Coordinate p0, Coordinate p1, Geometry parent, int index) {
31     super(p0, p1);
32     this.parent = parent;
33     this.index = index;
34   }
35  
36   public TaggedLineSegment(Coordinate p0, Coordinate p1) {
37     this(p0, p1, null, -1);
38   }
39  
40   public Geometry getParent() { return parent; }
41   public int getIndex() { return index; }
42 }
43