navit  0.5.3-trunk
binfile.c File Reference
#include <stdlib.h>
#include <glib.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 "coord.h"
#include "transform.h"
#include "file.h"
#include "zipfile.h"
#include "linguistics.h"
#include "endianess.h"
#include "callback.h"
#include "types.h"
#include "geom.h"

Data Structures

struct  tile
 A map tile, a rectangular region of the world. More...
 
struct  map_download
 
struct  map_priv
 Represents the map from a single binfile. More...
 
struct  map_rect_priv
 Implementation-specific map rect data. More...
 
struct  map_search_priv
 Represents a search on a map. This struct represents a search on a map; it is created when starting a search, and is used for retrieving results. More...
 
struct  binfile_hash_entry
 
struct  duplicate
 

Functions

static void push_tile (struct map_rect_priv *mr, struct tile *t, int offset, int length)
 
static void setup_pos (struct map_rect_priv *mr)
 
static void map_binfile_close (struct map_priv *m)
 
static int map_binfile_open (struct map_priv *m)
 
static void map_binfile_destroy (struct map_priv *m)
 
static void lfh_to_cpu (struct zip_lfh *lfh)
 
static void cd_to_cpu (struct zip_cd *zcd)
 
static void eoc_to_cpu (struct zip_eoc *eoc)
 
static void binfile_check_version (struct map_priv *m)
 
static struct zip_eocbinfile_read_eoc (struct file *fi)
 
static struct zip64_eocbinfile_read_eoc64 (struct file *fi)
 
static int binfile_cd_extra (struct zip_cd *cd)
 
static struct zip_cdbinfile_read_cd (struct map_priv *m, int offset, int len)
 
static struct zip_cd_extbinfile_cd_ext (struct zip_cd *cd)
 Get the ZIP64 extra field data corresponding to a zip central directory header. More...
 
static long long binfile_cd_offset (struct zip_cd *cd)
 
static struct zip_lfhbinfile_read_lfh (struct file *fi, long long offset)
 
static unsigned char * binfile_read_content (struct map_priv *m, struct file *fi, long long offset, struct zip_lfh *lfh)
 
static int binfile_search_cd (struct map_priv *m, int offset, char *name, int partial, int skip)
 
static void map_destroy_binfile (struct map_priv *m)
 
static void binfile_coord_rewind (void *priv_data)
 
static int binfile_coord_left (void *priv_data)
 
static int binfile_coord_get (void *priv_data, struct coord *c, int count)
 
static int binfile_coords_left (void *priv_data)
 Get nuber of coords left for current item. More...
 
static void binfile_attr_rewind (void *priv_data)
 
static char * binfile_extract (struct map_priv *m, char *dir, char *filename, int partial)
 
static int binfile_attr_get (void *priv_data, enum attr_type attr_type, struct attr *attr)
 
static guint binfile_hash_entry_hash (gconstpointer key)
 
static gboolean binfile_hash_entry_equal (gconstpointer a, gconstpointer b)
 
static int * binfile_item_dup (struct map_priv *m, struct item *item, struct tile *t, int extend)
 
static int binfile_coord_set (void *priv_data, struct coord *c, int count, enum change_mode mode)
 
static int binfile_attr_set (void *priv_data, struct attr *attr, enum change_mode mode)
 
static int pop_tile (struct map_rect_priv *mr)
 
static int zipfile_to_tile (struct map_priv *m, struct zip_cd *cd, struct tile *t)
 
static int map_binfile_handle_redirect (struct map_priv *m)
 
static int map_binfile_http_request (struct map_priv *m, struct attr **attrs)
 
static long long map_binfile_download_size (struct map_priv *m)
 
static int map_binfile_http_close (struct map_priv *m)
 
static struct filemap_binfile_http_range (struct map_priv *m, long long offset, int size)
 
static unsigned char * map_binfile_download_range (struct map_priv *m, long long offset, int size)
 
static struct zip_cddownload_cd (struct map_download *download)
 
static int download_request (struct map_download *download)
 
static int download_start (struct map_download *download)
 
static int download_download (struct map_download *download)
 
static int download_finish (struct map_download *download)
 
static int download_planet_size (struct map_download *download)
 
static int download_eoc (struct map_download *download)
 
static int download_directory_start (struct map_download *download)
 
static int download_directory_do (struct map_download *download)
 
static int download_directory_finish (struct map_download *download)
 
static int download_initial_finish (struct map_download *download)
 
static void push_zipfile_tile_do (struct map_rect_priv *mr, struct zip_cd *cd, int zipfile, int offset, int length)
 
static struct zip_cddownload (struct map_priv *m, struct map_rect_priv *mr, struct zip_cd *cd, int zipfile, int offset, int length, int async)
 
static int push_zipfile_tile (struct map_rect_priv *mr, int zipfile, int offset, int length, int async)
 
static struct map_rect_privmap_rect_new_binfile_int (struct map_priv *map, struct map_selection *sel)
 
static void tile_bbox (char *tile, int len, struct coord_rect *r)
 
static int map_download_selection_check (struct zip_cd *cd, struct map_selection *sel)
 
static void map_download_selection (struct map_priv *m, struct map_rect_priv *mr, struct map_selection *sel)
 
static struct map_rect_privmap_rect_new_binfile (struct map_priv *map, struct map_selection *sel)
 
static void write_changes_do (gpointer key, gpointer value, gpointer user_data)
 
static void write_changes (struct map_priv *m)
 
static void load_changes (struct map_priv *m)
 
static void map_rect_destroy_binfile (struct map_rect_priv *mr)
 
static int selection_contains (struct map_selection *sel, struct coord_rect *r, struct range *mima)
 
static void map_parse_country_binfile (struct map_rect_priv *mr)
 
static int map_parse_submap (struct map_rect_priv *mr, int async)
 
static int push_modified_item (struct map_rect_priv *mr)
 
static struct itemmap_rect_get_item_binfile (struct map_rect_priv *mr)
 
static struct itemmap_rect_get_item_byid_binfile (struct map_rect_priv *mr, int id_hi, int id_lo)
 
static int binmap_search_by_index (struct map_priv *map, struct item *item, struct map_rect_priv **ret)
 
static struct map_rect_privbinmap_search_street_by_place (struct map_priv *map, struct item *town, struct coord *c, struct map_selection *sel, GList **boundaries)
 
static int binmap_get_estimated_town_size (struct item *town)
 
static struct map_rect_privbinmap_search_street_by_estimate (struct map_priv *map, struct item *town, struct coord *c, struct map_selection *sel)
 
static struct map_rect_privbinmap_search_housenumber_by_estimate (struct map_priv *map, struct coord *c, struct map_selection *sel)
 
static int binmap_get_estimated_boundaries (struct item *town, GList **boundaries)
 
static struct map_search_privbinmap_search_new (struct map_priv *map, struct item *item, struct attr *search, int partial)
 
static guint duplicate_hash (gconstpointer key)
 
static gboolean duplicate_equal (gconstpointer a, gconstpointer b)
 
static struct duplicateduplicate_test (struct map_search_priv *msp, struct item *item, enum attr_type attr_type, enum attr_type attr_type2)
 Test an item if it's duplicate. If it's not a duplicate, return new struct duplicate to be duplicate_insert()'ed. More...
 
static void duplicate_insert (struct map_search_priv *msp, struct duplicate *d)
 Insert struct duplicate item into the duplicate hash. More...
 
static int duplicate (struct map_search_priv *msp, struct item *item, enum attr_type attr_type, enum attr_type attr_type2)
 Check if item is duplicate and update duplicate hash if needed. More...
 
static int item_inside_poly_list (struct item *it, GList *l)
 
static struct itembinmap_search_get_item (struct map_search_priv *map_search)
 
static void binmap_search_destroy (struct map_search_priv *ms)
 
static int binmap_get_attr (struct map_priv *m, enum attr_type type, struct attr *attr)
 
static int binmap_set_attr (struct map_priv *map, struct attr *attr)
 
static int binfile_get_index (struct map_priv *m)
 
static int map_binfile_zip_setup (struct map_priv *m, char *filename, int mmap)
 
static struct map_privmap_new_binfile (struct map_methods *meth, struct attr **attrs, struct callback_list *cbl)
 
void plugin_init (void)
 

Variables

static int map_id
 
static struct item_methods methods_binfile
 
static struct map_methods map_methods_binfile
 

Function Documentation

◆ binfile_attr_get()

◆ binfile_attr_rewind()

◆ binfile_attr_set()

◆ binfile_cd_ext()

static struct zip_cd_ext* binfile_cd_ext ( struct zip_cd cd)
static

Get the ZIP64 extra field data corresponding to a zip central directory header.

Parameters
cdpointer to zip central directory structure
Returns
pointer to ZIP64 extra field, or NULL if not available

References zip_cd_ext::size, zip_cd_ext::tag, zip_extra_header_id_zip64, zip_size_64bit_placeholder, zip_cd::zipcfnl, zip_cd::zipcxtl, and zip_cd::zipofst.

Referenced by binfile_cd_offset(), and download_finish().

◆ binfile_cd_extra()

static int binfile_cd_extra ( struct zip_cd cd)
static

◆ binfile_cd_offset()

static long long binfile_cd_offset ( struct zip_cd cd)
static
Parameters
cdpointer to zip central directory structure
Returns
Offset of local file header in zip file. Will use ZIP64 data if present.

References binfile_cd_ext(), zip_cd::zipofst, and zip_cd_ext::zipofst.

Referenced by binfile_extract(), download_finish(), download_request(), and zipfile_to_tile().

◆ binfile_check_version()

static void binfile_check_version ( struct map_priv m)
static

◆ binfile_coord_get()

static int binfile_coord_get ( void *  priv_data,
struct coord c,
int  count 
)
static

◆ binfile_coord_left()

static int binfile_coord_left ( void *  priv_data)
inlinestatic

◆ binfile_coord_rewind()

static void binfile_coord_rewind ( void *  priv_data)
static

◆ binfile_coord_set()

◆ binfile_coords_left()

static int binfile_coords_left ( void *  priv_data)
static

Get nuber of coords left for current item.

Parameters
prv_data

References binfile_coord_left().

◆ binfile_extract()

◆ binfile_get_index()

◆ binfile_hash_entry_equal()

static gboolean binfile_hash_entry_equal ( gconstpointer  a,
gconstpointer  b 
)
static

◆ binfile_hash_entry_hash()

static guint binfile_hash_entry_hash ( gconstpointer  key)
static

◆ binfile_item_dup()

◆ binfile_read_cd()

◆ binfile_read_content()

static unsigned char* binfile_read_content ( struct map_priv m,
struct file fi,
long long  offset,
struct zip_lfh lfh 
)
static

◆ binfile_read_eoc()

static struct zip_eoc* binfile_read_eoc ( struct file fi)
static

◆ binfile_read_eoc64()

◆ binfile_read_lfh()

static struct zip_lfh* binfile_read_lfh ( struct file fi,
long long  offset 
)
static

◆ binfile_search_cd()

◆ binmap_get_attr()

static int binmap_get_attr ( struct map_priv m,
enum attr_type  type,
struct attr attr 
)
static

◆ binmap_get_estimated_boundaries()

◆ binmap_get_estimated_town_size()

static int binmap_get_estimated_town_size ( struct item town)
static

◆ binmap_search_by_index()

static int binmap_search_by_index ( struct map_priv map,
struct item item,
struct map_rect_priv **  ret 
)
static

◆ binmap_search_destroy()

◆ binmap_search_get_item()

◆ binmap_search_housenumber_by_estimate()

static struct map_rect_priv* binmap_search_housenumber_by_estimate ( struct map_priv map,
struct coord c,
struct map_selection sel 
)
static

◆ binmap_search_new()

◆ binmap_search_street_by_estimate()

static struct map_rect_priv* binmap_search_street_by_estimate ( struct map_priv map,
struct item town,
struct coord c,
struct map_selection sel 
)
static

◆ binmap_search_street_by_place()

◆ binmap_set_attr()

static int binmap_set_attr ( struct map_priv map,
struct attr attr 
)
static

References attr::num, attr::type, and attr::u.

◆ cd_to_cpu()

◆ download()

◆ download_cd()

◆ download_directory_do()

static int download_directory_do ( struct map_download download)
static

◆ download_directory_finish()

static int download_directory_finish ( struct map_download download)
static

References download().

Referenced by download().

◆ download_directory_start()

static int download_directory_start ( struct map_download download)
static

References download(), and map_binfile_http_range().

Referenced by download().

◆ download_download()

static int download_download ( struct map_download download)
static

◆ download_eoc()

static int download_eoc ( struct map_download download)
static

◆ download_finish()

◆ download_initial_finish()

static int download_initial_finish ( struct map_download download)
static

References download(), and file_data_write().

Referenced by download().

◆ download_planet_size()

static int download_planet_size ( struct map_download download)
static

◆ download_request()

◆ download_start()

static int download_start ( struct map_download download)
static

◆ duplicate()

static int duplicate ( struct map_search_priv msp,
struct item item,
enum attr_type  attr_type,
enum attr_type  attr_type2 
)
static

Check if item is duplicate and update duplicate hash if needed.

Parameters
msppointer to private map search data
itemitem to check
attr_type
attr_type2,optional,allowsto check for duplicate combinations of 2 attributes
Returns
0 if item is not a duplicate 1 if item is duplicate or doesn't have required attr_type attribute

References duplicate_insert(), and duplicate_test().

Referenced by binmap_search_get_item().

◆ duplicate_equal()

static gboolean duplicate_equal ( gconstpointer  a,
gconstpointer  b 
)
static

References duplicate::c, duplicate::str, coord::x, and coord::y.

Referenced by duplicate_test().

◆ duplicate_hash()

static guint duplicate_hash ( gconstpointer  key)
static

References duplicate::c, key, duplicate::str, coord::x, and coord::y.

Referenced by duplicate_test().

◆ duplicate_insert()

static void duplicate_insert ( struct map_search_priv msp,
struct duplicate d 
)
static

Insert struct duplicate item into the duplicate hash.

Parameters
msppointer to private map search data
duplicateDuplicate info to insert

References map_search_priv::search_results.

Referenced by binmap_search_get_item(), and duplicate().

◆ duplicate_test()

static struct duplicate* duplicate_test ( struct map_search_priv msp,
struct item item,
enum attr_type  attr_type,
enum attr_type  attr_type2 
)
static

Test an item if it's duplicate. If it's not a duplicate, return new struct duplicate to be duplicate_insert()'ed.

Parameters
msppointer to private map search data
itemitem to check
attr_type
attr_type2,optional,allowsto check for duplicate combinations of 2 attributes returns - pointer to new struct duplicate, if this item is not already exist in hash
  • NULL if this item already exists in duplicate hash or doesnt have an attr_type attr;

References binfile_attr_rewind(), binfile_coord_rewind(), duplicate::c, duplicate_equal(), duplicate_hash(), item_attr_get(), item_coord_get(), item::priv_data, map_search_priv::search_results, attr::str, duplicate::str, attr::u, coord::x, and coord::y.

Referenced by binmap_search_get_item(), and duplicate().

◆ eoc_to_cpu()

◆ item_inside_poly_list()

static int item_inside_poly_list ( struct item it,
GList l 
)
static

◆ lfh_to_cpu()

◆ load_changes()

◆ map_binfile_close()

◆ map_binfile_destroy()

static void map_binfile_destroy ( struct map_priv m)
static

◆ map_binfile_download_range()

static unsigned char* map_binfile_download_range ( struct map_priv m,
long long  offset,
int  size 
)
static

◆ map_binfile_download_size()

◆ map_binfile_handle_redirect()

static int map_binfile_handle_redirect ( struct map_priv m)
static

◆ map_binfile_http_close()

static int map_binfile_http_close ( struct map_priv m)
static

◆ map_binfile_http_range()

static struct file* map_binfile_http_range ( struct map_priv m,
long long  offset,
int  size 
)
static

◆ map_binfile_http_request()

static int map_binfile_http_request ( struct map_priv m,
struct attr **  attrs 
)
static

◆ map_binfile_open()

◆ map_binfile_zip_setup()

◆ map_destroy_binfile()

static void map_destroy_binfile ( struct map_priv m)
static

◆ map_download_selection()

static void map_download_selection ( struct map_priv m,
struct map_rect_priv mr,
struct map_selection sel 
)
static

◆ map_download_selection_check()

static int map_download_selection_check ( struct zip_cd cd,
struct map_selection sel 
)
static

◆ map_new_binfile()

◆ map_parse_country_binfile()

◆ map_parse_submap()

◆ map_rect_destroy_binfile()

◆ map_rect_get_item_binfile()

◆ map_rect_get_item_byid_binfile()

◆ map_rect_new_binfile()

◆ map_rect_new_binfile_int()

◆ plugin_init()

void plugin_init ( void  )

◆ pop_tile()

◆ push_modified_item()

◆ push_tile()

◆ push_zipfile_tile()

◆ push_zipfile_tile_do()

static void push_zipfile_tile_do ( struct map_rect_priv mr,
struct zip_cd cd,
int  zipfile,
int  offset,
int  length 
)
static

◆ selection_contains()

static int selection_contains ( struct map_selection sel,
struct coord_rect r,
struct range mima 
)
static

◆ setup_pos()

◆ tile_bbox()

◆ write_changes()

static void write_changes ( struct map_priv m)
static

◆ write_changes_do()

static void write_changes_do ( gpointer  key,
gpointer  value,
gpointer  user_data 
)
static

◆ zipfile_to_tile()

Variable Documentation

◆ map_id

int map_id
static

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.

Referenced by map_new_binfile().

◆ map_methods_binfile

struct map_methods map_methods_binfile
static
Initial value:
= {
"utf-8",
NULL,
}
static void map_destroy_binfile(struct map_priv *m)
Definition: binfile.c:412
static struct item * map_rect_get_item_byid_binfile(struct map_rect_priv *mr, int id_hi, int id_lo)
Definition: binfile.c:1726
static void binmap_search_destroy(struct map_search_priv *ms)
Definition: binfile.c:2317
static int binmap_set_attr(struct map_priv *map, struct attr *attr)
Definition: binfile.c:2355
static struct map_rect_priv * map_rect_new_binfile(struct map_priv *map, struct map_selection *sel)
Definition: binfile.c:1472
static struct item * binmap_search_get_item(struct map_search_priv *map_search)
Definition: binfile.c:2156
static struct item * map_rect_get_item_binfile(struct map_rect_priv *mr)
Definition: binfile.c:1676
static void map_rect_destroy_binfile(struct map_rect_priv *mr)
Definition: binfile.c:1548
static int binmap_get_attr(struct map_priv *m, enum attr_type type, struct attr *attr)
Definition: binfile.c:2335
static struct map_search_priv * binmap_search_new(struct map_priv *map, struct item *item, struct attr *search, int partial)
Definition: binfile.c:1918
@ projection_mg
Definition: projection.h:25

Referenced by map_new_binfile().

◆ methods_binfile

struct item_methods methods_binfile
static
Initial value:
= {
NULL,
NULL,
}
static int binfile_attr_set(void *priv_data, struct attr *attr, enum change_mode mode)
Definition: binfile.c:727
static void binfile_coord_rewind(void *priv_data)
Definition: binfile.c:419
static int binfile_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
Definition: binfile.c:524
static int binfile_coord_set(void *priv_data, struct coord *c, int count, enum change_mode mode)
Definition: binfile.c:633
static int binfile_coords_left(void *priv_data)
Get nuber of coords left for current item.
Definition: binfile.c:461
static int binfile_coord_get(void *priv_data, struct coord *c, int count)
Definition: binfile.c:431
static void binfile_attr_rewind(void *priv_data)
Definition: binfile.c:470

Referenced by map_rect_new_binfile_int().