diff options
author | tegzed <tegzed@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2011-01-05 20:15:30 +0000 |
---|---|---|
committer | tegzed <tegzed@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2011-01-05 20:15:30 +0000 |
commit | 0ca87730e8d4aa243890a341f9f679c3eeeb9762 (patch) | |
tree | a409b8cc714e48811e6b0b19432b44a94ddd0600 | |
parent | 67290e88fa1ca03b1cdf696914c85ff5402625d2 (diff) | |
download | navit-0ca87730e8d4aa243890a341f9f679c3eeeb9762.tar.gz |
Add:map/csv:Added initial version of csv map driver
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@3868 ffa7fe5e-494d-0410-b361-a75ebd5db220
-rw-r--r-- | COPYING | 2 | ||||
-rw-r--r-- | configure.in | 6 | ||||
-rw-r--r-- | navit/attr_def.h | 2 | ||||
-rw-r--r-- | navit/map/Makefile.am | 5 | ||||
-rw-r--r-- | navit/map/csv/Makefile.am | 9 | ||||
-rw-r--r-- | navit/map/csv/Makefile.in | 702 | ||||
-rw-r--r-- | navit/map/csv/csv.c | 348 | ||||
-rw-r--r-- | navit/map/csv/csv.h | 47 | ||||
-rw-r--r-- | navit/map/csv/quadtree.c | 299 | ||||
-rw-r--r-- | navit/map/csv/quadtree.h | 36 |
10 files changed, 1455 insertions, 1 deletions
@@ -55,6 +55,8 @@ navit/data/mg/block.c navit/data/mg/map.c navit/data/textfile/textfile.c navit/data/textfile/textfile.h +navit/data/csv/csv.c +navit/data/csv/csv.h navit/data/binfile/binfile.c navit/data/garmin_img/garmin_img.c navit/data/garmin/gentypes.c diff --git a/configure.in b/configure.in index 36dd6fde2..5e6992ff6 100644 --- a/configure.in +++ b/configure.in @@ -60,6 +60,7 @@ map_filter=yes; map_filter_reason=default map_mg=yes; map_mg_reason=default map_shapefile=yes; map_shapefile_reason=default map_textfile=yes; map_textfile_reason=default +map_csv=yes; map_csv_reason=default osd_core=yes; osd_core_reason=default plugin_pedestrian=no; plugin_pedestrian_reason=default routing=yes; routing_reason=default @@ -916,6 +917,9 @@ AM_CONDITIONAL(MAP_SHAPEFILE, test "x${map_shapefile}" = "xyes") # textfile AC_ARG_ENABLE(map-textfile, [ --disable-map-textfile disable map textfile], map_textfile=$enableval;map_textfile_reason="configure parameter") AM_CONDITIONAL(MAP_TEXTFILE, test "x${map_textfile}" = "xyes") +# csv +AC_ARG_ENABLE(map-csv, [ --disable-map-csv disable map csv], map_csv=$enableval;map_csv_reason="configure parameter") +AM_CONDITIONAL(MAP_CSV, test "x${map_csv}" = "xyes") ## osd # core @@ -1081,6 +1085,7 @@ navit/binding/dbus/Makefile navit/map/Makefile navit/map/mg/Makefile navit/map/textfile/Makefile +navit/map/csv/Makefile navit/map/shapefile/Makefile navit/map/filter/Makefile navit/map/binfile/Makefile @@ -1234,6 +1239,7 @@ echo " filter: $map_filter ($map_filter_reason)" echo " mg: $map_mg ($map_mg_reason)" echo " shapefile: $map_shapefile ($map_shapefile_reason)" echo " textfile: $map_textfile ($map_textfile_reason)" +echo " csv: $map_csv ($map_csv_reason)" echo "Bindings:" diff --git a/navit/attr_def.h b/navit/attr_def.h index 1a3afeb0b..3d450160e 100644 --- a/navit/attr_def.h +++ b/navit/attr_def.h @@ -355,6 +355,8 @@ ATTR(position_speed) ATTR(position_direction) ATTR(position_hdop) ATTR(position_radius) +ATTR(position_longitude) +ATTR(position_latitude) ATTR2(0x0005ffff,type_double_end) ATTR2(0x00060000,type_coord_geo_begin) ATTR(position_coord_geo) diff --git a/navit/map/Makefile.am b/navit/map/Makefile.am index 45f91ae1f..d2b6efdc5 100644 --- a/navit/map/Makefile.am +++ b/navit/map/Makefile.am @@ -17,5 +17,8 @@ endif if MAP_TEXTFILE SUBDIRS+=textfile endif +if MAP_CSV + SUBDIRS+=csv +endif -DIST_SUBDIRS=mg textfile binfile garmin shapefile filter +DIST_SUBDIRS=mg textfile csv binfile garmin shapefile filter diff --git a/navit/map/csv/Makefile.am b/navit/map/csv/Makefile.am new file mode 100644 index 000000000..d8670ea2c --- /dev/null +++ b/navit/map/csv/Makefile.am @@ -0,0 +1,9 @@ +include $(top_srcdir)/Makefile.inc +AM_CPPFLAGS = @NAVIT_CFLAGS@ -I$(top_srcdir)/navit -DMODULE=map_csv +if PLUGINS + modulemap_LTLIBRARIES = libmap_csv.la +else + noinst_LTLIBRARIES = libmap_csv.la +endif +libmap_csv_la_SOURCES = csv.c csv.h quadtree.c quadtree.h +libmap_csv_la_LDFLAGS = -module -avoid-version @NAVIT_MODULE_LDFLAGS@ diff --git a/navit/map/csv/Makefile.in b/navit/map/csv/Makefile.in new file mode 100644 index 000000000..c07315526 --- /dev/null +++ b/navit/map/csv/Makefile.in @@ -0,0 +1,702 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/Makefile.inc +subdir = navit/map/csv +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/codeset.m4 \ + $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/glibc21.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intdiv0.m4 \ + $(top_srcdir)/m4/intmax.m4 $(top_srcdir)/m4/inttypes-pri.m4 \ + $(top_srcdir)/m4/inttypes.m4 $(top_srcdir)/m4/inttypes_h.m4 \ + $(top_srcdir)/m4/isc-posix.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ + $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/longdouble.m4 $(top_srcdir)/m4/longlong.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \ + $(top_srcdir)/m4/printf-posix.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/m4/signed.m4 $(top_srcdir)/m4/size_max.m4 \ + $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ + $(top_srcdir)/m4/ulonglong.m4 $(top_srcdir)/m4/wchar_t.m4 \ + $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xsize.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__installdirs = "$(DESTDIR)$(modulemapdir)" +LTLIBRARIES = $(modulemap_LTLIBRARIES) $(noinst_LTLIBRARIES) +libmap_csv_la_LIBADD = +am_libmap_csv_la_OBJECTS = csv.lo quadtree.lo +libmap_csv_la_OBJECTS = $(am_libmap_csv_la_OBJECTS) +libmap_csv_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libmap_csv_la_LDFLAGS) $(LDFLAGS) -o $@ +@PLUGINS_FALSE@am_libmap_csv_la_rpath = +@PLUGINS_TRUE@am_libmap_csv_la_rpath = -rpath $(modulemapdir) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libmap_csv_la_SOURCES) +DIST_SOURCES = $(libmap_csv_la_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +ANDROID_PERMISSIONS = @ANDROID_PERMISSIONS@ +ANDROID_PROJECT = @ANDROID_PROJECT@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CCLD_FOR_BUILD = @CCLD_FOR_BUILD@ +CC_FOR_BUILD = @CC_FOR_BUILD@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CRYPTO_LIBS = @CRYPTO_LIBS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DBUS_SERVICE_DIR = @DBUS_SERVICE_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@ +FONTCONFIG_LIBS = @FONTCONFIG_LIBS@ +FREEIMAGE_LIBS = @FREEIMAGE_LIBS@ +FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@ +FREETYPE2_LIBS = @FREETYPE2_LIBS@ +FRIBIDI_CFLAGS = @FRIBIDI_CFLAGS@ +FRIBIDI_LIBS = @FRIBIDI_LIBS@ +GDLIB_CONFIG = @GDLIB_CONFIG@ +GD_CFLAGS = @GD_CFLAGS@ +GD_LIBS = @GD_LIBS@ +GENCAT = @GENCAT@ +GLC_CFLAGS = @GLC_CFLAGS@ +GLC_LIBS = @GLC_LIBS@ +GLIBC21 = @GLIBC21@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_LIBS = @GLIB_LIBS@ +GMODULE_CFLAGS = @GMODULE_CFLAGS@ +GMODULE_LIBS = @GMODULE_LIBS@ +GMSGFMT = @GMSGFMT@ +GPSBT_CFLAGS = @GPSBT_CFLAGS@ +GPSBT_LIBS = @GPSBT_LIBS@ +GPSD_CFLAGS = @GPSD_CFLAGS@ +GPSD_LIBS = @GPSD_LIBS@ +GREP = @GREP@ +GTK2_CFLAGS = @GTK2_CFLAGS@ +GTK2_LIBS = @GTK2_LIBS@ +GYPSY_CFLAGS = @GYPSY_CFLAGS@ +GYPSY_LIBS = @GYPSY_LIBS@ +HAVE_ASPRINTF = @HAVE_ASPRINTF@ +HAVE_POSIX_PRINTF = @HAVE_POSIX_PRINTF@ +HAVE_SNPRINTF = @HAVE_SNPRINTF@ +HAVE_WPRINTF = @HAVE_WPRINTF@ +HILDON_CFLAGS = @HILDON_CFLAGS@ +HILDON_LIBS = @HILDON_LIBS@ +IMLIB2_CFLAGS = @IMLIB2_CFLAGS@ +IMLIB2_LIBS = @IMLIB2_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLBISON = @INTLBISON@ +INTLIBS = @INTLIBS@ +INTLLIBS = @INTLLIBS@ +INTLOBJS = @INTLOBJS@ +INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@ +IPHONE_CFLAGS = @IPHONE_CFLAGS@ +IPHONE_LIBS = @IPHONE_LIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBC_LIBS = @LIBC_LIBS@ +LIBGARMIN_CFLAGS = @LIBGARMIN_CFLAGS@ +LIBGARMIN_LIBS = @LIBGARMIN_LIBS@ +LIBGPS19_CFLAGS = @LIBGPS19_CFLAGS@ +LIBGPS19_LIBS = @LIBGPS19_LIBS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBLOCATION_CFLAGS = @LIBLOCATION_CFLAGS@ +LIBLOCATION_LIBS = @LIBLOCATION_LIBS@ +LIBNAVIT = @LIBNAVIT@ +LIBOBJS = @LIBOBJS@ +LIBOSSO_CFLAGS = @LIBOSSO_CFLAGS@ +LIBOSSO_LIBS = @LIBOSSO_LIBS@ +LIBPDL_CFLAGS = @LIBPDL_CFLAGS@ +LIBPDL_LIBS = @LIBPDL_LIBS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MOC = @MOC@ +MODULE_LDFLAGS = @MODULE_LDFLAGS@ +MODULE_LIBADD = @MODULE_LIBADD@ +MOFILES = @MOFILES@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +NAVIT_CFLAGS = @NAVIT_CFLAGS@ +NAVIT_LIBS = @NAVIT_LIBS@ +NAVIT_MODULE_LDFLAGS = @NAVIT_MODULE_LDFLAGS@ +NAVIT_SOCKET_LDFLAGS = @NAVIT_SOCKET_LDFLAGS@ +NAVIT_VARIANT = @NAVIT_VARIANT@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENGL_CFLAGS = @OPENGL_CFLAGS@ +OPENGL_LIBS = @OPENGL_LIBS@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PG_CONFIG = @PG_CONFIG@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POFILES = @POFILES@ +POIFILES = @POIFILES@ +POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ +POSTGRESQL_LIBS = @POSTGRESQL_LIBS@ +POSUB = @POSUB@ +PYTHONCONFIG = @PYTHONCONFIG@ +PYTHON_CFLAGS = @PYTHON_CFLAGS@ +PYTHON_LIBS = @PYTHON_LIBS@ +QT_DECLARATIVE_CFLAGS = @QT_DECLARATIVE_CFLAGS@ +QT_DECLARATIVE_LIBS = @QT_DECLARATIVE_LIBS@ +QT_GUI_CFLAGS = @QT_GUI_CFLAGS@ +QT_GUI_LIBS = @QT_GUI_LIBS@ +QT_SVG_CFLAGS = @QT_SVG_CFLAGS@ +QT_SVG_LIBS = @QT_SVG_LIBS@ +QT_XML_CFLAGS = @QT_XML_CFLAGS@ +QT_XML_LIBS = @QT_XML_LIBS@ +RANLIB = @RANLIB@ +SAXON = @SAXON@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_IMAGE_LIBS = @SDL_IMAGE_LIBS@ +SDL_LIBS = @SDL_LIBS@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHAPEFILE_CFLAGS = @SHAPEFILE_CFLAGS@ +SHAPEFILE_LIBS = @SHAPEFILE_LIBS@ +SHELL = @SHELL@ +SOURCE_MODE = @SOURCE_MODE@ +SPEECHD_CFLAGS = @SPEECHD_CFLAGS@ +SPEECHD_LIBS = @SPEECHD_LIBS@ +STRIP = @STRIP@ +SVG2PNG = @SVG2PNG@ +SVG2PNG_SCALES = @SVG2PNG_SCALES@ +SVG2PNG_SCALES_FLAG = @SVG2PNG_SCALES_FLAG@ +SVG2PNG_SCALES_NAV = @SVG2PNG_SCALES_NAV@ +USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WINDRES = @WINDRES@ +WORDEXP_LIBS = @WORDEXP_LIBS@ +XGETTEXT = @XGETTEXT@ +XSLTS = @XSLTS@ +ZLIB_CFLAGS = @ZLIB_CFLAGS@ +ZLIB_LIBS = @ZLIB_LIBS@ +_PATH_BZCAT = @_PATH_BZCAT@ +_PATH_PYTHON = @_PATH_PYTHON@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +ac_ct_OBJC = @ac_ct_OBJC@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +cross_compiling = @cross_compiling@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +modulebindingdir = $(pkglibdir)/binding +modulemapdir = $(pkglibdir)/map +modulefontdir = $(pkglibdir)/font +modulegraphicsdir = $(pkglibdir)/graphics +moduleguidir = $(pkglibdir)/gui +modulespeechdir = $(pkglibdir)/speech +moduleosddir = $(pkglibdir)/osd +modulevehicledir = $(pkglibdir)/vehicle +moduleplugindir = $(pkglibdir)/plugin +moduleautoloaddir = $(pkglibdir)/autoload +pkgdocdir = $(pkgdatadir) +xpmdir = $(pkgdatadir)/xpm +skinsdir = $(pkgdatadir)/skins +fontsdir = $(pkgdatadir)/fonts +mapsdir = $(pkgdatadir)/maps +AM_CPPFLAGS = @NAVIT_CFLAGS@ -I$(top_srcdir)/navit -DMODULE=map_csv +@PLUGINS_TRUE@modulemap_LTLIBRARIES = libmap_csv.la +@PLUGINS_FALSE@noinst_LTLIBRARIES = libmap_csv.la +libmap_csv_la_SOURCES = csv.c csv.h quadtree.c quadtree.h +libmap_csv_la_LDFLAGS = -module -avoid-version @NAVIT_MODULE_LDFLAGS@ +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/Makefile.inc $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu navit/map/csv/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu navit/map/csv/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-modulemapLTLIBRARIES: $(modulemap_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(modulemapdir)" || $(MKDIR_P) "$(DESTDIR)$(modulemapdir)" + @list='$(modulemap_LTLIBRARIES)'; test -n "$(modulemapdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(modulemapdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(modulemapdir)"; \ + } + +uninstall-modulemapLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(modulemap_LTLIBRARIES)'; test -n "$(modulemapdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(modulemapdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(modulemapdir)/$$f"; \ + done + +clean-modulemapLTLIBRARIES: + -test -z "$(modulemap_LTLIBRARIES)" || rm -f $(modulemap_LTLIBRARIES) + @list='$(modulemap_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libmap_csv.la: $(libmap_csv_la_OBJECTS) $(libmap_csv_la_DEPENDENCIES) + $(libmap_csv_la_LINK) $(am_libmap_csv_la_rpath) $(libmap_csv_la_OBJECTS) $(libmap_csv_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/csv.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/quadtree.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: + for dir in "$(DESTDIR)$(modulemapdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-modulemapLTLIBRARIES \ + clean-noinstLTLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-modulemapLTLIBRARIES + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-modulemapLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-modulemapLTLIBRARIES \ + clean-noinstLTLIBRARIES ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man \ + install-modulemapLTLIBRARIES install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-modulemapLTLIBRARIES + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/navit/map/csv/csv.c b/navit/map/csv/csv.c new file mode 100644 index 000000000..e7e415405 --- /dev/null +++ b/navit/map/csv/csv.c @@ -0,0 +1,348 @@ +/** + * Navit, a modular navigation system. + * Copyright (C) 2005-2011 Navit Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include <glib.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <math.h> +#include "config.h" +#include "debug.h" +#include "plugin.h" +#include "projection.h" +#include "item.h" +#include "map.h" +#include "maptype.h" +#include "attr.h" +#include "transform.h" +#include "file.h" +#include "quadtree.h" + +#include "csv.h" + +static int map_id; + + +struct quadtree_data +{ + struct item* item; + GList* attr_list; +}; + +static void +map_destroy_csv(struct map_priv *m) +{ + dbg(1,"map_destroy_csv\n"); + g_free(m); + g_hash_table_destroy(m->item_hash); + quadtree_destroy(m->tree_root); +} + +static void +csv_coord_rewind(void *priv_data) +{ +} + +static int +csv_coord_get(void *priv_data, struct coord *c, int count) +{ + struct map_rect_priv *mr=priv_data; + if(mr) { + *c = mr->c; + return 1; + } + else { + return 0; + } +} + +static void +csv_attr_rewind(void *priv_data) +{ + struct map_rect_priv *mr=priv_data; + //TODO implement if needed +} + +static int +csv_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) +{ + struct map_rect_priv *mr=priv_data; + + GList* attr_list = ((struct quadtree_data*)(((struct quadtree_item*)(mr->curr_item->data))->data))->attr_list; + if (attr_type == attr_any) { + } + + while(attr_list) { + if(((struct attr*)attr_list->data)->type == attr_type) { + *attr = *(struct attr*)attr_list->data; + return 1; + } + attr_list = g_list_next(attr_list); + } + attr = NULL; + return 0; +} + +static struct item_methods methods_csv = { + csv_coord_rewind, + csv_coord_get, + csv_attr_rewind, + csv_attr_get, +}; + +static struct map_rect_priv * +map_rect_new_csv(struct map_priv *map, struct map_selection *sel) +{ + struct map_rect_priv *mr; + + dbg(1,"map_rect_new_csv\n"); + mr=g_new0(struct map_rect_priv, 1); + mr->m=map; + mr->bStarted = 0; + mr->sel=sel; + if (map->flags & 1) + mr->item.id_hi=1; + else + mr->item.id_hi=0; + mr->item.id_lo=0; + mr->item.meth=&methods_csv; + mr->item.priv_data=mr; + + //convert selection to geo + struct coord_geo lu; + struct coord_geo rl; + transform_to_geo(projection_mg, &sel->u.c_rect.lu, &lu); + transform_to_geo(projection_mg, &sel->u.c_rect.rl, &rl); + GList*res = NULL; + quadtree_find_rect_items(map->tree_root, lu.lng, rl.lng, rl.lat, lu.lat, &res); + mr->query_result = res; + mr->curr_item = res; + return mr; +} + + +static void +map_rect_destroy_csv(struct map_rect_priv *mr) +{ + g_free(mr); +} + +static struct item * +map_rect_get_item_csv(struct map_rect_priv *mr) +{ + if(mr->bStarted) { + mr->curr_item = g_list_next(mr->curr_item); + } + else { + mr->bStarted = 1; + } + + if(mr->curr_item) { + struct item* ret; + ret = ((struct quadtree_data*)(((struct quadtree_item*)(mr->curr_item->data))->data))->item; + ret->priv_data=mr; + struct coord_geo cg; + if(mr->curr_item && mr->curr_item->data) { + cg.lng = ((struct quadtree_item*)(mr->curr_item->data))->longitude; + cg.lat = ((struct quadtree_item*)(mr->curr_item->data))->latitude; + transform_from_geo(projection_mg, &cg, &mr->c); + ret = ((struct quadtree_data*)(((struct quadtree_item*)(mr->curr_item->data))->data))->item; + return ret; + } + + } + return NULL; +} + +static struct item * +map_rect_get_item_byid_csv(struct map_rect_priv *mr, int id_hi, int id_lo) +{ + //currently id_hi is ignored + return g_hash_table_lookup(mr->m->item_hash,id_lo); +} + +static struct map_methods map_methods_csv = { + projection_mg, + "iso8859-1", + map_destroy_csv, + map_rect_new_csv, + map_rect_destroy_csv, + map_rect_get_item_csv, + map_rect_get_item_byid_csv, +}; + +static struct map_priv * +map_new_csv(struct map_methods *meth, struct attr **attrs) +{ + struct map_priv *m = NULL; + m = g_new0(struct map_priv, 1); + m->id = ++map_id; + m->item_hash = g_hash_table_new(g_int_hash, g_int_equal); + + struct attr *item_type = attr_search(attrs, NULL, attr_item_type); + struct attr *attr_types = attr_search(attrs, NULL, attr_attr_types); + int bLonFound = 0; + int bLatFound = 0; + int attr_cnt = 0; + enum attr_type* attr_type_list = NULL; + struct quadtree_node* tree_root = quadtree_node_new(NULL,-90,90,-90,90); + if(attr_types) { + enum attr_type* at = attr_types->u.attr_types; + while(*at != attr_none) { + attr_type_list = g_realloc(attr_type_list,sizeof(enum attr_type)*(attr_cnt+1)); + attr_type_list[attr_cnt] = *at; + if(*at==attr_position_latitude) { + bLatFound = 1; + } + else if(*at==attr_position_longitude) { + bLonFound = 1; + } + ++attr_cnt; + ++at; + } + } + else { + return NULL; + } + + if(bLonFound==0 || bLatFound==0) { + return NULL; + } + + struct attr *item_type_attr=attr_search(attrs, NULL, attr_item_type); + + if( !item_type_attr || item_type_attr->u.item_type==type_none) { + return NULL; + } + + struct attr *data=attr_search(attrs, NULL, attr_data); + + if(data) { + //load csv file into quadtree structure + //if column number is wrong skip + FILE*fp; + if((fp=fopen(data->u.str,"rt"))) { + int item_idx = 0; + while(!feof(fp)) { + const int max_line_len = 256; + char line[max_line_len]; + if(fgets(line,max_line_len,fp)) { + char*line2 = g_strdup(line); + //count columns + //TODO make delimiter parameter + char* delim = ","; + int col_cnt=0; + char*tok; + while((tok=strtok( (col_cnt==0)?line:NULL , delim))) { + ++col_cnt; + } + + if(col_cnt==attr_cnt) { + int cnt = 0; //idx of current attr + char*tok; + const int zoom_max = 18; + struct item *curr_item = item_new("",zoom_max);//does not use parameters + curr_item->type = item_type_attr->u.item_type; + curr_item->id_lo = item_idx; + if (m->flags & 1) + curr_item->id_hi=1; + else + curr_item->id_hi=0; + curr_item->meth=&methods_csv; + + GList* attr_list = NULL; + int bAddSum = 1; + double longitude = 0.0, latitude=0.0; + while((tok=strtok( (cnt==0)?line2:NULL , delim))) { + struct attr*curr_attr = g_new0(struct attr,1); + curr_attr->type = attr_types->u.attr_types[cnt]; + int bAdd = 1; + if(ATTR_IS_STRING(attr_types->u.attr_types[cnt])) { + curr_attr->u.str = g_strdup(tok); + } + else if(ATTR_IS_INT(attr_types->u.attr_types[cnt])) { + curr_attr->u.num = atoi(tok); + } + else if(ATTR_IS_DOUBLE(attr_types->u.attr_types[cnt])) { + double *d = g_new(double,1); + *d = atof(tok); + curr_attr->u.numd = d; + if(attr_types->u.attr_types[cnt] == attr_position_longitude) { + longitude = *d; + } + if(attr_types->u.attr_types[cnt] == attr_position_latitude) { + latitude = *d; + } + } + else { + //unknown attribute + bAddSum = bAdd = 0; + g_free(curr_attr); + } + + if(bAdd) { + attr_list = g_list_prepend(attr_list, curr_attr); + } + ++cnt; + } + if(bAddSum) { + struct quadtree_data* qd = g_new0(struct quadtree_data,1); + qd->item = curr_item; + qd->attr_list = attr_list; + struct quadtree_item* qi =g_new(struct quadtree_item,1); + qi->data = qd; + qi->longitude = longitude; + qi->latitude = latitude; + quadtree_add(tree_root, qi); + g_hash_table_insert(m->item_hash, item_idx,curr_item); + ++item_idx; + } + else { + g_free(curr_item); + } + + } + else { + //printf("ERROR: Non-matching attr count and column count: %d %d SKIPPING line: %s\n",col_cnt, attr_cnt,line); + } + g_free(line2); + } + } + fclose(fp); + } + else { + return NULL; + } + } + + *meth = map_methods_csv; + m->tree_root = tree_root; + struct attr *flags=attr_search(attrs, NULL, attr_flags); + if (flags) + m->flags=flags->u.num; + return m; +} + +void +plugin_init(void) +{ + dbg(1,"csv: plugin_init\n"); + plugin_register_map_type("csv", map_new_csv); +} + diff --git a/navit/map/csv/csv.h b/navit/map/csv/csv.h new file mode 100644 index 000000000..81ba94805 --- /dev/null +++ b/navit/map/csv/csv.h @@ -0,0 +1,47 @@ +/** + * Navit, a modular navigation system. + * Copyright (C) 2005-2008 Navit Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include <stdio.h> +#include <glib.h> + +#include "attr.h" +#include "coord.h" +#include "quadtree.h" + + +struct map_priv { + + int id; + struct quadtree* tree_root; + int flags; + GHashTable*item_hash; +}; + +#define SIZE 512 + +struct map_rect_priv { + struct map_selection *sel; + GList* query_result; + GList* curr_item; + struct coord c; + int bStarted; + struct item item; + struct map_priv *m; +}; + diff --git a/navit/map/csv/quadtree.c b/navit/map/csv/quadtree.c new file mode 100644 index 000000000..2bd9f0a99 --- /dev/null +++ b/navit/map/csv/quadtree.c @@ -0,0 +1,299 @@ +#include "quadtree.h" + +#include <stdlib.h> + +#define QUADTREE_NODE_CAPACITY 10 + +#define MAX_DOUBLE 9999999 + +static double +dist_sq(double x1,double y1,double x2,double y2) +{ + return (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1); +} + +struct quadtree_node* +quadtree_node_new(struct quadtree_node* parent, double xmin, double xmax, double ymin, double ymax ) { + struct quadtree_node*ret = calloc(1, sizeof(struct quadtree_node)); + ret->xmin = xmin; + ret->xmax = xmax; + ret->ymin = ymin; + ret->ymax = ymax; + ret->is_leaf = 1; + ret->parent = parent; + return ret; +} + +/* + * searches all four subnodes recursively for the list of items within a rectangle + */ +void +quadtree_find_rect_items(struct quadtree_node* this_, double dXMin, double dXMax, double dYMin, double dYMax, GList**out) { + + struct quadtree_node* nodes[4] = { this_->aa, this_->ab, this_->ba, this_->bb }; + if( this_->is_leaf ) { + int i; + //double distance_sq = current_max; + for(i=0;i<this_->node_num;++i) { //select only items within input rectangle + if(dXMin<=this_->items[i].longitude && this_->items[i].longitude<=dXMax && + dYMin<=this_->items[i].latitude && this_->items[i].latitude<=dYMax + ) { + *out=g_list_prepend(*out,&this_->items[i]); + } + } + } + else { + int i; + for( i=0;i<4;++i) { + if(nodes[i] ) { + //limit flooding + if(nodes[i]->xmax<dXMin || dXMax<nodes[i]->xmin || + nodes[i]->ymax<dYMin || dYMax<nodes[i]->ymin + ) { + continue; + } + struct quadtree_item*res_tmp = NULL; + //recurse into subtiles if there is at least one subtile corner within input rectangle + quadtree_find_rect_items(nodes[i],dXMin,dXMax,dYMin,dYMax,out); + } + } + } +} + +/* + * searches all four subnodes recursively for the closest item + */ +struct quadtree_item* +quadtree_find_nearest_flood(struct quadtree_node* this_, struct quadtree_item* item, double current_max, struct quadtree_node* toSkip) { + struct quadtree_node* nodes[4] = { this_->aa, this_->ab, this_->ba, this_->bb }; + struct quadtree_item*res = NULL; + if( this_->is_leaf ) { + int i; + double distance_sq = current_max; + for(i=0;i<this_->node_num;++i) { + double curr_dist_sq = dist_sq(item->longitude,item->latitude,this_->items[i].longitude,this_->items[i].latitude); + if(curr_dist_sq<distance_sq) { + distance_sq = curr_dist_sq; + res = &this_->items[i]; + } + } + } + else { + int i; + for( i=0;i<4;++i) { + if(nodes[i] && nodes[i]!=toSkip) { + //limit flooding + struct quadtree_item*res_tmp = NULL; + if( + dist_sq(nodes[i]->xmin,nodes[i]->ymin,item->longitude,item->latitude)<current_max || + dist_sq(nodes[i]->xmax,nodes[i]->ymin,item->longitude,item->latitude)<current_max || + dist_sq(nodes[i]->xmax,nodes[i]->ymax,item->longitude,item->latitude)<current_max || + dist_sq(nodes[i]->xmin,nodes[i]->ymax,item->longitude,item->latitude)<current_max + ) { + res_tmp = quadtree_find_nearest_flood(nodes[i],item,current_max,NULL); + } + if(res_tmp) { + res = res_tmp; + double curr_dist_sq = dist_sq(item->longitude,item->latitude,res->longitude,res->latitude); + if(curr_dist_sq<current_max) { + current_max = curr_dist_sq; + } + } + } + } + } + return res; +} + +/* + * tries to find closest item, first it descend into the quadtree as much as possible, then if no point is found + */ +struct quadtree_item* +quadtree_find_nearest(struct quadtree_node* this_, struct quadtree_item* item) { + if( ! this_ ) { + return NULL; + } + struct quadtree_item*res = NULL; + double distance_sq = MAX_DOUBLE; + if( this_->is_leaf ) { + int i; + for(i=0;i<this_->node_num;++i) { + double curr_dist_sq = dist_sq(item->longitude,item->latitude,this_->items[i].longitude,this_->items[i].latitude); + if(curr_dist_sq<distance_sq) { + distance_sq = curr_dist_sq; + res = &this_->items[i]; + } + } + //go up n levels + if(!res && this_->parent) { + struct quadtree_node* anchestor = this_->parent; + int cnt = 0; + while (anchestor->parent && cnt<4) { + anchestor = anchestor->parent; + ++cnt; + } + struct quadtree_item*res2 = NULL; + res2 = quadtree_find_nearest_flood(anchestor,item,distance_sq,NULL); + if(res2) { + res = res2; + } + } + } + else { + if( + this_->aa && + this_->aa->xmin<=item->longitude && item->longitude<this_->aa->xmax && + this_->aa->ymin<=item->latitude && item->latitude<this_->aa->ymax + ) { + res = quadtree_find_nearest(this_->aa,item); + } + else if( + this_->ab && + this_->ab->xmin<=item->longitude && item->longitude<this_->ab->xmax && + this_->ab->ymin<=item->latitude && item->latitude<this_->ab->ymax + ) { + res = quadtree_find_nearest(this_->ab,item); + } + else if( + this_->ba && + this_->ba->xmin<=item->longitude && item->longitude<this_->ba->xmax && + this_->ba->ymin<=item->latitude && item->latitude<this_->ba->ymax + ) { + res = quadtree_find_nearest(this_->ba,item); + } + else if( + this_->bb && + this_->bb->xmin<=item->longitude && item->longitude<this_->bb->xmax && + this_->bb->ymin<=item->latitude && item->latitude<this_->bb->ymax + ) { + res = quadtree_find_nearest(this_->bb,item); + } + else { + if(this_->parent) { + //go up two levels + struct quadtree_node* anchestor = this_->parent; + int cnt = 0; + while (anchestor->parent && cnt<4) { + anchestor = anchestor->parent; + ++cnt; + } + res = quadtree_find_nearest_flood(anchestor,item,distance_sq,NULL); + } + } + } + return res; +} + +void +quadtree_add(struct quadtree_node* this_, struct quadtree_item* item) { + if( this_->is_leaf ) { + this_->items[this_->node_num++] = *item; + if(QUADTREE_NODE_CAPACITY == this_->node_num) { + quadtree_split(this_); + } + } + else { + if( + this_->xmin<=item->longitude && item->longitude<this_->xmin+(this_->xmax-this_->xmin)/2.0 && + this_->ymin<=item->latitude && item->latitude<this_->ymin+(this_->ymax-this_->ymin)/2.0 + ) { + if(!this_->aa) { + this_->aa = quadtree_node_new( this_, this_->xmin, this_->xmin+(this_->xmax-this_->xmin)/2.0 , this_->ymin, this_->ymin+(this_->ymax-this_->ymin)/2.0 ); + } + quadtree_add(this_->aa,item); + } + else if( + this_->xmin+(this_->xmax-this_->xmin)/2.0<=item->longitude && item->longitude<this_->xmax && + this_->ymin<=item->latitude && item->latitude<this_->ymin+(this_->ymax-this_->ymin)/2.0 + ) { + if(!this_->ab) { + this_->ab = quadtree_node_new( this_, this_->xmin+(this_->xmax-this_->xmin)/2.0, this_->xmax , this_->ymin, this_->ymin+(this_->ymax-this_->ymin)/2.0 ); + } + quadtree_add(this_->ab,item); + } + else if( + this_->xmin<=item->longitude && item->longitude<this_->xmin+(this_->xmax-this_->xmin)/2.0 && + this_->ymin+(this_->ymax-this_->ymin)/2.0<=item->latitude && item->latitude<this_->ymax + ) { + if(!this_->ba) { + this_->ba = quadtree_node_new( this_, this_->xmin, this_->xmin+(this_->xmax-this_->xmin)/2.0 , this_->ymin+(this_->ymax-this_->ymin)/2.0 , this_->ymax); + } + quadtree_add(this_->ba,item); + } + else if( + this_->xmin+(this_->xmax-this_->xmin)/2.0<=item->longitude && item->longitude<this_->xmax && + this_->ymin+(this_->ymax-this_->ymin)/2.0<=item->latitude && item->latitude<this_->ymax + ) { + if(!this_->bb) { + this_->bb = quadtree_node_new( this_, this_->xmin+(this_->xmax-this_->xmin)/2.0, this_->xmax , this_->ymin+(this_->ymax-this_->ymin)/2.0 , this_->ymax); + } + quadtree_add(this_->bb,item); + } + } +} + +void +quadtree_split(struct quadtree_node* this_) { + int i; + this_->is_leaf = 0; + for(i=0;i<this_->node_num;++i) { + if( + this_->xmin<=this_->items[i].longitude && this_->items[i].longitude<this_->xmin+(this_->xmax-this_->xmin)/2.0 && + this_->ymin<=this_->items[i].latitude && this_->items[i].latitude<this_->ymin+(this_->ymax-this_->ymin)/2.0 + ) { + if(!this_->aa) { + this_->aa = quadtree_node_new( this_, this_->xmin, this_->xmin+(this_->xmax-this_->xmin)/2.0 , this_->ymin, this_->ymin+(this_->ymax-this_->ymin)/2.0 ); + } + quadtree_add(this_->aa,&this_->items[i]); + } + else if( + this_->xmin+(this_->xmax-this_->xmin)/2.0<=this_->items[i].longitude && this_->items[i].longitude<this_->xmax && + this_->ymin<=this_->items[i].latitude && this_->items[i].latitude<this_->ymin+(this_->ymax-this_->ymin)/2.0 + ) { + if(!this_->ab) { + this_->ab = quadtree_node_new( this_, this_->xmin+(this_->xmax-this_->xmin)/2.0, this_->xmax , this_->ymin, this_->ymin+(this_->ymax-this_->ymin)/2.0 ); + } + quadtree_add(this_->ab,&this_->items[i]); + } + else if( + this_->xmin<=this_->items[i].longitude && this_->items[i].longitude<this_->xmin+(this_->xmax-this_->xmin)/2.0 && + this_->ymin+(this_->ymax-this_->ymin)/2.0<=this_->items[i].latitude && this_->items[i].latitude<this_->ymax + ) { + if(!this_->ba) { + this_->ba = quadtree_node_new( this_, this_->xmin, this_->xmin+(this_->xmax-this_->xmin)/2.0 , this_->ymin+(this_->ymax-this_->ymin)/2.0 , this_->ymax); + } + quadtree_add(this_->ba,&this_->items[i]); + } + else if( + this_->xmin+(this_->xmax-this_->xmin)/2.0<=this_->items[i].longitude && this_->items[i].longitude<this_->xmax && + this_->ymin+(this_->ymax-this_->ymin)/2.0<=this_->items[i].latitude && this_->items[i].latitude<this_->ymax + ) { + if(!this_->bb) { + this_->bb = quadtree_node_new( this_, this_->xmin+(this_->xmax-this_->xmin)/2.0, this_->xmax , this_->ymin+(this_->ymax-this_->ymin)/2.0 , this_->ymax); + } + quadtree_add(this_->bb,&this_->items[i]); + } + } + this_->node_num = 0; +} + +void +quadtree_destroy(struct quadtree_node* this_) { + if(this_->aa) { + quadtree_destroy(this_->aa); + } + if(this_->ab) { + quadtree_destroy(this_->ab); + } + if(this_->ba) { + quadtree_destroy(this_->ba); + } + if(this_->bb) { + quadtree_destroy(this_->bb); + } + free(this_); +} + + + + diff --git a/navit/map/csv/quadtree.h b/navit/map/csv/quadtree.h new file mode 100644 index 000000000..9bc74cce3 --- /dev/null +++ b/navit/map/csv/quadtree.h @@ -0,0 +1,36 @@ +#ifndef QUADTREE_H +#define QUADTREE_H + +#include <glib.h> + +#define QUADTREE_NODE_CAPACITY 10 + +struct quadtree_item { + double longitude; + double latitude; + void* data; +}; + +struct quadtree_node { + int node_num; + struct quadtree_item items[QUADTREE_NODE_CAPACITY]; + struct quadtree_node *aa; + struct quadtree_node *ab; + struct quadtree_node *ba; + struct quadtree_node *bb; + double xmin, xmax, ymin, ymax; + int is_leaf; + struct quadtree_node*parent; +}; + +struct quadtree_node* quadtree_node_new(struct quadtree_node* parent, double xmin, double xmax, double ymin, double ymax ); +struct quadtree_item* quadtree_find_nearest_flood(struct quadtree_node* this_, struct quadtree_item* item, double current_max, struct quadtree_node* toSkip); +struct quadtree_item* quadtree_find_nearest(struct quadtree_node* this_, struct quadtree_item* item); +void quadtree_find_rect_items(struct quadtree_node* this_, double dXMin, double dXMax, double dYMin, double dYMax, GList**out); +void quadtree_split(struct quadtree_node* this_); +void quadtree_add(struct quadtree_node* this_, struct quadtree_item* item); +void quadtree_destroy(struct quadtree_node* this_); + + + +#endif |