PointList.getLatitude
Code IndexAdd Codota to your IDE (free)

Best Java code snippets using com.graphhopper.util.PointList.getLatitude (Showing top 20 results out of 315)

  • Common ways to obtain PointList
private void myMethod () {
PointList p =
  • EdgeIteratorState edgeIteratorState;edgeIteratorState.fetchWayGeometry(3)
  • PathWrapper pathWrapper;pathWrapper.getPoints()
  • new PointList(cap, true)
  • Smart code suggestions by Codota
}
origin: graphhopper/graphhopper

/**
 * Latitude of the location where this instruction should take place.
 */
double getFirstLat() {
  return points.getLatitude(0);
}
origin: graphhopper/graphhopper

@Override
public double getLat(int index) {
  return getLatitude(index);
}
origin: graphhopper/graphhopper

@Override
public double getLatitude(int index) {
  if (index > getSize())
    throw new ArrayIndexOutOfBoundsException(ERR_MSG + " index:" + index + ", size:" + getSize());
  return wrappedPointList.getLatitude(fromOffset + index);
}
origin: graphhopper/graphhopper

@Override
public double getLatitude(int nodeId) {
  if (isVirtualNode(nodeId))
    return virtualNodes.getLatitude(nodeId - mainNodes);
  return mainNodeAccess.getLatitude(nodeId);
}
origin: graphhopper/graphhopper

@Override
public int hashCode() {
  int hash = 5;
  for (int i = 0; i < getSize(); i++) {
    hash = 73 * hash + (int) Math.round(getLatitude(i) * 1000000);
    hash = 73 * hash + (int) Math.round(getLongitude(i) * 1000000);
  }
  hash = 73 * hash + this.getSize();
  return hash;
}
origin: graphhopper/graphhopper

@Override
public String toString() {
  StringBuilder sb = new StringBuilder();
  for (int i = 0; i < getSize(); i++) {
    if (i > 0)
      sb.append(", ");
    sb.append('(');
    sb.append(getLatitude(i));
    sb.append(',');
    sb.append(getLongitude(i));
    if (this.is3D()) {
      sb.append(',');
      sb.append(getElevation(i));
    }
    sb.append(')');
  }
  return sb.toString();
}
origin: graphhopper/graphhopper

List<List<Double>> createList(PointList pl, List<Integer> integs) {
  List<List<Double>> list = new ArrayList<>();
  for (int i : integs) {
    List<Double> entryList = new ArrayList<>(2);
    entryList.add(pl.getLatitude(i));
    entryList.add(pl.getLongitude(i));
    list.add(entryList);
  }
  return list;
}
origin: graphhopper/graphhopper

public GHPoint3D toGHPoint(int index) {
  return new GHPoint3D(getLatitude(index), getLongitude(index), getElevation(index));
}
origin: graphhopper/graphhopper

public static String encodePolyline(PointList poly, boolean includeElevation, double precision) {
  StringBuilder sb = new StringBuilder();
  int size = poly.getSize();
  int prevLat = 0;
  int prevLon = 0;
  int prevEle = 0;
  for (int i = 0; i < size; i++) {
    int num = (int) Math.floor(poly.getLatitude(i) * precision);
    encodeNumber(sb, num - prevLat);
    prevLat = num;
    num = (int) Math.floor(poly.getLongitude(i) * precision);
    encodeNumber(sb, num - prevLon);
    prevLon = num;
    if (includeElevation) {
      num = (int) Math.floor(poly.getElevation(i) * 100);
      encodeNumber(sb, num - prevEle);
      prevEle = num;
    }
  }
  return sb.toString();
}
origin: graphhopper/graphhopper

/**
 * Calculates the 2D bounding box of this route
 */
public BBox calcBBox2D() {
  check("calcRouteBBox");
  BBox bounds = BBox.createInverse(false);
  for (int i = 0; i < pointList.getSize(); i++) {
    bounds.update(pointList.getLatitude(i), pointList.getLongitude(i));
  }
  return bounds;
}
origin: graphhopper/graphhopper

