22 package org.matsim.core.utils.geometry;
24 import java.util.ArrayList;
25 import java.util.LinkedHashMap;
26 import java.util.List;
28 import java.util.Map.Entry;
29 import java.util.Random;
31 import org.geotools.api.feature.simple.SimpleFeature;
32 import org.geotools.geometry.jts.GeometryBuilder;
33 import org.locationtech.jts.geom.Coordinate;
34 import org.locationtech.jts.geom.Geometry;
35 import org.locationtech.jts.geom.GeometryFactory;
36 import org.locationtech.jts.geom.LineString;
37 import org.locationtech.jts.geom.Point;
38 import org.locationtech.jts.geom.Polygon;
82 Map<Link,LineString> segments =
new LinkedHashMap<>() ;
85 segments.put( link, theSegment ) ;
89 List<Link> resultList =
new ArrayList<>();
90 for ( Entry<Link, LineString> entry : segments.entrySet() ) {
91 if( lineString.intersects( entry.getValue() ) ){
92 resultList.add( entry.getKey() ) ;
107 LineString theSegment = GEOMETRY_FACTORY.createLineString(
new Coordinate[] { fromCoord, toCoord });
113 Point point = GEOMETRY_FACTORY.createPoint(coordinate);
120 double [] flatArray =
new double[coords.size()*2] ;
122 for (
Coord coord : coords ) {
123 flatArray[ii] = coord.getX() ;
125 flatArray[ii] = coord.getY() ;
128 return new GeometryBuilder().polygon( flatArray ) ;
148 x = ft.getBounds().getMinX() + rnd.nextDouble() * (ft.getBounds().getMaxX() - ft.getBounds().getMinX());
149 y = ft.getBounds().getMinY() + rnd.nextDouble() * (ft.getBounds().getMaxY() - ft.getBounds().getMinY());
151 }
while ( ! (((Geometry) ft.getDefaultGeometry()).contains(p)) );
static Polygon createGeotoolsPolygon(List< Coord > coords)
static final GeometryFactory GEOMETRY_FACTORY
static void assertNotNull(Object obj)
Map< Id< Link >, ? extends Link > getLinks()
static LineString createGeotoolsLineString(Link link)
static List< Link > findIntersectingLinks(LineString lineString, final Network network)
static Point createGeotoolsPoint(Coord coord)
static Point getRandomPointInFeature(Random rnd, SimpleFeature ft)
static List< Link > findIntersectingLinks(Link link, final Network network)