本文整理了Java中com.vividsolutions.jts.geom.Geometry.contains()
方法的一些代码示例,展示了Geometry.contains()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.contains()
方法的具体详情如下:
包路径:com.vividsolutions.jts.geom.Geometry
类名称:Geometry
方法名:contains
[英]Tests whether this geometry contains the argument geometry.
The contains
predicate has the following equivalent definitions:
[T*****FF*]
g.within(this) = true
contains
is the converse of #within )B.contains(A) = false
. (As a concrete example, take A to be a LineString which lies in the boundary of a Polygon B.) For a predicate with similar behaviour but avoiding this subtle limitation, see #covers.contains
谓词具有以下等效定义:[T*****FF*]
匹配g.within(this) = true
contains
是#in的反义词)B.contains(A) = false
。(作为一个具体的例子,假设a是一个位于多边形B边界的线字符串。)对于具有类似行为但避免这种微妙限制的谓词,请参见#covers。代码示例来源:origin: opentripplanner/OpenTripPlanner
@Override
public boolean filter(Individual individual) {
Coordinate coord = new Coordinate(individual.lon, individual.lat);
Point pt = gf.createPoint(coord);
boolean accept = hull.contains(pt);
//LOG.debug("label {} accept {}", individual.label, accept);
return accept;
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
@Override
public String resolve(double x, double y) {
System.out.println("x="+x+", y="+y);
FeatureIterator<Feature> iterator = collection.features();
while( iterator.hasNext() ){
SimpleFeature feature = (SimpleFeature) iterator.next();
Geometry geom = (Geometry) feature.getDefaultGeometry();
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
Coordinate coord = new Coordinate(x, y);
Point point = geometryFactory.createPoint(coord);
//System.out.println("checking "+point.toString());
if(geom.contains(point)) {
return feature.getAttribute(this.nameField).toString();
}
}
return null;
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
/**
* Safely add a vertex to this area. This creates edges to all other vertices unless those edges would cross one of the original edges.
*/
public void addVertex(IntersectionVertex newVertex, Graph graph) {
GeometryFactory geometryFactory = GeometryUtils.getGeometryFactory();
if (edges.size() == 0) {
throw new RuntimeException("Can't add a vertex to an empty area");
}
@SuppressWarnings("unchecked")
HashSet<IntersectionVertex> verticesCopy = (HashSet<IntersectionVertex>) vertices.clone();
VERTEX: for (IntersectionVertex v : verticesCopy) {
LineString newGeometry = geometryFactory.createLineString(new Coordinate[] {
newVertex.getCoordinate(), v.getCoordinate() });
// ensure that new edge does not leave the bounds of the original area, or
// fall into any holes
if (!originalEdges.union(originalEdges.getBoundary()).contains(newGeometry)) {
continue VERTEX;
}
// check to see if this splits multiple NamedAreas. This code is rather similar to
// code in OSMGBI, but the data structures are different
createSegments(newVertex, v, areas, graph);
}
vertices.add(newVertex);
}
代码示例来源:origin: com.vividsolutions/jts
/**
* Default implementation.
*/
public boolean contains(Geometry g)
{
return baseGeom.contains(g);
}
代码示例来源:origin: com.vividsolutions/jts
return g.contains(this);
代码示例来源:origin: opentripplanner/OpenTripPlanner
LineString segment = (LineString) mls.getGeometryN(i);
if (segment.contains(startPoint)
|| segment.getBoundary().contains(startPoint)) {
edgeCoordinate = segment.getEndPoint().getCoordinate();
代码示例来源:origin: com.vividsolutions/jts
/**
* Computes the full topological <tt>contains</tt> predicate.
* Used when short-circuit tests are not conclusive.
*
* @param geom the test geometry
* @return true if this prepared polygon contains the test geometry
*/
protected boolean fullTopologicalPredicate(Geometry geom)
{
boolean isContained = prepPoly.getGeometry().contains(geom);
return isContained;
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
|| segment.getBoundary().contains(startPoint)) {
found = true;
if (segment.getLength() > 0.000001) {
代码示例来源:origin: org.geotools/gt-main
static public boolean contains(Geometry arg0,Geometry arg1)
{
if (arg0 == null || arg1 == null) return false;
Geometry _this = arg0;
return _this.contains(arg1);
}
代码示例来源:origin: com.vividsolutions/jts-core
/**
* Default implementation.
*/
public boolean contains(Geometry g)
{
return baseGeom.contains(g);
}
代码示例来源:origin: org.wikibrainapi/wikibrain-cookbook
private static LocalPage findCountry(Map<LocalPage, Geometry> countryShapes, Geometry point) {
for (LocalPage country : countryShapes.keySet()) {
if (countryShapes.get(country).contains(point)) {
return country;
}
}
return null;
}
}
代码示例来源:origin: com.vividsolutions/jts-core
/**
* Computes the full topological <tt>contains</tt> predicate.
* Used when short-circuit tests are not conclusive.
*
* @param geom the test geometry
* @return true if this prepared polygon contains the test geometry
*/
protected boolean fullTopologicalPredicate(Geometry geom)
{
boolean isContained = prepPoly.getGeometry().contains(geom);
return isContained;
}
代码示例来源:origin: matsim-org/matsim
private boolean linkToNodeInServiceArea(Link link) {
Point p = factory.createPoint(MGC.coord2Coordinate(link.getToNode().getCoord()));
if(this.include.contains(p)){
if(exclude.contains(p)){
return false;
}
return true;
}
return false;
}
代码示例来源:origin: matsim-org/matsim
private boolean linkToNodeInServiceArea(Link link) {
Point p = factory.createPoint(MGC.coord2Coordinate(link.getToNode().getCoord()));
if(this.include.contains(p)){
if(exclude.contains(p)){
return false;
}
return true;
}
return false;
}
代码示例来源:origin: matsim-org/matsim
private TransitStopFacility drawRandomStop(Geometry buffer, PRouteProvider pRouteProvider, Set<Id<TransitStopFacility>> stopsUsed) {
List<TransitStopFacility> choiceSet = new LinkedList<>();
// find choice-set
for (TransitStopFacility stop : pRouteProvider.getAllPStops()) {
if (!stopsUsed.contains(stop.getId())) {
if (buffer.contains(MGC.coord2Point(stop.getCoord()))) {
choiceSet.add(stop);
}
}
}
return pRouteProvider.drawRandomStopFromList(choiceSet);
}
代码示例来源:origin: org.onebusaway/onebusaway-transit-data-federation
@Override
public void handleEntity(Object bean) {
Stop stop = (Stop) bean;
Point point = _factory.createPoint(new Coordinate(stop.getLat(),stop.getLon()));
if (_geometry.contains(point))
System.out.println(stop.getLat() + " " + stop.getLon() + " "
+ stop.getId());
}
代码示例来源:origin: OneBusAway/onebusaway-application-modules
@Override
public void handleEntity(Object bean) {
Stop stop = (Stop) bean;
Point point = _factory.createPoint(new Coordinate(stop.getLat(),stop.getLon()));
if (_geometry.contains(point))
System.out.println(stop.getLat() + " " + stop.getLon() + " "
+ stop.getId());
}
代码示例来源:origin: matsim-org/matsim
@SuppressWarnings("unchecked")
private List<Zone<T>> getZones(Point point) {
if(point.getSRID() != srid)
point = transformPoint(point);
List<Zone<T>> result = quadtree.query(point.getEnvelopeInternal());
List<Zone<T>> zones = new ArrayList<Zone<T>>(result.size());
for(Zone<T> z : result) {
if(z.getGeometry().contains(point))
zones.add(z);
}
return zones;
}
代码示例来源:origin: BaseXdb/basex
@Override
public Item item(final QueryContext qc, final InputInfo ii) throws QueryException {
return Bln.get(checkGeo(0, qc).contains(checkGeo(1, qc)));
}
}
代码示例来源:origin: org.geotools/gt-main
@Override
protected boolean basicEvaluate(Geometry left, Geometry right) {
Envelope envLeft = left.getEnvelopeInternal();
Envelope envRight = right.getEnvelopeInternal();
if(envLeft.contains(envRight))
return left.contains(right);
return false;
}
public Object accept(FilterVisitor visitor, Object extraData) {
内容来源于网络,如有侵权,请联系作者删除!