public void add(PointList points) {
  ensureMutability();
  int newSize = size + points.getSize();
  incCap(newSize);
  for (int i = 0; i < points.getSize(); i++) {
    int tmp = size + i;
    latitudes[tmp] = points.getLatitude(i);
    longitudes[tmp] = points.getLongitude(i);
    if (is3D)
      elevations[tmp] = points.getElevation(i);
  }
  size = newSize;
}
origin: graphhopper/graphhopper

/**
 * This method fills the edgeIds hash with edgeIds found inside the specified geometry
 */
public void fillEdgeIDs(GHIntHashSet edgeIds, Geometry geometry, EdgeFilter filter) {
  if (geometry instanceof Point) {
    GHPoint point = GHPoint.create((Point) geometry);
    findClosestEdgeToPoint(edgeIds, point, filter);
  } else if (geometry instanceof LineString) {
    PointList pl = PointList.fromLineString((LineString) geometry);
    // TODO do map matching or routing
    int lastIdx = pl.size() - 1;
    if (pl.size() >= 2) {
      double meanLat = (pl.getLatitude(0) + pl.getLatitude(lastIdx)) / 2;
      double meanLon = (pl.getLongitude(0) + pl.getLongitude(lastIdx)) / 2;
      findClosestEdge(edgeIds, meanLat, meanLon, filter);
    }
  } else if (geometry instanceof MultiPoint) {
    for (Coordinate coordinate : geometry.getCoordinates()) {
      findClosestEdge(edgeIds, coordinate.y, coordinate.x, filter);
    }
  }
}
origin: graphhopper/graphhopper

/**
 * Clones this PointList. If this PointList was immutable, the cloned will be mutable. If this PointList was a
 * ShallowImmutablePointList, the cloned PointList will be a regular PointList.
 */
public PointList clone(boolean reverse) {
  PointList clonePL = new PointList(getSize(), is3D());
  if (is3D())
    for (int i = 0; i < getSize(); i++) {
      clonePL.add(getLatitude(i), getLongitude(i), getElevation(i));
    }
  else
    for (int i = 0; i < getSize(); i++) {
      clonePL.add(getLatitude(i), getLongitude(i));
    }
  if (reverse)
    clonePL.reverse();
  return clonePL;
}
origin: graphhopper/graphhopper

private PathLayer createPathLayer(PathWrapper response) {
  Style style = Style.builder()
      .fixed(true)
      .generalization(Style.GENERALIZATION_SMALL)
      .strokeColor(0x9900cc33)
      .strokeWidth(4 * getResources().getDisplayMetrics().density)
      .build();
  PathLayer pathLayer = new PathLayer(mapView.map(), style);
  List<GeoPoint> geoPoints = new ArrayList<>();
  PointList pointList = response.getPoints();
  for (int i = 0; i < pointList.getSize(); i++)
    geoPoints.add(new GeoPoint(pointList.getLatitude(i), pointList.getLongitude(i)));
  pathLayer.setPoints(geoPoints);
  return pathLayer;
}
origin: graphhopper/graphhopper

  static GHPoint getPointForOrientationCalculation(EdgeIteratorState edgeIteratorState, NodeAccess nodeAccess) {
    double tmpLat;
    double tmpLon;
    PointList tmpWayGeo = edgeIteratorState.fetchWayGeometry(3);
    if (tmpWayGeo.getSize() <= 2) {
      tmpLat = nodeAccess.getLatitude(edgeIteratorState.getAdjNode());
      tmpLon = nodeAccess.getLongitude(edgeIteratorState.getAdjNode());
    } else {
      tmpLat = tmpWayGeo.getLatitude(1);
      tmpLon = tmpWayGeo.getLongitude(1);
    }
    return new GHPoint(tmpLat, tmpLon);
  }
}
origin: graphhopper/graphhopper

