当前位置: 首页>>代码示例>>Java>>正文


Java Position.LEFT属性代码示例

本文整理汇总了Java中com.vividsolutions.jts.geomgraph.Position.LEFT属性的典型用法代码示例。如果您正苦于以下问题:Java Position.LEFT属性的具体用法?Java Position.LEFT怎么用?Java Position.LEFT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.vividsolutions.jts.geomgraph.Position的用法示例。


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

示例1: getRightmostSideOfSegment

private int getRightmostSideOfSegment(DirectedEdge de, int i) {
    Edge e = de.getEdge();
    Coordinate coord[] = e.getCoordinates();

    if (i < 0 || i + 1 >= coord.length) {
        return -1;
    }
    if (coord[i].y == coord[i + 1].y) {
        return -1;    // indicates edge is parallel to x-axis
    }

    int pos = Position.LEFT;
    if (coord[i].y < coord[i + 1].y) {
        pos = Position.RIGHT;
    }
    return pos;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:17,代码来源:RightmostEdgeFinder.java

示例2: addNextSegment

public void addNextSegment(Coordinate p, boolean addStartPoint) {
    // s0-s1-s2 are the coordinates of the previous segment and the current one
    s0 = s1;
    s1 = s2;
    s2 = p;
    seg0.setCoordinates(s0, s1);
    computeOffsetSegment(seg0, side, distance, offset0);
    seg1.setCoordinates(s1, s2);
    computeOffsetSegment(seg1, side, distance, offset1);

    // do nothing if points are equal
    if (s1.equals(s2)) return;

    int orientation = CGAlgorithms.computeOrientation(s0, s1, s2);
    boolean outsideTurn =
            (orientation == CGAlgorithms.CLOCKWISE && side == Position.LEFT)
                    || (orientation == CGAlgorithms.COUNTERCLOCKWISE && side == Position.RIGHT);

    if (orientation == 0) { // lines are collinear
        addCollinear(addStartPoint);
    } else if (outsideTurn) {
        addOutsideTurn(orientation, addStartPoint);
    } else { // inside turn
        addInsideTurn(orientation, addStartPoint);
    }
}
 
开发者ID:Semantive,项目名称:jts,代码行数:26,代码来源:OffsetSegmentGenerator.java

示例3: merge

/**
 * merge updates only the NULL attributes of this object
 * with the attributes of another.
 */
public void merge(TopologyLocation gl)
{
  // if the src is an Area label & and the dest is not, increase the dest to be an Area
  if (gl.location.length > location.length) {
    int [] newLoc = new int[3];
    newLoc[Position.ON] = location[Position.ON];
    newLoc[Position.LEFT] = Location.NONE;
    newLoc[Position.RIGHT] = Location.NONE;
    location = newLoc;
  }
  for (int i = 0; i < location.length; i++) {
    if (location[i] == Location.NONE && i < gl.location.length)
      location[i] = gl.location[i];
  }
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:19,代码来源:TopologyLocation.java

示例4: findEdge

public void findEdge(List dirEdgeList) {
    /**
     * Check all forward DirectedEdges only.  This is still general,
     * because each edge has a forward DirectedEdge.
     */
    for (Object aDirEdgeList : dirEdgeList) {
        DirectedEdge de = (DirectedEdge) aDirEdgeList;
        if (!de.isForward()) {
            continue;
        }
        this.checkForRightmostCoordinate(de);
    }

    /**
     * If the rightmost point is a node, we need to identify which of
     * the incident edges is rightmost.
     */
    Assert.isTrue(this.minIndex != 0 || this.minCoord.equals(this.minDe.getCoordinate()), "inconsistency in rightmost processing");
    if (this.minIndex == 0) {
        this.findRightmostEdgeAtNode();
    } else {
        this.findRightmostEdgeAtVertex();
    }
    /**
     * now check that the extreme side is the R side.
     * If not, use the sym instead.
     */
    this.orientedDe = this.minDe;
    int rightmostSide = this.getRightmostSide(this.minDe, this.minIndex);
    if (rightmostSide == Position.LEFT) {
        this.orientedDe = this.minDe.getSym();
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:33,代码来源:RightmostEdgeFinder.java

示例5: addNextSegment

public void addNextSegment(Coordinate p, boolean addStartPoint) {
    // s0-s1-s2 are the coordinates of the previous segment and the current one
    this.s0 = this.s1;
    this.s1 = this.s2;
    this.s2 = p;
    this.seg0.setCoordinates(this.s0, this.s1);
    this.computeOffsetSegment(this.seg0, this.side, this.distance, this.offset0);
    this.seg1.setCoordinates(this.s1, this.s2);
    this.computeOffsetSegment(this.seg1, this.side, this.distance, this.offset1);

    // do nothing if points are equal
    if (this.s1.equals(this.s2)) {
        return;
    }

    int orientation = CGAlgorithms.computeOrientation(this.s0, this.s1, this.s2);
    boolean outsideTurn =
            (orientation == CGAlgorithms.CLOCKWISE && this.side == Position.LEFT)
                    || (orientation == CGAlgorithms.COUNTERCLOCKWISE && this.side == Position.RIGHT);

    if (orientation == 0) { // lines are collinear
        this.addCollinear(addStartPoint);
    } else if (outsideTurn) {
        this.addOutsideTurn(orientation, addStartPoint);
    } else { // inside turn
        this.addInsideTurn(orientation, addStartPoint);
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:28,代码来源:OffsetSegmentGenerator.java

示例6: computeOffsetSegment

/**
 * Compute an offset segment for an input segment on a given side and at a given distance.
 * The offset points are computed in full double precision, for accuracy.
 *
 * @param seg the segment to offset
 * @param side the side of the segment ({@link Position}) the offset lies on
 * @param distance the offset distance
 * @param offset the points computed for the offset segment
 */
private void computeOffsetSegment(LineSegment seg, int side, double distance, LineSegment offset) {
    int sideSign = side == Position.LEFT ? 1 : -1;
    double dx = seg.p1.x - seg.p0.x;
    double dy = seg.p1.y - seg.p0.y;
    double len = Math.sqrt(dx * dx + dy * dy);
    // u is the vector that is the length of the offset, in the direction of the segment
    double ux = sideSign * distance * dx / len;
    double uy = sideSign * distance * dy / len;
    offset.p0.x = seg.p0.x - uy;
    offset.p0.y = seg.p0.y + ux;
    offset.p1.x = seg.p1.x - uy;
    offset.p1.y = seg.p1.y + ux;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:22,代码来源:OffsetSegmentGenerator.java

示例7: computeOffsetSegment

/**
 * Compute an offset segment for an input segment on a given side and at a given distance.
 * The offset points are computed in full double precision, for accuracy.
 *
 * @param seg      the segment to offset
 * @param side     the side of the segment ({@link Position}) the offset lies on
 * @param distance the offset distance
 * @param offset   the points computed for the offset segment
 */
private void computeOffsetSegment(LineSegment seg, int side, double distance, LineSegment offset) {
    int sideSign = side == Position.LEFT ? 1 : -1;
    double dx = seg.p1.x - seg.p0.x;
    double dy = seg.p1.y - seg.p0.y;
    double len = Math.sqrt(dx * dx + dy * dy);
    // u is the vector that is the length of the offset, in the direction of the segment
    double ux = sideSign * distance * dx / len;
    double uy = sideSign * distance * dy / len;
    offset.p0.x = seg.p0.x - uy;
    offset.p0.y = seg.p0.y + ux;
    offset.p1.x = seg.p1.x - uy;
    offset.p1.y = seg.p1.y + ux;
}
 
开发者ID:Semantive,项目名称:jts,代码行数:22,代码来源:OffsetSegmentGenerator.java

示例8: addNextSegment

public void addNextSegment(Coordinate p, boolean addStartPoint)
{
  // s0-s1-s2 are the coordinates of the previous segment and the current one
  s0 = s1;
  s1 = s2;
  s2 = p;
  seg0.setCoordinates(s0, s1);
  computeOffsetSegment(seg0, side, distance, offset0);
  seg1.setCoordinates(s1, s2);
  computeOffsetSegment(seg1, side, distance, offset1);

  // do nothing if points are equal
  if (s1.equals(s2)) return;

  int orientation = CGAlgorithms.computeOrientation(s0, s1, s2);
  boolean outsideTurn =
        (orientation == CGAlgorithms.CLOCKWISE        && side == Position.LEFT)
    ||  (orientation == CGAlgorithms.COUNTERCLOCKWISE && side == Position.RIGHT);

  if (orientation == 0) { // lines are collinear
    addCollinear(addStartPoint);
  }
  else if (outsideTurn) 
  {
    addOutsideTurn(orientation, addStartPoint);
  }
  else { // inside turn
    addInsideTurn(orientation, addStartPoint);
  }
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:30,代码来源:OffsetSegmentGenerator.java

示例9: computeOffsetSegment

/**
 * Compute an offset segment for an input segment on a given side and at a given distance.
 * The offset points are computed in full double precision, for accuracy.
 *
 * @param seg the segment to offset
 * @param side the side of the segment ({@link Position}) the offset lies on
 * @param distance the offset distance
 * @param offset the points computed for the offset segment
 */
private void computeOffsetSegment(LineSegment seg, int side, double distance, LineSegment offset)
{
  int sideSign = side == Position.LEFT ? 1 : -1;
  double dx = seg.p1.x - seg.p0.x;
  double dy = seg.p1.y - seg.p0.y;
  double len = Math.sqrt(dx * dx + dy * dy);
  // u is the vector that is the length of the offset, in the direction of the segment
  double ux = sideSign * distance * dx / len;
  double uy = sideSign * distance * dy / len;
  offset.p0.x = seg.p0.x - uy;
  offset.p0.y = seg.p0.y + ux;
  offset.p1.x = seg.p1.x - uy;
  offset.p1.y = seg.p1.y + ux;
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:23,代码来源:OffsetSegmentGenerator.java

示例10: flip

public void flip()
{
  if (location.length <= 1) return;
  int temp = location[Position.LEFT];
  location[Position.LEFT] = location[Position.RIGHT];
  location[Position.RIGHT] = temp;
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:7,代码来源:TopologyLocation.java

示例11: addPolygon

private void addPolygon(Polygon p) {
    double offsetDistance = this.distance;
    int offsetSide = Position.LEFT;
    if (this.distance < 0.0) {
        offsetDistance = -this.distance;
        offsetSide = Position.RIGHT;
    }

    LinearRing shell = (LinearRing) p.getExteriorRing();
    Coordinate[] shellCoord = CoordinateArrays.removeRepeatedPoints(shell.getCoordinates());
    // optimization - don't bother computing buffer
    // if the polygon would be completely eroded
    if (this.distance < 0.0 && this.isErodedCompletely(shell, this.distance)) {
        return;
    }
    // don't attemtp to buffer a polygon with too few distinct vertices
    if (this.distance <= 0.0 && shellCoord.length < 3) {
        return;
    }

    this.addPolygonRing(
            shellCoord,
            offsetDistance,
            offsetSide,
            Location.EXTERIOR,
            Location.INTERIOR);

    for (int i = 0; i < p.getNumInteriorRing(); i++) {

        LinearRing hole = (LinearRing) p.getInteriorRingN(i);
        Coordinate[] holeCoord = CoordinateArrays.removeRepeatedPoints(hole.getCoordinates());

        // optimization - don't bother computing buffer for this hole
        // if the hole would be completely covered
        if (this.distance > 0.0 && this.isErodedCompletely(hole, -this.distance)) {
            continue;
        }

        // Holes are topologically labelled opposite to the shell, since
        // the interior of the polygon lies on their opposite side
        // (on the left, if the hole is oriented CCW)
        this.addPolygonRing(
                holeCoord,
                offsetDistance,
                Position.opposite(offsetSide),
                Location.INTERIOR,
                Location.EXTERIOR);
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:49,代码来源:OffsetCurveSetBuilder.java

示例12: addLimitedMitreJoin

/**
 * Adds a limited mitre join connecting the two reflex offset segments.
 * A limited mitre is a mitre which is beveled at the distance
 * determined by the mitre ratio limit.
 *
 * @param offset0 the first offset segment
 * @param offset1 the second offset segment
 * @param distance the offset distance
 * @param mitreLimit the mitre limit ratio
 */
private void addLimitedMitreJoin(
        LineSegment offset0,
        LineSegment offset1,
        double distance,
        double mitreLimit) {
    Coordinate basePt = this.seg0.p1;

    double ang0 = Angle.angle(basePt, this.seg0.p0);
    double ang1 = Angle.angle(basePt, this.seg1.p1);

    // oriented angle between segments
    double angDiff = Angle.angleBetweenOriented(this.seg0.p0, basePt, this.seg1.p1);
    // half of the interior angle
    double angDiffHalf = angDiff / 2;

    // angle for bisector of the interior angle between the segments
    double midAng = Angle.normalize(ang0 + angDiffHalf);
    // rotating this by PI gives the bisector of the reflex angle
    double mitreMidAng = Angle.normalize(midAng + Math.PI);

    // the miterLimit determines the distance to the mitre bevel
    double mitreDist = mitreLimit * distance;
    // the bevel delta is the difference between the buffer distance
    // and half of the length of the bevel segment
    double bevelDelta = mitreDist * Math.abs(Math.sin(angDiffHalf));
    double bevelHalfLen = distance - bevelDelta;

    // compute the midpoint of the bevel segment
    double bevelMidX = basePt.x + mitreDist * Math.cos(mitreMidAng);
    double bevelMidY = basePt.y + mitreDist * Math.sin(mitreMidAng);
    Coordinate bevelMidPt = new Coordinate(bevelMidX, bevelMidY);

    // compute the mitre midline segment from the corner point to the bevel segment midpoint
    LineSegment mitreMidLine = new LineSegment(basePt, bevelMidPt);

    // finally the bevel segment endpoints are computed as offsets from
    // the mitre midline
    Coordinate bevelEndLeft = mitreMidLine.pointAlongOffset(1.0, bevelHalfLen);
    Coordinate bevelEndRight = mitreMidLine.pointAlongOffset(1.0, -bevelHalfLen);

    if (this.side == Position.LEFT) {
        this.segList.addPt(bevelEndLeft);
        this.segList.addPt(bevelEndRight);
    } else {
        this.segList.addPt(bevelEndRight);
        this.segList.addPt(bevelEndLeft);
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:58,代码来源:OffsetSegmentGenerator.java

示例13: addPolygon

private void addPolygon(Polygon p) {
    double offsetDistance = distance;
    int offsetSide = Position.LEFT;
    if (distance < 0.0) {
        offsetDistance = -distance;
        offsetSide = Position.RIGHT;
    }

    LinearRing shell = (LinearRing) p.getExteriorRing();
    Coordinate[] shellCoord = CoordinateArrays.removeRepeatedPoints(shell.getCoordinates());
    // optimization - don't bother computing buffer
    // if the polygon would be completely eroded
    if (distance < 0.0 && isErodedCompletely(shell, distance))
        return;
    // don't attemtp to buffer a polygon with too few distinct vertices
    if (distance <= 0.0 && shellCoord.length < 3)
        return;

    addPolygonRing(
            shellCoord,
            offsetDistance,
            offsetSide,
            Location.EXTERIOR,
            Location.INTERIOR);

    for (int i = 0; i < p.getNumInteriorRing(); i++) {

        LinearRing hole = (LinearRing) p.getInteriorRingN(i);
        Coordinate[] holeCoord = CoordinateArrays.removeRepeatedPoints(hole.getCoordinates());

        // optimization - don't bother computing buffer for this hole
        // if the hole would be completely covered
        if (distance > 0.0 && isErodedCompletely(hole, -distance))
            continue;

        // Holes are topologically labelled opposite to the shell, since
        // the interior of the polygon lies on their opposite side
        // (on the left, if the hole is oriented CCW)
        addPolygonRing(
                holeCoord,
                offsetDistance,
                Position.opposite(offsetSide),
                Location.INTERIOR,
                Location.EXTERIOR);
    }
}
 
开发者ID:Semantive,项目名称:jts,代码行数:46,代码来源:OffsetCurveSetBuilder.java

示例14: addLimitedMitreJoin

/**
 * Adds a limited mitre join connecting the two reflex offset segments.
 * A limited mitre is a mitre which is beveled at the distance
 * determined by the mitre ratio limit.
 *
 * @param offset0    the first offset segment
 * @param offset1    the second offset segment
 * @param distance   the offset distance
 * @param mitreLimit the mitre limit ratio
 */
private void addLimitedMitreJoin(
        LineSegment offset0,
        LineSegment offset1,
        double distance,
        double mitreLimit) {
    Coordinate basePt = seg0.p1;

    double ang0 = Angle.angle(basePt, seg0.p0);
    double ang1 = Angle.angle(basePt, seg1.p1);

    // oriented angle between segments
    double angDiff = Angle.angleBetweenOriented(seg0.p0, basePt, seg1.p1);
    // half of the interior angle
    double angDiffHalf = angDiff / 2;

    // angle for bisector of the interior angle between the segments
    double midAng = Angle.normalize(ang0 + angDiffHalf);
    // rotating this by PI gives the bisector of the reflex angle
    double mitreMidAng = Angle.normalize(midAng + Math.PI);

    // the miterLimit determines the distance to the mitre bevel
    double mitreDist = mitreLimit * distance;
    // the bevel delta is the difference between the buffer distance
    // and half of the length of the bevel segment
    double bevelDelta = mitreDist * Math.abs(Math.sin(angDiffHalf));
    double bevelHalfLen = distance - bevelDelta;

    // compute the midpoint of the bevel segment
    double bevelMidX = basePt.x + mitreDist * Math.cos(mitreMidAng);
    double bevelMidY = basePt.y + mitreDist * Math.sin(mitreMidAng);
    Coordinate bevelMidPt = new Coordinate(bevelMidX, bevelMidY);

    // compute the mitre midline segment from the corner point to the bevel segment midpoint
    LineSegment mitreMidLine = new LineSegment(basePt, bevelMidPt);

    // finally the bevel segment endpoints are computed as offsets from
    // the mitre midline
    Coordinate bevelEndLeft = mitreMidLine.pointAlongOffset(1.0, bevelHalfLen);
    Coordinate bevelEndRight = mitreMidLine.pointAlongOffset(1.0, -bevelHalfLen);

    if (side == Position.LEFT) {
        segList.addPt(bevelEndLeft);
        segList.addPt(bevelEndRight);
    } else {
        segList.addPt(bevelEndRight);
        segList.addPt(bevelEndLeft);
    }
}
 
开发者ID:Semantive,项目名称:jts,代码行数:58,代码来源:OffsetSegmentGenerator.java

示例15: addLimitedMitreJoin

/**
 * Adds a limited mitre join connecting the two reflex offset segments.
 * A limited mitre is a mitre which is beveled at the distance
 * determined by the mitre ratio limit.
 * 
 * @param offset0 the first offset segment
 * @param offset1 the second offset segment
 * @param distance the offset distance
 * @param mitreLimit the mitre limit ratio
 */
private void addLimitedMitreJoin( 
    LineSegment offset0, 
    LineSegment offset1,
    double distance,
    double mitreLimit)
{
  Coordinate basePt = seg0.p1;
  
  double ang0 = Angle.angle(basePt, seg0.p0);
  double ang1 = Angle.angle(basePt, seg1.p1);
  
  // oriented angle between segments
  double angDiff = Angle.angleBetweenOriented(seg0.p0, basePt, seg1.p1);
  // half of the interior angle
  double angDiffHalf = angDiff / 2;

  // angle for bisector of the interior angle between the segments
  double midAng = Angle.normalize(ang0 + angDiffHalf);
  // rotating this by PI gives the bisector of the reflex angle
  double mitreMidAng = Angle.normalize(midAng + Math.PI);
  
  // the miterLimit determines the distance to the mitre bevel
  double mitreDist = mitreLimit * distance;
  // the bevel delta is the difference between the buffer distance
  // and half of the length of the bevel segment
  double bevelDelta = mitreDist * Math.abs(Math.sin(angDiffHalf));
  double bevelHalfLen = distance - bevelDelta;

  // compute the midpoint of the bevel segment
  double bevelMidX = basePt.x + mitreDist * Math.cos(mitreMidAng);
  double bevelMidY = basePt.y + mitreDist * Math.sin(mitreMidAng);
  Coordinate bevelMidPt = new Coordinate(bevelMidX, bevelMidY);
  
  // compute the mitre midline segment from the corner point to the bevel segment midpoint
  LineSegment mitreMidLine = new LineSegment(basePt, bevelMidPt);
  
  // finally the bevel segment endpoints are computed as offsets from 
  // the mitre midline
  Coordinate bevelEndLeft = mitreMidLine.pointAlongOffset(1.0, bevelHalfLen);
  Coordinate bevelEndRight = mitreMidLine.pointAlongOffset(1.0, -bevelHalfLen);
  
  if (side == Position.LEFT) {
    segList.addPt(bevelEndLeft);
    segList.addPt(bevelEndRight);
  }
  else {
    segList.addPt(bevelEndRight);
    segList.addPt(bevelEndLeft);     
  }
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:60,代码来源:OffsetSegmentGenerator.java


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