bool TileProjection::GeoToPixel(const GeoCoord& coord,
                                    double& x, double& y) const
    {
      assert(valid);

      x=coord.GetLon()*scaleGradtorad-lonOffset;
      y=height-(scale*atanh(sin(coord.GetLat()*gradtorad))-latOffset);

      return true;
    }
Beispiel #2
0
  void SortWayDataGenerator::GetTopLeftCoordinate(const Way& data,
                                                  GeoCoord& coord)
  {
    coord=data.nodes[0];

    for (size_t n=1; n<data.nodes.size(); n++) {
      coord.Set(std::max(coord.GetLat(),data.nodes[n].GetLat()),
                std::min(coord.GetLon(),data.nodes[n].GetLon()));
    }
  }
  bool MercatorProjection::GeoToPixel(const GeoCoord& coord,
                                      double& x, double& y) const
  {
    assert(valid);

    // Screen coordinate relative to center of image
    x=(coord.GetLon()-this->lon)*scaleGradtorad;
    y=(atanh(sin(coord.GetLat()*gradtorad))-latOffset)*scale;

    if (angle!=0.0) {
      double xn=x*angleNegCos-y*angleNegSin;
      double yn=x*angleNegSin+y*angleNegCos;

      x=xn;
      y=yn;
    }

    // Transform to canvas coordinate
    y=height/2-y;
    x+=width/2;

    return true;
  }
double GeoCoord::GetDistance(GeoCoord target)
{
    return GetEllipsoidalDistance(GetLon(), GetLat(), target.GetLon(), target.GetLat());
}