/** * Returns true if a point falls within this extent. * @param input * Point to test against this extent. */ public bool contains(GeoPoint input) { if (isInfinite() && input.isValid()) { return(true); } if (!isValid() || !input.isValid()) { return(false); } GeoPoint p = getSRS().transform(input); if (!p.isValid()) { return(false); } return ((sw.X <= p.X || Math.Abs(sw.X - p.X) < EPSILON) && (p.X <= ne.X || Math.Abs(p.X - ne.X) < EPSILON) && (sw.Y <= p.Y || Math.Abs(sw.Y - p.Y) < EPSILON) && (p.Y <= ne.Y || Math.Abs(p.Y - ne.Y) < EPSILON)); //return sw.x() <= p.x() && p.x() <= ne.x() && sw.y() <= p.y() && p.y() <= ne.y(); }
/** * Modified this extent to include a point. * @param point * Point to include. */ public void expandToInclude(GeoPoint input) { if (!isValid() || !input.isValid()) { //TODO osgGIS::notify( osg::WARN ) << "GeoExtent::expandToInclude: Illegal: either the extent of the input point is invalid" << std::endl; return; } if (!isInfinite()) { if (isEmpty()) { ne = sw = input; } else { GeoPoint new_point = getSRS().transform(input); if (new_point.isValid()) { double xmin = sw.X; double ymin = sw.Y; double xmax = ne.X; double ymax = ne.Y; if (new_point.X < xmin) { xmin = new_point.X; } if (new_point.X > xmax) { xmax = new_point.X; } if (new_point.Y < ymin) { ymin = new_point.Y; } if (new_point.Y > ymax) { ymax = new_point.Y; } sw.set((float)xmin, (float)ymin, (float)sw.Z); ne.set((float)xmax, (float)ymax, (float)ne.Z); } else { //TODO osgGIS::notify( osg::WARN ) // << "GeoExtent::expandToInclude: " // << "Unable to reproject coordinates" << std::endl; } } } recalc(); }
/** * Gets a cursor that will iterate over all the features whose shapes * intersect the specified point. * * @return * A cursor for iterating over search results */ public FeatureCursor getCursor(GeoPoint point) { if (point.isValid()) { assertSpatialIndex(); return(index.getCursor(new GeoExtent(point, point), true)); } else { return(new FeatureCursor()); // empty } }
/** * Returns true if a point falls within the extent. * @param input * Point to test against extent rectangle. */ public bool intersects(GeoPoint input) { if (isValid() && input.isValid() && !isEmpty()) { if (isInfinite()) { return(true); } GeoPoint point = sw.getSRS().transform(input); return (point.isValid() && (point.X >= sw.X || Math.Abs(point.X - sw.X) < EPSILON) && (point.X <= ne.X || Math.Abs(point.X - ne.X) < EPSILON) && (point.Y >= sw.Y || Math.Abs(point.Y - sw.Y) < EPSILON) && (point.Y <= ne.Y || Math.Abs(point.Y - ne.Y) < EPSILON)); //point.x() >= sw.x() && point.x() <= ne.x() && //point.y() >= sw.y() && point.y() <= ne.y(); } return(false); }