/** * Adds a polyline ({@link Polyline}) in WKB format to spatial index with some reference * identifier. * * @param id Identifier reference for polyline. * @param wkb {@link ByteBuffer} object of geometry in WKB format. */ public void add(int id, byte[] wkb) { Polyline geometry = (Polyline) OperatorImportFromWkb.local().execute(WkbImportFlags.wkbImportDefaults, Type.Polyline, ByteBuffer.wrap(wkb), null); Envelope2D env = new Envelope2D(); geometry.queryEnvelope2D(env); index.insert(id, env); geometries.put(id, wkb); }
private static boolean polylineContainsPolyline_(Polyline polyline_a, Polyline polyline_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polyline_a.queryEnvelope2D(env_a); polyline_b.queryEnvelope2D(env_b); // Quick envelope rejection test for false equality. if (!envelopeInfContainsEnvelope_(env_a, env_b, tolerance)) return false; // Quick rasterize test to see whether the the geometries are disjoint. if (tryRasterizedContainsOrDisjoint_(polyline_a, polyline_b, tolerance, false) == Relation.disjoint) return false; return linearPathWithinLinearPath_(polyline_b, polyline_a, tolerance, false); }
private static boolean polylineContainsPolyline_(Polyline polyline_a, Polyline polyline_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polyline_a.queryEnvelope2D(env_a); polyline_b.queryEnvelope2D(env_b); // Quick envelope rejection test for false equality. if (!envelopeInfContainsEnvelope_(env_a, env_b, tolerance)) return false; // Quick rasterize test to see whether the the geometries are disjoint. if (tryRasterizedContainsOrDisjoint_(polyline_a, polyline_b, tolerance, false) == Relation.disjoint) return false; return linearPathWithinLinearPath_(polyline_b, polyline_a, tolerance, false); }
/** * Adds a copy of a {@link Polyline} in WKB format to spatial index with some reference * identifier. * <p> * <b>Note:</b> To store only references to geometry objects provide geometries in WKB format * use {@link QuadTreeIndex#add(int, byte[])}. * * @param id Identifier reference for polyline. * @param polyline {@link Polyline} object of geometry. */ public void add(int id, Polyline polyline) { Envelope2D env = new Envelope2D(); polyline.queryEnvelope2D(env); index.insert(id, env); ByteBuffer wkb = OperatorExportToWkb.local().execute(WkbExportFlags.wkbExportLineString, polyline, null); geometries.put(id, wkb.array()); }
private static boolean polylineEqualsPolyline_(Polyline polyline_a, Polyline polyline_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polyline_a.queryEnvelope2D(env_a); polyline_b.queryEnvelope2D(env_b); // Quick envelope rejection test for false equality. if (!envelopeEqualsEnvelope_(env_a, env_b, tolerance, progress_tracker)) return false; // Quick rasterize test to see whether the the geometries are disjoint. if (tryRasterizedContainsOrDisjoint_(polyline_a, polyline_b, tolerance, false) == Relation.disjoint) return false; // Quick point equality check for true equality. This just checks if all // the points in each ring are the same (within a tolerance) and in the // same order if (multiPathExactlyEqualsMultiPath_(polyline_a, polyline_b, tolerance, progress_tracker)) return true; return linearPathEqualsLinearPath_(polyline_a, polyline_b, tolerance, false); }
private static boolean polylineEqualsPolyline_(Polyline polyline_a, Polyline polyline_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polyline_a.queryEnvelope2D(env_a); polyline_b.queryEnvelope2D(env_b); // Quick envelope rejection test for false equality. if (!envelopeEqualsEnvelope_(env_a, env_b, tolerance, progress_tracker)) return false; // Quick rasterize test to see whether the the geometries are disjoint. if (tryRasterizedContainsOrDisjoint_(polyline_a, polyline_b, tolerance, false) == Relation.disjoint) return false; // Quick point equality check for true equality. This just checks if all // the points in each ring are the same (within a tolerance) and in the // same order if (multiPathExactlyEqualsMultiPath_(polyline_a, polyline_b, tolerance, progress_tracker)) return true; return linearPathEqualsLinearPath_(polyline_a, polyline_b, tolerance, false); }
private static boolean polylineDisjointEnvelope_(Polyline polyline_a, Envelope envelope_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polyline_a.queryEnvelope2D(env_a); envelope_b.queryEnvelope2D(env_b); if (envelopeInfContainsEnvelope_(env_b, env_a, tolerance)) return false; return !linearPathIntersectsEnvelope_(polyline_a, env_b, tolerance, progress_tracker); }
private static boolean polylineDisjointEnvelope_(Polyline polyline_a, Envelope envelope_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polyline_a.queryEnvelope2D(env_a); envelope_b.queryEnvelope2D(env_b); if (envelopeInfContainsEnvelope_(env_b, env_a, tolerance)) return false; return !linearPathIntersectsEnvelope_(polyline_a, env_b, tolerance, progress_tracker); }
private static boolean polylineEqualsEnvelope_(Polyline polyline_a, Envelope envelope_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polyline_a.queryEnvelope2D(env_a); envelope_b.queryEnvelope2D(env_b); if (env_b.getHeight() > tolerance && env_b.getWidth() > tolerance) return false; // area cannot equal a line return envelopeEqualsEnvelope_(env_a, env_b, tolerance, progress_tracker); }
private static boolean polylineEqualsEnvelope_(Polyline polyline_a, Envelope envelope_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polyline_a.queryEnvelope2D(env_a); envelope_b.queryEnvelope2D(env_b); if (env_b.getHeight() > tolerance && env_b.getWidth() > tolerance) return false; // area cannot equal a line return envelopeEqualsEnvelope_(env_a, env_b, tolerance, progress_tracker); }
private static boolean polygonContainsPolyline_(Polygon polygon_a, Polyline polyline_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polygon_a.queryEnvelope2D(env_a); polyline_b.queryEnvelope2D(env_b); // Quick envelope rejection test for false equality. if (!envelopeInfContainsEnvelope_(env_a, env_b, tolerance)) return false; // Quick rasterize test to see whether the the geometries are disjoint, // or if one is contained in the other. int relation = tryRasterizedContainsOrDisjoint_(polygon_a, polyline_b, tolerance, false); if (relation == Relation.disjoint) return false; if (relation == Relation.contains) return true; return polygonContainsPolylineImpl_(polygon_a, polyline_b, tolerance, progress_tracker); }
private static boolean polygonContainsPolyline_(Polygon polygon_a, Polyline polyline_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polygon_a.queryEnvelope2D(env_a); polyline_b.queryEnvelope2D(env_b); // Quick envelope rejection test for false equality. if (!envelopeInfContainsEnvelope_(env_a, env_b, tolerance)) return false; // Quick rasterize test to see whether the the geometries are disjoint, // or if one is contained in the other. int relation = tryRasterizedContainsOrDisjoint_(polygon_a, polyline_b, tolerance, false); if (relation == Relation.disjoint) return false; if (relation == Relation.contains) return true; return polygonContainsPolylineImpl_(polygon_a, polyline_b, tolerance, progress_tracker); }
private static boolean polygonContainsPolylineImpl_(Polygon polygon_a, Polyline polyline_b, double tolerance, ProgressTracker progress_tracker) { boolean[] b_result_known = new boolean[1]; b_result_known[0] = false; boolean res = polygonContainsMultiPath_(polygon_a, polyline_b, tolerance, b_result_known, progress_tracker); if (b_result_known[0]) return res; // We can clip polygon_a to the extent of polyline_b Envelope2D envBInflated = new Envelope2D(); polyline_b.queryEnvelope2D(envBInflated); envBInflated.inflate(1000.0 * tolerance, 1000.0 * tolerance); Polygon _polygonA = null; if (polygon_a.getPointCount() > 10) { _polygonA = (Polygon)Clipper.clip(polygon_a, envBInflated, tolerance, 0.0); if (_polygonA.isEmpty()) return false; } else { _polygonA = polygon_a; } boolean bContains = RelationalOperationsMatrix.polygonContainsPolyline_(_polygonA, polyline_b, tolerance, progress_tracker); return bContains; }
private static boolean polylineContainsMultiPoint_(Polyline polyline_a, MultiPoint multipoint_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polyline_a.queryEnvelope2D(env_a); multipoint_b.queryEnvelope2D(env_b); if (!envelopeInfContainsEnvelope_(env_a, env_b, tolerance)) return false; // Quick rasterize test to see whether the the geometries are disjoint. if (tryRasterizedContainsOrDisjoint_(polyline_a, multipoint_b, tolerance, false) == Relation.disjoint) return false; if (!linearPathIntersectsMultiPoint_(polyline_a, multipoint_b, tolerance, true)) return false; MultiPoint boundary_a = (MultiPoint) (polyline_a.getBoundary()); return !multiPointIntersectsMultiPoint_(boundary_a, multipoint_b, tolerance, progress_tracker); }
private static boolean polygonContainsPolylineImpl_(Polygon polygon_a, Polyline polyline_b, double tolerance, ProgressTracker progress_tracker) { boolean[] b_result_known = new boolean[1]; b_result_known[0] = false; boolean res = polygonContainsMultiPath_(polygon_a, polyline_b, tolerance, b_result_known, progress_tracker); if (b_result_known[0]) return res; // We can clip polygon_a to the extent of polyline_b Envelope2D envBInflated = new Envelope2D(); polyline_b.queryEnvelope2D(envBInflated); envBInflated.inflate(1000.0 * tolerance, 1000.0 * tolerance); Polygon _polygonA = null; if (polygon_a.getPointCount() > 10) { _polygonA = (Polygon)Clipper.clip(polygon_a, envBInflated, tolerance, 0.0); if (_polygonA.isEmpty()) return false; } else { _polygonA = polygon_a; } boolean bContains = RelationalOperationsMatrix.polygonContainsPolyline_(_polygonA, polyline_b, tolerance, progress_tracker); return bContains; }
private static boolean polylineContainsMultiPoint_(Polyline polyline_a, MultiPoint multipoint_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polyline_a.queryEnvelope2D(env_a); multipoint_b.queryEnvelope2D(env_b); if (!envelopeInfContainsEnvelope_(env_a, env_b, tolerance)) return false; // Quick rasterize test to see whether the the geometries are disjoint. if (tryRasterizedContainsOrDisjoint_(polyline_a, multipoint_b, tolerance, false) == Relation.disjoint) return false; if (!linearPathIntersectsMultiPoint_(polyline_a, multipoint_b, tolerance, true)) return false; MultiPoint boundary_a = (MultiPoint) (polyline_a.getBoundary()); return !multiPointIntersectsMultiPoint_(boundary_a, multipoint_b, tolerance, progress_tracker); }
private static boolean polylineOverlapsEnvelope_(Polyline polyline_a, Envelope envelope_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polyline_a.queryEnvelope2D(env_a); envelope_b.queryEnvelope2D(env_b); if (envelopeInfContainsEnvelope_(env_a, env_b, tolerance) || envelopeInfContainsEnvelope_(env_b, env_a, tolerance)) return false; if (envelopeInfContainsEnvelope_(env_b, env_a, tolerance)) return false; if (env_b.getHeight() > tolerance && env_b.getWidth() > tolerance) return false; // lines cannot overlap areas if (env_b.getHeight() <= tolerance && env_b.getWidth() <= tolerance) return false; // lines cannot overlap points // Treat as polyline Polyline polyline_b = new Polyline(); Point p = new Point(); envelope_b.queryCornerByVal(0, p); polyline_b.startPath(p); envelope_b.queryCornerByVal(2, p); polyline_b.lineTo(p); return linearPathOverlapsLinearPath_(polyline_a, polyline_b, tolerance); }
private static boolean polylineOverlapsEnvelope_(Polyline polyline_a, Envelope envelope_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); polyline_a.queryEnvelope2D(env_a); envelope_b.queryEnvelope2D(env_b); if (envelopeInfContainsEnvelope_(env_a, env_b, tolerance) || envelopeInfContainsEnvelope_(env_b, env_a, tolerance)) return false; if (envelopeInfContainsEnvelope_(env_b, env_a, tolerance)) return false; if (env_b.getHeight() > tolerance && env_b.getWidth() > tolerance) return false; // lines cannot overlap areas if (env_b.getHeight() <= tolerance && env_b.getWidth() <= tolerance) return false; // lines cannot overlap points // Treat as polyline Polyline polyline_b = new Polyline(); Point p = new Point(); envelope_b.queryCornerByVal(0, p); polyline_b.startPath(p); envelope_b.queryCornerByVal(2, p); polyline_b.lineTo(p); return linearPathOverlapsLinearPath_(polyline_a, polyline_b, tolerance); }
private static boolean polylineContainsEnvelope_(Polyline polyline_a, Envelope envelope_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); envelope_b.queryEnvelope2D(env_b); polyline_a.queryEnvelope2D(env_a); if (!envelopeInfContainsEnvelope_(env_a, env_b, tolerance)) return false; if (env_b.getHeight() > tolerance && env_b.getWidth() > tolerance) return false; // when treated as an area, lines cannot contain // areas. if (env_b.getHeight() <= tolerance && env_b.getWidth() <= tolerance) {// Treat // as // point Point2D pt_b = envelope_b.getCenterXY(); return linearPathContainsPoint_(polyline_a, pt_b, tolerance); } // Treat as polyline Polyline polyline_b = new Polyline(); Point p = new Point(); envelope_b.queryCornerByVal(0, p); polyline_b.startPath(p); envelope_b.queryCornerByVal(2, p); polyline_b.lineTo(p); return linearPathWithinLinearPath_(polyline_b, polyline_a, tolerance, false); }
private static boolean polylineContainsEnvelope_(Polyline polyline_a, Envelope envelope_b, double tolerance, ProgressTracker progress_tracker) { Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D(); envelope_b.queryEnvelope2D(env_b); polyline_a.queryEnvelope2D(env_a); if (!envelopeInfContainsEnvelope_(env_a, env_b, tolerance)) return false; if (env_b.getHeight() > tolerance && env_b.getWidth() > tolerance) return false; // when treated as an area, lines cannot contain // areas. if (env_b.getHeight() <= tolerance && env_b.getWidth() <= tolerance) {// Treat // as // point Point2D pt_b = envelope_b.getCenterXY(); return linearPathContainsPoint_(polyline_a, pt_b, tolerance); } // Treat as polyline Polyline polyline_b = new Polyline(); Point p = new Point(); envelope_b.queryCornerByVal(0, p); polyline_b.startPath(p); envelope_b.queryCornerByVal(2, p); polyline_b.lineTo(p); return linearPathWithinLinearPath_(polyline_b, polyline_a, tolerance, false); }