speeding up things..

master
steffen 12 years ago
parent 30cbec28c6
commit eb328d6c47

@ -1,6 +1,10 @@
Version 0.0.2: name changed to spOSMroute, since on there had been another Version 0.0.2: name changed to spOSMroute, since on there had been another
OSMroute already. OSMroute already.
============================================================================= =============================================================================
(2013-07-23):
- added map_way_append_to_hash and map_area_append_to_hash to speedup
map_hash_realloc, which took most almost 30% of all time.
(2013-07-19): (2013-07-19):
- speeding up converting process. - speeding up converting process.

@ -376,6 +376,7 @@ extern struct map_way *map_way_find (struct map_hash *mh, unsigned long long int
extern void map_way_copy (struct map_way *dest, struct map_way *src); extern void map_way_copy (struct map_way *dest, struct map_way *src);
extern int map_way_add (struct map_way *way, int loadflags); extern int map_way_add (struct map_way *way, int loadflags);
extern int map_way_add_to_hash (struct map_hash *mh, struct map_way *mw); extern int map_way_add_to_hash (struct map_hash *mh, struct map_way *mw);
extern int map_way_append_to_hash (struct map_hash *mh, struct map_way *mw);
extern int map_way_getsize (struct map_way *way); extern int map_way_getsize (struct map_way *way);
extern int map_way_findclosest (struct map_pos *pos, struct map_pos *waypos, int idh, char *name, int namelen, unsigned long long int *closest_id, unsigned short int *closest_sid); extern int map_way_findclosest (struct map_pos *pos, struct map_pos *waypos, int idh, char *name, int namelen, unsigned long long int *closest_id, unsigned short int *closest_sid);
extern float map_way_getdistance (struct map_way *mw, struct map_pos *pos, struct map_pos *waypos); extern float map_way_getdistance (struct map_way *mw, struct map_pos *pos, struct map_pos *waypos);
@ -390,6 +391,7 @@ extern struct map_area *map_area_find (struct map_hash *mh, unsigned long long i
extern void map_area_copy (struct map_area *dest, struct map_area *src); extern void map_area_copy (struct map_area *dest, struct map_area *src);
extern int map_area_add (struct map_area *area, int loadflags); extern int map_area_add (struct map_area *area, int loadflags);
extern int map_area_add_to_hash (struct map_hash *mh, struct map_area *ma); extern int map_area_add_to_hash (struct map_hash *mh, struct map_area *ma);
extern int map_area_append_to_hash (struct map_hash *mh, struct map_area *ma);
extern int map_area_getsize (struct map_area *area); extern int map_area_getsize (struct map_area *area);

@ -32,6 +32,27 @@
* *
*/ */
/*
* add the area without checking for it's size, also no update is done
*/
int map_area_append_to_hash (struct map_hash *mh, struct map_area *ma) {
int size;
struct map_area *a = mh->areas;
mh->areas = (struct map_area*) map_hash_getfree_aligned (mh, POINTERALIGNMENT);
/* copy the area data to the free entry
* calc size and set free entry to it's new place */
size = map_area_getsize (ma);
map_area_copy (mh->areas, ma);
mh->areas->next = a;
mh->free = mh->free + size;
mh->areascnt++;
SETFLAG(mh->status, MS_changed);
return 1;
};
/* /*
* add the area without checking for it's size, but do an update * add the area without checking for it's size, but do an update
*/ */

@ -208,7 +208,7 @@ void map_hash_copy (struct map_hash *hd, struct map_hash *hs) {
i = 0; i = 0;
mw = hs->ways; mw = hs->ways;
while (mw && i < hs->wayscnt) { while (mw && i < hs->wayscnt) {
map_way_add_to_hash (hd, mw); map_way_append_to_hash (hd, mw);
mw = mw->next; mw = mw->next;
i++; i++;
} }
@ -220,7 +220,7 @@ void map_hash_copy (struct map_hash *hd, struct map_hash *hs) {
ma = hs->areas; ma = hs->areas;
i = 0; i = 0;
while (ma && i < hs->areascnt) { while (ma && i < hs->areascnt) {
map_area_add_to_hash (hd, ma); map_area_append_to_hash (hd, ma);
ma = ma->next; ma = ma->next;
i++; i++;
} }

@ -88,6 +88,36 @@ int map_way_add_to_hash (struct map_hash *mh, struct map_way *mw) {
}; };
/*
* append the way without checking for it's size or double entry, no update done
*/
int map_way_append_to_hash (struct map_hash *mh, struct map_way *mw) {
int size;
struct map_way *w = mh->ways;
/* check if the hash pos and the waypos are valid */
if (mw->p_cnt > 0) if (map_geo2igeo (mw->p[0].lon) != mh->pos.ilon ||
map_geo2igeo (mw->p[0].lat) != mh->pos.ilat) {
d_printf ("p[0]:%d,%d mhpos:%d,%d way does not bleong to hash.", __FUNCTION__, map_geo2igeo (mw->p[0].lon), map_geo2igeo (mw->p[0].lat), mh->pos.ilon, mh->pos.ilat);
errorexit (-1);
}
/* check if the first element is already the one we want to update */
mh->ways = (struct map_way*) map_hash_getfree_aligned (mh, POINTERALIGNMENT);
/* copy the way data to the free entry
* calc size and set free entry to it's new place */
size = map_way_getsize (mw);
map_way_copy (mh->ways, mw);
mh->ways->next = w;
mh->free = mh->free + size;
mh->wayscnt++;
SETFLAG(mh->status, MS_changed);
return 1;
};
/****************************************************************************** /******************************************************************************
* Add/Update way information * Add/Update way information
* - load/ get hash table * - load/ get hash table

Loading…
Cancel
Save