]> git.street.me.uk Git - andy/viking.git/commitdiff
Merge 'viking-0.9.8'
authorGuilhem Bonnefille <guilhem.bonnefille@gmail.com>
Wed, 15 Jul 2009 18:27:33 +0000 (20:27 +0200)
committerGuilhem Bonnefille <guilhem.bonnefille@gmail.com>
Wed, 15 Jul 2009 18:27:33 +0000 (20:27 +0200)
1  2 
ChangeLog
configure.ac
po/POTFILES.in
src/Makefile.am
src/bluemarble.h
src/modules.c
src/osm.c
src/terraserver.c
src/vikmapslayer.c

diff --cc ChangeLog
Simple merge
diff --cc configure.ac
index 4721b97619ac8e43da9395464b7d147200da7351,0af77887450ca7d8118b6f921b210c5e50f5f540..13d21ada6e5fb583e2945b322818a654e1638bf4
@@@ -240,8 -276,7 +276,9 @@@ echo "Google Maps                      
  echo "Terraserver Maps                 : $ac_cv_enable_terraserver"
  #echo "Expedia Maps                     : $ac_cv_enable_expedia"
  echo "Open Street Map                  : $ac_cv_enable_openstreetmap"
 +echo "OpenAerial                       : $ac_cv_enable_openaerial"
 +echo "BlueMarble                       : $ac_cv_enable_bluemarble"
+ echo "Geonames                         : $ac_cv_enable_geonames"
  #echo "Geocaches Acquire                : $ac_cv_enable_geocaches"
  echo "USGS 24k DEM                     : $ac_cv_enable_dem24k"
  echo "Realtime GPS Tracking            : $ac_cv_enable_realtimegpstracking"
diff --cc po/POTFILES.in
Simple merge
diff --cc src/Makefile.am
index 62be63210c7693cbe541dd082c469531d4ac04a3,af98ec1f356c96e37057d091ce0886aaef0ac3f8..78752e2f177052c45fd15b04d37bde6147695688
@@@ -103,16 -101,11 +107,21 @@@ libviking_a_SOURCES += 
        osm-traces.c osm-traces.h
  endif
  
 +if BLUEMARBLE
 +libviking_a_SOURCES += \
 +      bluemarble.c bluemarble.h
 +endif
 +
 +if OPENAERIAL
 +libviking_a_SOURCES += \
 +      openaerial.c openaerial.h
 +endif
 +
+ if GEONAMES
+ libviking_a_SOURCES += \
+       geonamessearch.c geonamessearch.h
+ endif
  viking_SOURCES = main.c
  
  INCLUDES        = @GTK_CFLAGS@ @EXPAT_CFLAGS@ @LIBCURL_CPPFLAGS@
index 209108ed40a926013f4a4c70168d99ddd57d5bca,0000000000000000000000000000000000000000..3a8ddf8d19cf3a150f2037c0173f85ad8fb001d4
mode 100644,000000..100644
--- /dev/null
@@@ -1,28 -1,0 +1,28 @@@
- void osm_init ();
 +/*
 + * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
 + *
 + * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
 + * Copyright (C) 2008, Guilhem Bonnefille <guilhem.bonnefille@gmail.com>
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 + *
 + */
 +
 +#ifndef __VIKING_BLUEMARBLE_H
 +#define __VIKING_BLUEMARBLE_H
 +
++void bluemarble_init ();
 +
 +#endif
diff --cc src/modules.c
index d5ad909da7460b0a66605cf8dfb86fac73a8fd87,f71cbfa625b7d182bee2a5264bb3dd4ad919d783..e0568cc490ee2fdfa1f9e34f44033fc97ca60d1e
@@@ -30,7 -30,6 +30,8 @@@
  #include "expedia.h"
  #include "osm.h"
  #include "osm-traces.h"
++#include "bluemarble.h"
++#include "openaerial.h"
  
  void modules_init()
  {
    osm_init();
    osm_traces_init();
  #endif
++#ifdef VIK_CONFIG_BLUEMARBLE
++  bluemarble_init();
++#endif
++#ifdef VIK_CONFIG_OPENAERIAL
++  openaerial_init();
++#endif
  }
  
diff --cc src/osm.c
index f8586f3f8460ea33761503edc3df50d876d6282d,18c10a5de5382934d3f010af1732a4624060380e..9326f4ee3485719025315b2511f39a2703e0efb8
+++ b/src/osm.c
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   *
   */
 -#include <gtk/gtk.h>
