private Envelope clipBounds(Envelope bounds) { return bounds.intersection(maxBounds); }
private Envelope clipBounds(Envelope bounds) { return bounds.intersection(maxBounds); }
private Geometry unionOptimized(Geometry g0, Geometry g1) { Envelope g0Env = g0.getEnvelopeInternal(); Envelope g1Env = g1.getEnvelopeInternal(); //* if (! g0Env.intersects(g1Env)) { Geometry combo = GeometryCombiner.combine(g0, g1); // System.out.println("Combined"); // System.out.println(combo); return combo; } //*/ // System.out.println(g0.getNumGeometries() + ", " + g1.getNumGeometries()); if (g0.getNumGeometries() <= 1 && g1.getNumGeometries() <= 1) return unionActual(g0, g1); // for testing... // if (true) return g0.union(g1); Envelope commonEnv = g0Env.intersection(g1Env); return unionUsingEnvelopeIntersection(g0, g1, commonEnv); // return UnionInteracting.union(g0, g1); }
private Envelope clipBounds(Envelope bounds) { return bounds.intersection(getMaxBounds()); }
public Envelope combine(List<GetLocationResult> results) { Envelope result = null; for (GetLocationResult add : results) { Envelope envelope = add.getEnvelope(); if (null == result) { result = envelope; } else { result = result.intersection(envelope); } } return result; } }
/** * @return the intersecton of the new bbox and the original */ public Envelope getIntersection() { Envelope bbox=null; if( !envelopeStack.isEmpty()) bbox=(Envelope) envelopeStack.peek(); if( original==null ){ return bbox==null?new Envelope():bbox; } if( bbox!=null ) return bbox.intersection(original); if( notEnvelope!=null ){ return intersectionWithNotEnvelope(original); } return original; }
/** * @return the intersecton of the new bbox and the original */ public Envelope getIntersection() { Envelope bbox=null; if( !envelopeStack.isEmpty()) bbox=(Envelope) envelopeStack.peek(); if( original==null ){ return bbox==null?new Envelope():bbox; } if( bbox!=null ) return bbox.intersection(original); if( notEnvelope!=null ){ return intersectionWithNotEnvelope(original); } return original; }
private Envelope intersection(Envelope e1, Envelope e2) { Envelope r = e1.intersection(e2); if (r.getWidth() < 0) return null; if (r.getHeight() < 0) return null; return r; }
private Envelope intersection(Envelope e1, Envelope e2) { Envelope r = e1.intersection(e2); if (r.getWidth() < 0) return null; if (r.getHeight() < 0) return null; return r; }
@Override public Object visit(And filter, Object data) { Envelope mixed = infinity(); for (Filter f : filter.getChildren()) { Envelope env = (Envelope) f.accept(this, data); mixed = mixed.intersection(env); } return mixed; }
/** * This adjusts the bounds by zooming out 2%, but also ensuring that * the maximum bounds do not exceed the world bounding box * * This only applies if the SRS is EPSG:4326 or EPSG:900913 * * @param reqSRS the SRS * @param bbox the current bounding box * @return the adjusted bounding box */ private static Envelope adjustBounds(String reqSRS, Envelope bbox) { if(reqSRS.equalsIgnoreCase("EPSG:4326")) { bbox.expandBy(bbox.getWidth() / 100, bbox.getHeight() / 100); Envelope maxEnv = new Envelope( -180.0,-90.0, 180.0,90.0 ); return bbox.intersection(maxEnv); } else if(reqSRS.equalsIgnoreCase("EPSG:900913")) { bbox.expandBy(bbox.getWidth() / 100, bbox.getHeight() / 100); Envelope maxEnv = new Envelope( -20037508.33, -20037508.33, 20037508.33, 20037508.33 ); return bbox.intersection(maxEnv); } return bbox; } }
@Override public SpatialResultSet execute(ProgressMonitor pm, Envelope extent) throws SQLException { lock = readRowSet.getReadLock(); try { lock.tryLock(LOCK_TIMEOUT, TimeUnit.SECONDS); // Do intersection of envelope double intersectionPercentage = extent.intersection(tableEnvelope).getArea() / tableEnvelope.getArea(); // If there is quite no zoom is great use the "select * from table" cached query. if( intersectionPercentage > RATIONAL_USAGE_INDEX) { readRowSet.beforeFirst(); return readRowSet; } else { return resultSetProvider.execute(pm, extent); } } catch (InterruptedException ex) { throw new SQLException(I18N.tr("Lock timeout while fetching {0}, another job is using this resource.", tableReference)); } }
return result.intersection(originalBounds);
@Override public SimpleFeatureCollection subCollection(Filter filter) { // get the new target envelope Envelope filterEnvelope = getEnvelope(filter); Envelope subEnvelope = queryBounds; if(filterEnvelope != null) { subEnvelope = subEnvelope.intersection(queryBounds); } if(subEnvelope.isNull()) { return new EmptyFeatureCollection(targetSchema); } // mix filters Query subQuery = new Query(query); Filter baseFilter = query.getFilter(); if(baseFilter != null && !Filter.INCLUDE.equals(baseFilter)) { Filter mixed = ff.and(baseFilter, filter); subQuery.setFilter(mixed); } return new CachingFeatureCollection(subEnvelope, sourceSchema, targetSchema, subQuery); }
final Envelope workingBound = bound.intersection(this.envelope); workingBound.expandBy(BOUND_ROUNDING_IN_MICRODEGREES); final double incrementValue = GRANULARITY;
/** * Scores the prospective parent based on geography. A perfectly matched * parent will entirely contain the child entity. (we only use MBRs here) * * @param feature * @param parent * the prospective parent to evaluate * @return a score from 0=poor match, no intersection, 1=perfect match, * competely contained */ public static double scoreGeography(ImportFeature feature, AdminEntity parent) { Envelope parentEnvelope = GeoUtils.toEnvelope(parent.getBounds()); Envelope childEnvelope = feature.getEnvelope(); if(childEnvelope.getArea() > 0) { double propContained = parentEnvelope.intersection(childEnvelope).getArea() / childEnvelope.getArea(); return propContained; } else { // we have only a point representation return parentEnvelope.contains(childEnvelope) ? 1 : 0; } }
/** * Scores the prospective parent based on geography. A perfectly matched * parent will entirely contain the child entity. (we only use MBRs here) * * @param feature * @param parent * the prospective parent to evaluate * @return a score from 0=poor match, no intersection, 1=perfect match, * competely contained */ public double scoreGeography(ImportFeature feature, AdminEntity parent) { Envelope parentEnvelope = GeoUtils.toEnvelope(parent.getBounds()); Envelope childEnvelope = feature.getEnvelope(); if(childEnvelope.getArea() > 0) { double propContained = parentEnvelope.intersection(childEnvelope).getArea() / childEnvelope.getArea(); return propContained; } else { // we have only a point representation return parentEnvelope.contains(childEnvelope) ? 1 : 0; } } }
private Geometry unionOptimized(Geometry g0, Geometry g1) { Envelope g0Env = g0.getEnvelopeInternal(); Envelope g1Env = g1.getEnvelopeInternal(); //* if (! g0Env.intersects(g1Env)) { Geometry combo = GeometryCombiner.combine(g0, g1); // System.out.println("Combined"); // System.out.println(combo); return combo; } //*/ // System.out.println(g0.getNumGeometries() + ", " + g1.getNumGeometries()); if (g0.getNumGeometries() <= 1 && g1.getNumGeometries() <= 1) return unionActual(g0, g1); // for testing... // if (true) return g0.union(g1); Envelope commonEnv = g0Env.intersection(g1Env); return unionUsingEnvelopeIntersection(g0, g1, commonEnv); // return UnionInteracting.union(g0, g1); }
protected boolean match(Geometry left, Geometry right) { if (extent != null) { // Handle easy case: points. Since each point is assigned to exactly one partition, // different partitions cannot emit duplicate results. if (left instanceof Point || right instanceof Point) { return geoMatch(left, right); } // Neither geometry is a point // Check if reference point of the intersection of the bounding boxes lies within // the extent of this partition. If not, don't run any checks. Let the partition // that contains the reference point do all the work. Envelope intersection = left.getEnvelopeInternal().intersection(right.getEnvelopeInternal()); if (!intersection.isNull()) { final Point referencePoint = makePoint(intersection.getMinX(), intersection.getMinY(), left.getFactory()); if (!extent.contains(referencePoint)) { return false; } } } return geoMatch(left, right); }
protected boolean match(Geometry left, Geometry right) { if (extent != null) { // Handle easy case: points. Since each point is assigned to exactly one partition, // different partitions cannot emit duplicate results. if (left instanceof Point || right instanceof Point) { return geoMatch(left, right); } // Neither geometry is a point // Check if reference point of the intersection of the bounding boxes lies within // the extent of this partition. If not, don't run any checks. Let the partition // that contains the reference point do all the work. Envelope intersection = left.getEnvelopeInternal().intersection(right.getEnvelopeInternal()); if (!intersection.isNull()) { final Point referencePoint = makePoint(intersection.getMinX(), intersection.getMinY(), left.getFactory()); if (!extent.contains(referencePoint)) { return false; } } } return geoMatch(left, right); }