Package org.onebusaway.transit_data_federation.model

Examples of org.onebusaway.transit_data_federation.model.ProjectedPoint


      BlockInstance blockInstance, CoordinatePoint location, long timestamp,
      double blockDistanceFrom, double blockDistanceTo) {

    BlockConfigurationEntry block = blockInstance.getBlock();

    ProjectedPoint targetPoint = ProjectedPointFactory.forward(location);

    List<AgencyAndId> shapePointIds = MappingLibrary.map(block.getTrips(),
        "trip.shapeId");

    T2<List<XYPoint>, double[]> tuple = _projectedShapePointService.getProjectedShapePoints(
        shapePointIds, targetPoint.getSrid());

    if (tuple == null) {
      throw new IllegalStateException("block had no shape points: "
          + block.getBlock().getId());
    }

    List<XYPoint> projectedShapePoints = tuple.getFirst();
    double[] distances = tuple.getSecond();

    int fromIndex = 0;
    int toIndex = distances.length;

    if (blockDistanceFrom > 0) {
      fromIndex = Arrays.binarySearch(distances, blockDistanceFrom);
      if (fromIndex < 0) {
        fromIndex = -(fromIndex + 1);
        // Include the previous point if we didn't get an exact match
        if (fromIndex > 0)
          fromIndex--;
      }
    }

    if (blockDistanceTo < distances[distances.length - 1]) {
      toIndex = Arrays.binarySearch(distances, blockDistanceTo);
      if (toIndex < 0) {
        toIndex = -(toIndex + 1);
        // Include the previous point if we didn't get an exact match
        if (toIndex < distances.length)
          toIndex++;
      }
    }

    XYPoint xyPoint = new XYPoint(targetPoint.getX(), targetPoint.getY());

    List<PointAndIndex> assignments = _shapePointsLibrary.computePotentialAssignments(
        projectedShapePoints, distances, xyPoint, fromIndex, toIndex);

    Min<ScheduledBlockLocation> best = new Min<ScheduledBlockLocation>();
View Full Code Here


  }

  public static ProjectedPoint forward(CoordinatePoint latlon, int zone) {
    UTMProjection projection = new UTMProjection(zone);
    XYPoint point = projection.forward(latlon);
    return new ProjectedPoint(latlon.getLat(), latlon.getLon(), point.getX(),
        point.getY(), zone);
  }
View Full Code Here

  public static ProjectedPoint reverse(double x, double y, int srid) {
    UTMProjection projection = new UTMProjection(srid);
    XYPoint p = new XYPoint(x, y);
    CoordinatePoint latlon = projection.reverse(p);
    return new ProjectedPoint(latlon.getLat(), latlon.getLon(), x, y, srid);
  }
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.model.ProjectedPoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.