public static void assertPList(PointList expected, PointList list) {
  assertEquals("size of point lists is not equal", expected.getSize(), list.getSize());
  for (int i = 0; i < expected.getSize(); i++) {
    assertEquals(expected.getLatitude(i), list.getLatitude(i), 1e-4);
    assertEquals(expected.getLongitude(i), list.getLongitude(i), 1e-4);
  }
}
origin: graphhopper/graphhopper

@Override
public boolean equals(Object obj) {
  if (obj == null)
    return false;
  PointList other = (PointList) obj;
  if (this.isEmpty() && other.isEmpty())
    return true;
  if (this.getSize() != other.getSize() || this.is3D() != other.is3D())
    return false;
  for (int i = 0; i < size(); i++) {
    if (!equalsEps(getLatitude(i), other.getLatitude(i)))
      return false;
    if (!equalsEps(getLongitude(i), other.getLongitude(i)))
      return false;
    if (this.is3D() && !equalsEps(getElevation(i), other.getElevation(i)))
      return false;
  }
  return true;
}
origin: graphhopper/graphhopper

public LineString toLineString(boolean includeElevation) {
  GeometryFactory gf = new GeometryFactory();
  Coordinate[] coordinates = new Coordinate[getSize() == 1 ? 2 : getSize()];
  for (int i = 0; i < getSize(); i++) {
    coordinates[i] = includeElevation ?
        new Coordinate(
            round6(getLongitude(i)),
            round6(getLatitude(i)),
            round2(getElevation(i))) :
        new Coordinate(
            round6(getLongitude(i)),
            round6(getLatitude(i)));
  }
  // special case as just 1 point is not supported in the specification #1412
  if (getSize() == 1)
    coordinates[1] = coordinates[0];
  return gf.createLineString(coordinates);
}
origin: graphhopper/graphhopper

@Test
public void testParse() {
  PointList pointList = new PointList();
  pointList.parse2DJSON("[[11.571499218899739,49.945605917549265],[11.571664621792689,49.94570668665409]]");
  assertEquals(49.945605917549265, pointList.getLatitude(0), 1e-6);
  assertEquals(11.571499218899739, pointList.getLongitude(0), 1e-6);
  assertEquals(49.94570668665409, pointList.getLatitude(1), 1e-6);
  assertEquals(11.571664621792689, pointList.getLongitude(1), 1e-6);
}
origin: graphhopper/graphhopper

private byte[] createWayGeometryBytes(PointList pillarNodes, boolean reverse) {
  int len = pillarNodes.getSize();
  int dim = nodeAccess.getDimension();
  int totalLen = len * dim * 4 + 4;
  byte[] bytes = new byte[totalLen];
  bitUtil.fromInt(bytes, len, 0);
  if (reverse)
    pillarNodes.reverse();
  int tmpOffset = 4;
  boolean is3D = nodeAccess.is3D();
  for (int i = 0; i < len; i++) {
    double lat = pillarNodes.getLatitude(i);
    bitUtil.fromInt(bytes, Helper.degreeToInt(lat), tmpOffset);
    tmpOffset += 4;
    bitUtil.fromInt(bytes, Helper.degreeToInt(pillarNodes.getLongitude(i)), tmpOffset);
    tmpOffset += 4;
    if (is3D) {
      bitUtil.fromInt(bytes, Helper.eleToInt(pillarNodes.getElevation(i)), tmpOffset);
      tmpOffset += 4;
    }
  }
  return bytes;
}
com.graphhopper.utilPointListgetLatitude

Popular methods of PointList

  • getLongitude
  • <init>
  • getSize
  • add
  • getElevation
  • size
  • is3D
  • getDimension
  • isEmpty
  • getEle
  • getLat
  • getLon
  • getLat,
  • getLon,
  • toGHPoint,
  • calcDistance,
  • clear,
  • copy,
  • reverse,
  • set,
  • toString

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getContentResolver (Context)
  • getSystemService (Context)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • Reference (javax.naming)
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o

For IntelliJ IDEA,
Android Studio or Eclipse

  • Search for JavaScript code betaCodota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutBlogContact Us
  • Plugin user guideTerms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)