| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
package org.locationtech.jts.geom.prep; |
| 13 |
|
| 14 |
import org.locationtech.jts.geom.Geometry; |
| 15 |
import org.locationtech.jts.geom.Lineal; |
| 16 |
import org.locationtech.jts.noding.FastSegmentSetIntersectionFinder; |
| 17 |
import org.locationtech.jts.noding.SegmentStringUtil; |
| 18 |
|
| 19 |
/** |
| 20 |
* A prepared version for {@link Lineal} geometries. |
| 21 |
* <p> |
| 22 |
* Instances of this class are thread-safe. |
| 23 |
* |
| 24 |
* @author mbdavis |
| 25 |
* |
| 26 |
*/ |
| 27 |
public class PreparedLineString |
| 28 |
extends BasicPreparedGeometry |
| 29 |
{ |
| 30 |
private FastSegmentSetIntersectionFinder segIntFinder = null; |
| 31 |
|
| 32 |
public PreparedLineString(Lineal line) { |
| 33 |
super((Geometry) line); |
| 34 |
} |
| 35 |
|
| 36 |
public synchronized FastSegmentSetIntersectionFinder getIntersectionFinder() |
| 37 |
{ |
| 38 |
/** |
| 39 |
* MD - Another option would be to use a simple scan for |
| 40 |
* segment testing for small geometries. |
| 41 |
* However, testing indicates that there is no particular advantage |
| 42 |
* to this approach. |
| 43 |
*/ |
| 44 |
if (segIntFinder == null) |
| 45 |
segIntFinder = new FastSegmentSetIntersectionFinder(SegmentStringUtil.extractSegmentStrings(getGeometry())); |
| 46 |
return segIntFinder; |
| 47 |
} |
| 48 |
|
| 49 |
public boolean intersects(Geometry g) |
| 50 |
{ |
| 51 |
if (! envelopesIntersect(g)) return false; |
| 52 |
return PreparedLineStringIntersects.intersects(this, g); |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* There's not much point in trying to optimize contains, since |
| 57 |
* contains for linear targets requires the entire test geometry |
| 58 |
* to exactly match the target linework. |
| 59 |
*/ |
| 60 |
} |
| 61 |
|