示例#1
0
文件: MapPanel.java 项目: TimJin/map
 public void zoomToGarminGeo(double factor, int longitude, int latitude) {
   Point2D.Double mapCoord = new Point2D.Double();
   COORD tempCoord = transformer.createTempCoord();
   transformer.wgs84ToMap(
       CoordUtils.toWGS84Rad(longitude), CoordUtils.toWGS84Rad(latitude), tempCoord, mapCoord);
   zoom(factor, (int) mapCoord.getX(), (int) mapCoord.getY());
 }
示例#2
0
文件: MapPanel.java 项目: TimJin/map
 /** Zoom and position the map in order to see everything. */
 public void showAllMap() {
   transformer.resetAutoScale();
   try {
     transformer.adjustAutoScaleFromWgs84(
         CoordUtils.toWGS84Rad(map.getMinLongitude()),
         CoordUtils.toWGS84Rad(map.getMinLatitude()));
     transformer.adjustAutoScaleFromWgs84(
         CoordUtils.toWGS84Rad(map.getMaxLongitude()),
         CoordUtils.toWGS84Rad(map.getMaxLatitude()));
   } catch (IOException e) {
     e.printStackTrace();
   }
   transformer.fixAspectRatio();
   transformerChanged();
 }
示例#3
0
文件: MapPanel.java 项目: TimJin/map
  public String getInfo(int x, int y, int maxNbInfo) {
    Point2D.Double wgs84 = new Point2D.Double();
    transformer.map2wgs84(x, y, wgs84);

    Point2D.Double wgs84Precision = new Point2D.Double();
    transformer.map2wgs84(x + 5, y, wgs84Precision);

    int longitude = CoordUtils.fromWGS84Rad(wgs84.x);
    int latitude = CoordUtils.fromWGS84Rad(wgs84.y);

    int precision =
        Math.max(
            Math.abs(longitude - CoordUtils.fromWGS84Rad(wgs84Precision.x)),
            Math.abs(latitude - CoordUtils.fromWGS84Rad(wgs84Precision.y)));

    try {
      FindObjectByPositionListener listener =
          new FindObjectByPositionListener(longitude, latitude, precision);

      int resolution = getResolution(transformer);
      map.readMapForDrawing(
          longitude, longitude, latitude, latitude, resolution, ObjectKind.ALL, listener);

      List<FoundObject> founds = listener.getFounds();
      if (founds.isEmpty()) return null;
      StringBuilder buffer = new StringBuilder("<html>\n<ul>\n");
      for (int i = founds.size() - 1; i >= Math.max(0, founds.size() - maxNbInfo); i--) {
        FoundObject found = founds.get(i);
        buffer.append("  <li>");
        found.toDebugHtml(buffer);
        buffer.append("</li>\n");
      }
      buffer.append("</ul>\n</html>\n");
      return buffer.toString();
    } catch (IOException e) {
      e.printStackTrace();
      return null;
    }
  }