public Coordinate getCoordOnEdge(Vector obsPoint) {
   if (this == InferredEdge.emptyEdge) return null;
   final Coordinate revObsPoint = new Coordinate(obsPoint.getElement(1), obsPoint.getElement(0));
   final LinearLocation here = locationIndexedLine.project(revObsPoint);
   final Coordinate pointOnLine = locationIndexedLine.extractPoint(here);
   final Coordinate revOnLine = new Coordinate(pointOnLine.y, pointOnLine.x);
   return revOnLine;
 }
예제 #2
0
  /**
   * Calculates the width of a point if it is not set in the gaf file.<br>
   * For PP points, it is just the distance to the first point.<br>
   * For non-pp points, it is the station of the point projected to the pp-line.
   */
  private BigDecimal getOrCalculatePoint(
      final GafPart gafPart, final GafPoint gafPoint, final GafPart projectionPart) {
    final BigDecimal width = gafPoint.getWidth();
    if (width != null) return width;

    final com.vividsolutions.jts.geom.Point location = gafPoint.getPoint();
    if (GafKind.P.equals(gafPart.getKind()) || projectionPart == null) {
      return calculateWidthFromDistance(gafPart, location);
    } else {
      final Geometry line = projectionPart.getLine(m_dbType);
      if (!(line instanceof LineString) || line.getNumPoints() < 2)
        return calculateWidthFromDistance(gafPart, location);

      final LineString ls = (LineString) line;

      final LocationIndexedLine lineRef = new LocationIndexedLine(line);
      final LinearLocation loc = lineRef.project(location.getCoordinate());
      final Coordinate closestPt = loc.getCoordinate(line);

      final double distance = ls.getCoordinateN(0).distance(closestPt);
      return new BigDecimal(distance).setScale(3, BigDecimal.ROUND_HALF_UP);
    }
  }
 /**
  * Get the snapped location in projected/euclidean coordinates for the given obsPoint (in
  * lat/lon).
  *
  * @param obsPoint
  * @return
  */
 public Vector getPointOnEdge(Coordinate obsPoint) {
   if (this == InferredEdge.emptyEdge) return null;
   final LinearLocation here = locationIndexedLine.project(obsPoint);
   final Coordinate pointOnLine = locationIndexedLine.extractPoint(here);
   return VectorFactory.getDefault().createVector2D(pointOnLine.x, pointOnLine.y);
 }