+ #ifdef HAVE_CONFIG_H
+ #include "config.h"
+ #endif
 -#ifdef HAVE_MATH_H
 -#include <math.h>
 -#endif
 -#include "viking.h"
 -#include "coords.h"
 -#include "vikcoord.h"
 -#include "mapcoord.h"
+ #include <glib/gi18n.h>
 +
 +#include "osm.h"
  #include "vikmapslayer.h"
 +#include "vikslippymapsource.h"
+ #include "vikwebtoolcenter.h"
+ #include "vikexttools.h"
  
 -#include "osm.h"
 -
 -static guint8 osm_zoom ( gdouble mpp );
 -
 -static gboolean osm_coord_to_mapcoord ( const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest );
 -static void osm_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest );
 -static int osm_maplint_download ( MapCoord *src, const gchar *dest_fn );
 -static int osm_mapnik_download ( MapCoord *src, const gchar *dest_fn );
 -static int osm_osmarender_download ( MapCoord *src, const gchar *dest_fn );
 -static int osm_cycle_download ( MapCoord *src, const gchar *dest_fn );
 -#ifdef VIK_CONFIG_BLUEMARBLE
 -static int bluemarble_download ( MapCoord *src, const gchar *dest_fn );
 -#endif
 -#ifdef VIK_CONFIG_OPENAERIAL
 -static int openaerialmap_download ( MapCoord *src, const gchar *dest_fn );
 -#endif
 -
 -static DownloadOptions osm_options = { NULL, 0, a_check_map_file };
 -
  /* initialisation */
  void osm_init () {
 -  VikMapsLayer_MapType osmarender_type = { 12, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, osm_coord_to_mapcoord, osm_mapcoord_to_center_coord, osm_osmarender_download };
 -  VikMapsLayer_MapType mapnik_type = { 13, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, osm_coord_to_mapcoord, osm_mapcoord_to_center_coord, osm_mapnik_download };  VikMapsLayer_MapType maplint_type = { 14, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, osm_coord_to_mapcoord, osm_mapcoord_to_center_coord, osm_maplint_download };
 -  VikMapsLayer_MapType cycle_type = { 17, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, osm_coord_to_mapcoord, osm_mapcoord_to_center_coord, osm_cycle_download };
 +  VikMapSource *osmarender_type = VIK_MAP_SOURCE(vik_slippy_map_source_new_with_id(12, "tah.openstreetmap.org", "/Tiles/tile/%d/%d/%d.png"));
 +  VikMapSource *mapnik_type = VIK_MAP_SOURCE(vik_slippy_map_source_new_with_id( 13, "tile.openstreetmap.org", "/%d/%d/%d.png"));
 +  VikMapSource *maplint_type = VIK_MAP_SOURCE(vik_slippy_map_source_new_with_id( 14, "tah.openstreetmap.org", "/Tiles/maplint.php/%d/%d/%d.png"));
 +  VikMapSource *cycle_type = VIK_MAP_SOURCE(vik_slippy_map_source_new_with_id( 17, "thunderflames.org/tiles/cycle/", "%d/%d/%d.png" ));
  
 -#ifdef VIK_CONFIG_BLUEMARBLE
 -  VikMapsLayer_MapType bluemarble_type = { 15, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, osm_coord_to_mapcoord, osm_mapcoord_to_center_coord, bluemarble_download };
 -#endif
 -
 -#ifdef VIK_CONFIG_OPENAERIAL
 -  VikMapsLayer_MapType openaerialmap_type = { 20, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, osm_coord_to_mapcoord, osm_mapcoord_to_center_coord, openaerialmap_download };
 -#endif
 -
 -  maps_layer_register_type("OpenStreetMap (Osmarender)", 12, &osmarender_type);
 -  maps_layer_register_type("OpenStreetMap (Mapnik)", 13, &mapnik_type);
 -  maps_layer_register_type("OpenStreetMap (Maplint)", 14, &maplint_type);
 -  maps_layer_register_type("OpenStreetMap (Cycle)", 17, &cycle_type);
 -
 -#ifdef VIK_CONFIG_BLUEMARBLE
 -  maps_layer_register_type("BlueMarble", 15, &bluemarble_type);
 -#endif
 -#ifdef VIK_CONFIG_OPENAERIAL
 -  maps_layer_register_type("OpenAerialMap", 20, &openaerialmap_type);
 -#endif
 +  maps_layer_register_map_source ("OpenStreetMap (Osmarender)", osmarender_type);
 +  maps_layer_register_map_source ("OpenStreetMap (Mapnik)", mapnik_type);
 +  maps_layer_register_map_source ("OpenStreetMap (Maplint)", maplint_type);
 +  maps_layer_register_map_source ("OpenStreetMap (Cycle)", cycle_type);
+   // Webtools
+   VikWebtoolCenter *webtool = NULL;
+   webtool = vik_webtool_center_new_with_members ( _("OSM (view)"), "http://openstreetmap.org/?lat=%s&lon=%s&zoom=%d&layers=B000FTF" );
+   vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
+   g_object_unref ( webtool );
+   webtool = vik_webtool_center_new_with_members ( _("OSM (edit)"), "http://www.openstreetmap.org/edit?lat=%s&lon=%s&zoom=%d" );
+   vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
+   g_object_unref ( webtool );
+   webtool = vik_webtool_center_new_with_members ( _("OSM (render)"), "http://www.informationfreeway.org/?lat=%s&lon=%s&zoom=%d&layers=B0000F000F" );
+   vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
+   g_object_unref ( webtool );
  }
  
 -/* 1 << (x) is like a 2**(x) */
 -#define GZ(x) (1<<(x))
 -
 -static const gdouble scale_mpps[] = { GZ(0), GZ(1), GZ(2), GZ(3), GZ(4), GZ(5), GZ(6), GZ(7), GZ(8), GZ(9),
 -                                      GZ(10), GZ(11), GZ(12), GZ(13), GZ(14), GZ(15), GZ(16), GZ(17) };
 -
 -static const gint num_scales = (sizeof(scale_mpps) / sizeof(scale_mpps[0]));
 -
 -#define ERROR_MARGIN 0.01
 -guint8 osm_zoom ( gdouble mpp ) {
 -  gint i;
 -  for ( i = 0; i < num_scales; i++ ) {
 -    if ( ABS(scale_mpps[i] - mpp) < ERROR_MARGIN )
 -      return i;
 -  }
 -  return 255;
 -}
 -
 -static gboolean osm_coord_to_mapcoord ( const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest )
 -{
 -  g_assert ( src->mode == VIK_COORD_LATLON );
 -
 -  if ( xzoom != yzoom )
 -    return FALSE;
 -
 -  dest->scale = osm_zoom ( xzoom );
 -  if ( dest->scale == 255 )
 -    return FALSE;
 -
 -  dest->x = (src->east_west + 180) / 360 * GZ(17) / xzoom;
 -  dest->y = (180 - MERCLAT(src->north_south)) / 360 * GZ(17) / xzoom;
 -  dest->z = 0;
 -  return TRUE;
 -}
 -
 -static void osm_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest )
 -{
 -  gdouble socalled_mpp = GZ(src->scale);
 -  dest->mode = VIK_COORD_LATLON;
 -  dest->east_west = ((src->x+0.5) / GZ(17) * socalled_mpp * 360) - 180;
 -  dest->north_south = DEMERCLAT(180 - ((src->y+0.5) / GZ(17) * socalled_mpp * 360));
 -}
 -
 -/* Maplint tiles
 - * Ex: http://dev.openstreetmap.org/~ojw/Tiles/maplint.php/10/517/375.png
 - */
 -static int osm_maplint_download ( MapCoord *src, const gchar *dest_fn )
 -{
 -   int res = -1;
 -   gchar *uri = g_strdup_printf ( "/Tiles/maplint.php/%d/%d/%d.png", 17-src->scale, src->x, src->y );
 -   res = a_http_download_get_url ( "tah.openstreetmap.org", uri, dest_fn, &osm_options );
 -   g_free ( uri );
 -   return res;
 -}
 -
 -static int osm_mapnik_download ( MapCoord *src, const gchar *dest_fn )
 -{
 -   int res = -1;
 -   gchar *uri = g_strdup_printf ( "/%d/%d/%d.png", 17-src->scale, src->x, src->y );
 -   res = a_http_download_get_url ( "tile.openstreetmap.org", uri, dest_fn, &osm_options );
 -   g_free ( uri );
 -   return res;
 -}
 -
 -static int osm_osmarender_download ( MapCoord *src, const gchar *dest_fn )
 -{
 -   int res = -1;
 -   gchar *uri = g_strdup_printf ( "/Tiles/tile/%d/%d/%d.png", 17-src->scale, src->x, src->y );
 -   res = a_http_download_get_url ( "tah.openstreetmap.org", uri, dest_fn, &osm_options );
 -   g_free ( uri );
 -   return res;
 -}
 -
 -#ifdef VIK_CONFIG_BLUEMARBLE
 -static int bluemarble_download ( MapCoord *src, const gchar *dest_fn )
 -{
 -   int res = -1;
 -   gchar *uri = g_strdup_printf ( "/com.modestmaps.bluemarble/%d-r%d-c%d.jpg", 17-src->scale, src->y, src->x );
 -   res = a_http_download_get_url ( "s3.amazonaws.com", uri, dest_fn, &osm_options );
 -
 -   g_free ( uri );
 -   return res;
 -
 -}
 -#endif
 -   
 -#ifdef VIK_CONFIG_OPENAERIAL
 -static int openaerialmap_download ( MapCoord *src, const gchar *dest_fn )
 -{
 -   int res = -1;
 -   gchar *uri = g_strdup_printf ( "/tiles/1.0.0/openaerialmap-900913/%d/%d/%d.jpg", 17-src->scale, src->x, src->y );
 -   res = a_http_download_get_url ( "tile.openaerialmap.org", uri, dest_fn, &osm_options );
 -
 -   g_free ( uri );
 -   return res;
 -}
 -#endif
 -
 -static int osm_cycle_download ( MapCoord *src, const gchar *dest_fn )
 -{
 -   int res = -1;
 -   gchar *uri = g_strdup_printf ( "/tiles/cycle/%d/%d/%d.png", 17-src->scale, src->x, src->y );
 -   res = a_http_download_get_url ( "andy.sandbox.cloudmade.com", uri, dest_fn, &osm_options );
 -   g_free ( uri );
 -   return res;
 -}
