• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java LineIntersector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.vividsolutions.jts.algorithm.LineIntersector的典型用法代码示例。如果您正苦于以下问题:Java LineIntersector类的具体用法?Java LineIntersector怎么用?Java LineIntersector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LineIntersector类属于com.vividsolutions.jts.algorithm包,在下文中一共展示了LineIntersector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: checkValid

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
/**
 * Checks validity of a LinearRing.
 */
private void checkValid(LinearRing g) {
    this.checkInvalidCoordinates(g.getCoordinates());
    if (this.validErr != null) {
        return;
    }
    this.checkClosedRing(g);
    if (this.validErr != null) {
        return;
    }

    GeometryGraph graph = new GeometryGraph(0, g);
    this.checkTooFewPoints(graph);
    if (this.validErr != null) {
        return;
    }
    LineIntersector li = new RobustLineIntersector();
    graph.computeSelfNodes(li, true);
    this.checkNoSelfIntersectingRings(graph);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:23,代码来源:IsValidOp.java


示例2: isSimpleLinearGeometry

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
private boolean isSimpleLinearGeometry(Geometry geom) {
    if (geom.isEmpty()) {
        return true;
    }
    GeometryGraph graph = new GeometryGraph(0, geom);
    LineIntersector li = new RobustLineIntersector();
    SegmentIntersector si = graph.computeSelfNodes(li, true);
    // if no self-intersection, must be simple
    if (!si.hasIntersection()) {
        return true;
    }
    if (si.hasProperIntersection()) {
        this.nonSimpleLocation = si.getProperIntersectionPoint();
        return false;
    }
    if (this.hasNonEndpointIntersection(graph)) {
        return false;
    }
    if (this.isClosedEndpointsInInterior) {
        if (this.hasClosedEndpointIntersection(graph)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:26,代码来源:IsSimpleOp.java


示例3: getNoder

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
private Noder getNoder(PrecisionModel precisionModel) {
        if (this.workingNoder != null) {
            return this.workingNoder;
        }

        // otherwise use a fast (but non-robust) noder
        MCIndexNoder noder = new MCIndexNoder();
        LineIntersector li = new RobustLineIntersector();
        li.setPrecisionModel(precisionModel);
        noder.setSegmentIntersector(new IntersectionAdder(li));
//    Noder noder = new IteratedNoder(precisionModel);
        return noder;
//    Noder noder = new SimpleSnapRounder(precisionModel);
//    Noder noder = new MCIndexSnapRounder(precisionModel);
//    Noder noder = new ScaledNoder(new MCIndexSnapRounder(new PrecisionModel(1.0)),
//                                  precisionModel.getScale());
    }
 
开发者ID:gegy1000,项目名称:Earth,代码行数:18,代码来源:BufferBuilder.java


示例4: HotPixel

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
/**
 * Creates a new hot pixel, using a given scale factor.
 * The scale factor must be strictly positive (non-zero).
 *
 * @param pt the coordinate at the centre of the pixel
 * @param scaleFactor the scaleFactor determining the pixel size.  Must be > 0
 * @param li the intersector to use for testing intersection with line segments
 */
public HotPixel(Coordinate pt, double scaleFactor, LineIntersector li) {
    this.originalPt = pt;
    this.pt = pt;
    this.scaleFactor = scaleFactor;
    this.li = li;
    //tolerance = 0.5;
    if (scaleFactor <= 0) {
        throw new IllegalArgumentException("Scale factor must be non-zero");
    }
    if (scaleFactor != 1.0) {
        this.pt = new Coordinate(this.scale(pt.x), this.scale(pt.y));
        this.p0Scaled = new Coordinate();
        this.p1Scaled = new Coordinate();
    }
    this.initCorners(this.pt);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:25,代码来源:HotPixel.java


示例5: computeSelfNodes

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
/**
     * Compute self-nodes, taking advantage of the Geometry type to
     * minimize the number of intersection tests.  (E.g. rings are
     * not tested for self-intersection, since they are assumed to be valid).
     *
     * @param li the LineIntersector to use
     * @param computeRingSelfNodes if <false>, intersection checks are optimized to not test rings for self-intersection
     * @return the SegmentIntersector used, containing information about the intersections found
     */
    public SegmentIntersector computeSelfNodes(LineIntersector li, boolean computeRingSelfNodes) {
        SegmentIntersector si = new SegmentIntersector(li, true, false);
        EdgeSetIntersector esi = this.createEdgeSetIntersector();
        // optimized test for Polygons and Rings
        if (!computeRingSelfNodes
                && (this.parentGeom instanceof LinearRing
                || this.parentGeom instanceof Polygon
                || this.parentGeom instanceof MultiPolygon)) {
            esi.computeIntersections(this.edges, si, false);
        } else {
            esi.computeIntersections(this.edges, si, true);
        }
//System.out.println("SegmentIntersector # tests = " + si.numTests);
        this.addSelfIntersectionNodes(this.argIndex);
        return si;
    }
 
开发者ID:gegy1000,项目名称:Earth,代码行数:26,代码来源:GeometryGraph.java


示例6: computeEdgeIntersections

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
public SegmentIntersector computeEdgeIntersections(
            GeometryGraph g,
            LineIntersector li,
            boolean includeProper) {
        SegmentIntersector si = new SegmentIntersector(li, includeProper, true);
        si.setBoundaryNodes(this.getBoundaryNodes(), g.getBoundaryNodes());

        EdgeSetIntersector esi = this.createEdgeSetIntersector();
        esi.computeIntersections(this.edges, g.edges, si);
/*
for (Iterator i = g.edges.iterator(); i.hasNext();) {
Edge e = (Edge) i.next();
Debug.print(e.getEdgeIntersectionList());
}
*/
        return si;
    }
 
开发者ID:gegy1000,项目名称:Earth,代码行数:18,代码来源:GeometryGraph.java


示例7: isPointOnLineSegment

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
/**
 * Checks if the point is located on the given {@link LineSegment} (including endpoints).
 */
public static boolean isPointOnLineSegment(Coordinate point, LineSegment line) {
    double lengthOfLine = line.getLength();
    double distFromEnd1 = point.distance(line.p0);
    double distFromEnd2 = point.distance(line.p1);

    // this seems to handle robustness errors (due to rounding) better
    if (distFromEnd1 + distFromEnd2 == lengthOfLine) {
        return true;
    }

    // Fallback to what should probably be the robust implementation (TODO: investigate precision issues)
    LineIntersector lineIntersector = new RobustLineIntersector();
    lineIntersector.computeIntersection(point, line.p0, line.p1);
    return lineIntersector.hasIntersection();
}
 
开发者ID:grimsa,项目名称:polysplit,代码行数:19,代码来源:GeometryUtils.java


示例8: isSimpleLinearGeometry

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
private boolean isSimpleLinearGeometry(Geometry geom) {
    if (geom.isEmpty()) return true;
    GeometryGraph graph = new GeometryGraph(0, geom);
    LineIntersector li = new RobustLineIntersector();
    SegmentIntersector si = graph.computeSelfNodes(li, true);
    // if no self-intersection, must be simple
    if (!si.hasIntersection()) return true;
    if (si.hasProperIntersection()) {
        nonSimpleLocation = si.getProperIntersectionPoint();
        return false;
    }
    if (hasNonEndpointIntersection(graph)) return false;
    if (isClosedEndpointsInInterior) {
        if (hasClosedEndpointIntersection(graph)) return false;
    }
    return true;
}
 
开发者ID:Semantive,项目名称:jts,代码行数:18,代码来源:IsSimpleOp.java


示例9: HotPixel

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
/**
 * Creates a new hot pixel, using a given scale factor.
 * The scale factor must be strictly positive (non-zero).
 *
 * @param pt          the coordinate at the centre of the pixel
 * @param scaleFactor the scaleFactor determining the pixel size.  Must be > 0
 * @param li          the intersector to use for testing intersection with line segments
 */
public HotPixel(Coordinate pt, double scaleFactor, LineIntersector li) {
    originalPt = pt;
    this.pt = pt;
    this.scaleFactor = scaleFactor;
    this.li = li;
    //tolerance = 0.5;
    if (scaleFactor <= 0)
        throw new IllegalArgumentException("Scale factor must be non-zero");
    if (scaleFactor != 1.0) {
        this.pt = new Coordinate(scale(pt.x), scale(pt.y));
        p0Scaled = new Coordinate();
        p1Scaled = new Coordinate();
    }
    initCorners(this.pt);
}
 
开发者ID:Semantive,项目名称:jts,代码行数:24,代码来源:HotPixel.java


示例10: computeSelfNodes

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
/**
     * Compute self-nodes, taking advantage of the Geometry type to
     * minimize the number of intersection tests.  (E.g. rings are
     * not tested for self-intersection, since they are assumed to be valid).
     *
     * @param li                   the LineIntersector to use
     * @param computeRingSelfNodes if <false>, intersection checks are optimized to not test rings for self-intersection
     * @return the SegmentIntersector used, containing information about the intersections found
     */
    public SegmentIntersector computeSelfNodes(LineIntersector li, boolean computeRingSelfNodes) {
        SegmentIntersector si = new SegmentIntersector(li, true, false);
        EdgeSetIntersector esi = createEdgeSetIntersector();
        // optimized test for Polygons and Rings
        if (!computeRingSelfNodes
                && (parentGeom instanceof LinearRing
                || parentGeom instanceof Polygon
                || parentGeom instanceof MultiPolygon)) {
            esi.computeIntersections(edges, si, false);
        } else {
            esi.computeIntersections(edges, si, true);
        }
//System.out.println("SegmentIntersector # tests = " + si.numTests);
        addSelfIntersectionNodes(argIndex);
        return si;
    }
 
开发者ID:Semantive,项目名称:jts,代码行数:26,代码来源:GeometryGraph.java


示例11: computeEdgeIntersections

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
public SegmentIntersector computeEdgeIntersections(
            GeometryGraph g,
            LineIntersector li,
            boolean includeProper) {
        SegmentIntersector si = new SegmentIntersector(li, includeProper, true);
        si.setBoundaryNodes(this.getBoundaryNodes(), g.getBoundaryNodes());

        EdgeSetIntersector esi = createEdgeSetIntersector();
        esi.computeIntersections(edges, g.edges, si);
/*
for (Iterator i = g.edges.iterator(); i.hasNext();) {
Edge e = (Edge) i.next();
Debug.print(e.getEdgeIntersectionList());
}
*/
        return si;
    }
 
开发者ID:Semantive,项目名称:jts,代码行数:18,代码来源:GeometryGraph.java


示例12: hasInteriorIntersection

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
/**
 * @return true if there is an intersection point which is not an endpoint of the segment p0-p1
 */
private boolean hasInteriorIntersection(LineIntersector li, Coordinate p0, Coordinate p1) {
    for (int i = 0; i < li.getIntersectionNum(); i++) {
        Coordinate intPt = li.getIntersection(i);
        if (!(intPt.equals(p0) || intPt.equals(p1))) {
            return true;
        }
    }
    return false;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:13,代码来源:NodingValidator.java


示例13: isBoundaryPoint

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
private boolean isBoundaryPoint(LineIntersector li, Collection[] bdyNodes) {
    if (bdyNodes == null) {
        return false;
    }
    if (this.isBoundaryPoint(li, bdyNodes[0])) {
        return true;
    }
    return isBoundaryPoint(li, bdyNodes[1]);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:10,代码来源:SegmentIntersector.java


示例14: addIntersection

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
/**
     * Add an EdgeIntersection for intersection intIndex.
     * An intersection that falls exactly on a vertex of the edge is normalized
     * to use the higher of the two possible segmentIndexes
     */
    public void addIntersection(LineIntersector li, int segmentIndex, int geomIndex, int intIndex) {
        Coordinate intPt = new Coordinate(li.getIntersection(intIndex));
        int normalizedSegmentIndex = segmentIndex;
        double dist = li.getEdgeDistance(geomIndex, intIndex);
//Debug.println("edge intpt: " + intPt + " dist: " + dist);
        // normalize the intersection point location
        int nextSegIndex = normalizedSegmentIndex + 1;
        if (nextSegIndex < this.pts.length) {
            Coordinate nextPt = this.pts[nextSegIndex];
//Debug.println("next pt: " + nextPt);

            // Normalize segment index if intPt falls on vertex
            // The check for point equality is 2D only - Z values are ignored
            if (intPt.equals2D(nextPt)) {
//Debug.println("normalized distance");
                normalizedSegmentIndex = nextSegIndex;
                dist = 0.0;
            }
        }
        /**
         * Add the intersection point to edge intersection list.
         */
        EdgeIntersection ei = this.eiList.add(intPt, normalizedSegmentIndex, dist);
//ei.print(System.out);

    }
 
开发者ID:gegy1000,项目名称:Earth,代码行数:32,代码来源:Edge.java


示例15: findAndClassifyIntersections

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
private void findAndClassifyIntersections(Geometry geom) {
    List lineSegStr = SegmentStringUtil.extractSegmentStrings(geom);

    LineIntersector li = new RobustLineIntersector();
    SegmentIntersectionDetector intDetector = new SegmentIntersectionDetector(li);
    intDetector.setFindAllIntersectionTypes(true);
    this.prepPoly.getIntersectionFinder().intersects(lineSegStr, intDetector);

    this.hasSegmentIntersection = intDetector.hasIntersection();
    this.hasProperIntersection = intDetector.hasProperIntersection();
    this.hasNonProperIntersection = intDetector.hasNonProperIntersection();
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:13,代码来源:AbstractPreparedPolygonContains.java


示例16: isIntersectingPolygon

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
/**
 * Checks if the line intersects any of the edges of given polygon.<br>
 * Start and end points of the line can only touch, but not cross the edges of polygon.
 *
 * @param line line which might intersect the edges of polygon
 * @param polygon the polygon
 * @return true if line intersects at least one edge of the polygon
 */
public static boolean isIntersectingPolygon(LineSegment line, Polygon polygon) {
    LineIntersector lineIntersector = new RobustLineIntersector();

    List<LineSegment> edges = getLineSegments(polygon.getExteriorRing());
    for (LineSegment edge : edges) {
        lineIntersector.computeIntersection(line.p0, line.p1, edge.p0, edge.p1);
        if (lineIntersector.hasIntersection() && lineIntersector.isProper()) {      // intersection exists and is not one of the endpoints of the line
            return true;
        }
    }
    return false;
}
 
开发者ID:grimsa,项目名称:polysplit,代码行数:21,代码来源:GeometryUtils.java


示例17: fullClosedLine

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
LineString fullClosedLine(List<LineString> lines) {
    List<Coordinate> tail = new ArrayList<>();

    boolean found;
    do {
        found = false;
        for (int i = 0; i < lines.size(); i++) {
            if (addToClosed(tail, lines.get(i))) {
                lines.remove(i);
                i--;
                found = true;
            }
        }
    } while (found);

    LineString s = GeometryHelper.createLine(tail);
    if (!s.isClosed()) {
        throw new RuntimeException("Non-closed line starts from " + tail.get(0) + " ends to "
                + tail.get(tail.size() - 1));
    }
    if (!s.isSimple()) {
        GeometryGraph graph = new GeometryGraph(0, s);
        LineIntersector li = new RobustLineIntersector();
        SegmentIntersector si = graph.computeSelfNodes(li, true);
        if (si.hasProperInteriorIntersection()) {
            throw new RuntimeException("Self-intersection for " + relation.getObjectCode()
                    + " near point " + si.getProperIntersectionPoint());
        }else {
            throw new RuntimeException("Self-intersected line: " + s);
        }
    }
    return s;
}
 
开发者ID:alex73,项目名称:OSMemory,代码行数:34,代码来源:ExtendedRelation.java


示例18: getNoder

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
private Noder getNoder(PrecisionModel precisionModel) {
        if (workingNoder != null) return workingNoder;

        // otherwise use a fast (but non-robust) noder
        MCIndexNoder noder = new MCIndexNoder();
        LineIntersector li = new RobustLineIntersector();
        li.setPrecisionModel(precisionModel);
        noder.setSegmentIntersector(new IntersectionAdder(li));
//    Noder noder = new IteratedNoder(precisionModel);
        return noder;
//    Noder noder = new SimpleSnapRounder(precisionModel);
//    Noder noder = new MCIndexSnapRounder(precisionModel);
//    Noder noder = new ScaledNoder(new MCIndexSnapRounder(new PrecisionModel(1.0)),
//                                  precisionModel.getScale());
    }
 
开发者ID:Semantive,项目名称:jts,代码行数:16,代码来源:BufferBuilder.java


示例19: hasInteriorIntersection

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
/**
 * @return true if there is an intersection point which is not an endpoint of the segment p0-p1
 */
private boolean hasInteriorIntersection(LineIntersector li, Coordinate p0, Coordinate p1) {
    for (int i = 0; i < li.getIntersectionNum(); i++) {
        Coordinate intPt = li.getIntersection(i);
        if (!(intPt.equals(p0) || intPt.equals(p1)))
            return true;
    }
    return false;
}
 
开发者ID:Semantive,项目名称:jts,代码行数:12,代码来源:NodingValidator.java


示例20: isBoundaryPoint

import com.vividsolutions.jts.algorithm.LineIntersector; //导入依赖的package包/类
private boolean isBoundaryPoint(LineIntersector li, Collection bdyNodes) {
    for (Iterator i = bdyNodes.iterator(); i.hasNext(); ) {
        Node node = (Node) i.next();
        Coordinate pt = node.getCoordinate();
        if (li.isIntersection(pt)) return true;
    }
    return false;
}
 
开发者ID:Semantive,项目名称:jts,代码行数:9,代码来源:SegmentIntersector.java



注:本文中的com.vividsolutions.jts.algorithm.LineIntersector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ExecutionTimeMeasurer类代码示例发布时间:2022-05-22
下一篇:
Java ChainedProxyManager类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap