+/**
+ * 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 <math.h>
#include <stdlib.h>
#include "maptool.h"
#include "file.h"
#include "debug.h"
+#if GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 10
+#define g_slice_alloc0 g_malloc0
+#define g_slice_new(x) g_new(x,1)
+#define g_slice_new0(x) g_new0(x,1)
+#define g_slice_free(x,y) g_free(y)
+#define g_slice_free1(x,y) g_free(y)
+#endif
+
struct ch_edge {
int flags;
int weight;
g_slice_free(struct item_id, data);
}
-#define sq(x) ((double)(x)*(x))
-
static void
add_node_to_hash(FILE *idx, GHashTable *hash, struct coord *c, int *nodes)
{
int last_edge_id=nodes[node+1].first_edge;
int edge_id;
struct ch_edge ch_edge;
- memset(&ch_edge, 0, sizeof(ch_edge));
+ struct item_bin *item_bin;
struct edge_hash_item fwd,rev;
- item_bin_init(item_bin, type_ch_node);
- int oldnode=GPOINTER_TO_INT(g_hash_table_lookup(newnode_hash, GINT_TO_POINTER(node)));
+ int oldnode;
+ memset(&ch_edge, 0, sizeof(ch_edge));
+ item_bin=init_item(type_ch_node);
+ oldnode=GPOINTER_TO_INT(g_hash_table_lookup(newnode_hash, GINT_TO_POINTER(node)));
#if 0
dbg(0,"0x%x,0x%x\n",node_index[oldnode].x,node_index[oldnode].y);
#endif
#endif
}
id=g_hash_table_lookup(sgr_nodes_hash, GINT_TO_POINTER((int)edge->target));
- if (id == NULL) {
- fprintf(stderr,"Failed to look up target %d\n",edge->target);
- }
#if 0
dbg(0,"id for %d is "ITEM_ID_FMT"\n",edge->target,ITEM_ID_ARGS(*id));
#endif
- ch_edge.target=*id;
+ if (id == NULL) {
+ fprintf(stderr,"Failed to look up target %d\n",edge->target);
+ } else {
+ ch_edge.target=*id;
+ }
}
item_bin_add_attr_data(item_bin,attr_ch_edge,&ch_edge,sizeof(ch_edge));
}
{
struct tile_info info;
FILE *in,*ref,*ddsg_coords,*ddsg;
+ FILE **graphfiles;
info.write=0;
info.maxlen=0;
info.suffix=suffix;
info.tiles_list=NULL;
info.tilesdir_out=tilesdir_out;
- FILE *graphfiles[ch_levels+1];
+ graphfiles=g_alloca(sizeof(FILE*)*(ch_levels+1));
ch_create_tempfiles(suffix, graphfiles, ch_levels, 1);
in=tempfile(map_suffix,"ways_split",0);
{
struct tile_info info;
struct tile_head *th;
- FILE *graphfiles[ch_levels+1];
+ FILE **graphfiles=g_alloca(sizeof(FILE*)*(ch_levels+1));
+ FILE *ref;
+ struct item_id id;
+ int nodeid=0;
info.write=1;
- info.maxlen=zip_info->maxnamelen;
+ info.maxlen=zip_get_maxnamelen(zip_info);
info.suffix=suffix;
info.tiles_list=NULL;
info.tilesdir_out=NULL;
- FILE *ref=tempfile(suffix,"sgr_ref",1);
- struct item_id id;
- int nodeid=0;
+ ref=tempfile(suffix,"sgr_ref",1);
create_tile_hash();
fprintf(stderr,"Size error '%s': %d vs %d\n", th->name, th->total_size, th->total_size_used);
exit(1);
}
- write_zipmember(zip_info, th->name, zip_info->maxnamelen, th->zip_data, th->total_size);
+ write_zipmember(zip_info, th->name, zip_get_maxnamelen(zip_info), th->zip_data, th->total_size);
} else {
- fwrite(th->zip_data, th->total_size, 1, zip_info->index);
+ fwrite(th->zip_data, th->total_size, 1, zip_get_index(zip_info));
}
g_free(th->zip_data);
th=th->next;