index c79fb34c4e2ab62a98ad7f286bd4085f6310aa4b,8127da2ed181d9e1edc4dcd38c67cd2e8e6ccf17..e9d78c83aead0380d3995cd4531ed6e4a47d1459
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   *
   */
+ #ifdef HAVE_CONFIG_H
+ #include "config.h"
+ #endif
  
 -#include <gtk/gtk.h>
 -#ifdef HAVE_MATH_H
 -#include <math.h>
 -#endif
 -
 -#include "viking.h"
 -#include "coords.h"
 -#include "vikcoord.h"
 -#include "mapcoord.h"
 -#include "download.h"
 -#include "vikmapslayer.h"
 -
  #include "terraserver.h"
 -
 -static gboolean terraserver_topo_coord_to_mapcoord ( const VikCoord *src, gdouble xmpp, gdouble ympp, MapCoord *dest );
 -static int terraserver_topo_download ( MapCoord *src, const gchar *dest_fn );
 -
 -static gboolean terraserver_aerial_coord_to_mapcoord ( const VikCoord *src, gdouble xmpp, gdouble ympp, MapCoord *dest );
 -static int terraserver_aerial_download ( MapCoord *src, const gchar *dest_fn );
 -
 -static gboolean terraserver_urban_coord_to_mapcoord ( const VikCoord *src, gdouble xmpp, gdouble ympp, MapCoord *dest );
 -static int terraserver_urban_download ( MapCoord *src, const gchar *dest_fn );
 -
 -static void terraserver_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest );
 -
 -static DownloadOptions terraserver_options = { NULL, 0, a_check_map_file };
 +#include "terraservermapsource.h"
 +#include "vikmapslayer.h"
  
  void terraserver_init () {
 -  VikMapsLayer_MapType map_type_1 = { 2, 200, 200, VIK_VIEWPORT_DRAWMODE_UTM, terraserver_topo_coord_to_mapcoord, terraserver_mapcoord_to_center_coord, terraserver_topo_download };
 -  VikMapsLayer_MapType map_type_2 = { 1, 200, 200, VIK_VIEWPORT_DRAWMODE_UTM, terraserver_aerial_coord_to_mapcoord, terraserver_mapcoord_to_center_coord, terraserver_aerial_download };
 -  VikMapsLayer_MapType map_type_3 = { 4, 200, 200, VIK_VIEWPORT_DRAWMODE_UTM, terraserver_urban_coord_to_mapcoord, terraserver_mapcoord_to_center_coord, terraserver_urban_download };
 -
 -  maps_layer_register_type("Terraserver Topos", 2, &map_type_1);
 -  maps_layer_register_type("Terraserver Aerials", 1, &map_type_2);
 -  maps_layer_register_type("Terraserver Urban Areas", 4, &map_type_3);
 -}
 -
 -#define TERRASERVER_SITE "terraserver-usa.com"
 -#define MARGIN_OF_ERROR 0.001
 -
 -static int mpp_to_scale ( gdouble mpp, guint8 type )
 -{
 -  mpp *= 4;
 -  gint t = (gint) mpp;
 -  if ( ABS(mpp - t) > MARGIN_OF_ERROR )
 -    return FALSE;
 +  VikMapSource *map_type_1 = VIK_MAP_SOURCE(terraserver_map_source_new_with_id( 2, 2 ));
 +  VikMapSource *map_type_2 = VIK_MAP_SOURCE(terraserver_map_source_new_with_id( 1, 1 ));
 +  VikMapSource *map_type_3 = VIK_MAP_SOURCE(terraserver_map_source_new_with_id( 4, 4 ));
  
 -  switch ( t ) {
 -    case 1: return (type == 4) ? 8 : 0;
 -    case 2: return (type == 4) ? 9 : 0;
 -    case 4: return (type != 2) ? 10 : 0;
 -    case 8: return 11;
 -    case 16: return 12;
 -    case 32: return 13;
 -    case 64: return 14;
 -    case 128: return 15;
 -    case 256: return 16;
 -    case 512: return 17;
 -    case 1024: return 18;
 -    case 2048: return 19;
 -    default: return 0;
 -  }
 +  maps_layer_register_map_source ("Terraserver Topos", map_type_1);
 +  maps_layer_register_map_source ("Terraserver Aerials", map_type_2);
 +  maps_layer_register_map_source ("Terraserver Urban Areas", map_type_3);
  }
 -
 -static gdouble scale_to_mpp ( gint scale )
 -{
 -  return pow(2,scale - 10);
 -}
 -
 -static gboolean terraserver_coord_to_mapcoord ( const VikCoord *src, gdouble xmpp, gdouble ympp, MapCoord *dest, guint8 type )
 -{
 -  g_assert ( src->mode == VIK_COORD_UTM );
 -
 -  if ( xmpp != ympp )
 -    return FALSE;
 -
 -  dest->scale = mpp_to_scale ( xmpp, type );
 -  if ( ! dest->scale )
 -    return FALSE;
 -
 -  dest->x = (gint)(((gint)(src->east_west))/(200*xmpp));
 -  dest->y = (gint)(((gint)(src->north_south))/(200*xmpp));
 -  dest->z = src->utm_zone;
 -  return TRUE;
 -}
 -
 -static gboolean terraserver_topo_coord_to_mapcoord ( const VikCoord *src, gdouble xmpp, gdouble ympp, MapCoord *dest )
 -{ return terraserver_coord_to_mapcoord ( src, xmpp, ympp, dest, 2 ); }
 -static gboolean terraserver_aerial_coord_to_mapcoord ( const VikCoord *src, gdouble xmpp, gdouble ympp, MapCoord *dest )
 -{ return terraserver_coord_to_mapcoord ( src, xmpp, ympp, dest, 1 ); }
 -static gboolean terraserver_urban_coord_to_mapcoord ( const VikCoord *src, gdouble xmpp, gdouble ympp, MapCoord *dest )
 -{ return terraserver_coord_to_mapcoord ( src, xmpp, ympp, dest, 4 ); }
 -
 -static void terraserver_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest )
 -{
 -  // FIXME: slowdown here!
 -  gdouble mpp = scale_to_mpp ( src->scale );
 -  dest->mode = VIK_COORD_UTM;
 -  dest->utm_zone = src->z;
 -  dest->east_west = ((src->x * 200) + 100) * mpp;
 -  dest->north_south = ((src->y * 200) + 100) * mpp;
 -}
 -
 -static int terraserver_download ( MapCoord *src, const gchar *dest_fn, guint8 type )
 -{
 -  int res = -1;
 -  gchar *uri = g_strdup_printf ( "/tile.ashx?T=%d&S=%d&X=%d&Y=%d&Z=%d", type,
 -                                  src->scale, src->x, src->y, src->z );
 -  res = a_http_download_get_url ( TERRASERVER_SITE, uri, dest_fn, &terraserver_options );
 -  g_free ( uri );
 -  return(res);
 -}
 -
 -static int terraserver_topo_download ( MapCoord *src, const gchar *dest_fn )
 -{ return terraserver_download ( src, dest_fn, 2 ); }
 -static int terraserver_aerial_download ( MapCoord *src, const gchar *dest_fn )
 -{ return terraserver_download ( src, dest_fn, 1 ); }
 -static int terraserver_urban_download ( MapCoord *src, const gchar *dest_fn )
 -{ return terraserver_download ( src, dest_fn, 4 ); }
Simple merge