#include "debug.h"
#include "plugin.h"
#include "projection.h"
+#include "item.h"
#include "map.h"
#include "maptype.h"
-#include "item.h"
#include "attr.h"
#include "coord.h"
#include "transform.h"
return 1;
while (sel) {
if (coord_rect_overlap(r, &sel->u.c_rect)) {
- order=sel->order[0];
- if (sel->order[1] > order)
- order=sel->order[1];
- if (sel->order[2] > order)
- order=sel->order[2];
+ order=sel->order;
dbg(1,"min %d max %d order %d\n", mima->min, mima->max, order);
if (!mima->min && !mima->max)
return 1;
struct map_search_priv *msp;
struct map_selection *ms;
struct item *town;
- int i;
/*
* NOTE: If you implement search for other attributes than attr_town_name and attr_street_name,
break;
ms = g_new(struct map_selection, 1);
ms->next = NULL;
- for (i = 0; i < layer_end; i++)
- {
- ms->order[i] = 18;
- }
+ ms->range = item_range_all; /* FIXME */
+ ms->order = 18;
map_rec = map_rect_new_binfile(map, ms);
town = map_rect_get_item_byid_binfile(map_rec, item->id_hi, item->id_lo);
if (town) {
static int
get_level(struct map_selection *sel)
{
- int l;
- l = max(sel->order[layer_town], sel->order[layer_street]);
- l = max(l, sel->order[layer_poly]);
- return l;
+ return sel->order;
}
static int
/* levels we do not deal w/ them
*/
int flags = 0;
- if (sel && sel->order[layer_town] == 0 && sel->order[layer_poly] == 0
- && sel->order[layer_street]) {
+ if (sel && sel->range.min == type_street_0 && sel->range.max == type_ferry) {
// Get all roads
flags = GO_GET_ROUTABLE;
} else if (sel)
return NULL;
}
+struct item_range town_ranges[]={
+ {type_town_label,type_port_label},
+};
+
+struct item_range street_ranges[]={
+ {type_street_nopass,type_street_unkn},
+};
+
+struct item_range poly_ranges[]={
+ {type_border_country,type_water_line},
+ {type_street_unkn,type_street_unkn},
+ {type_area,type_last},
+};
+
+
static int
file_next(struct map_rect_priv *mr)
{
case file_strname_stn:
continue;
case file_town_twn:
- layer=layer_town;
+ if (mr->cur_sel && !map_selection_contains_item_range(mr->cur_sel, 0, town_ranges, sizeof(town_ranges)/sizeof(struct item_range)))
+ continue;
break;
case file_street_str:
- layer=layer_street;
+ if (mr->cur_sel && !map_selection_contains_item_range(mr->cur_sel, 0, street_ranges, sizeof(street_ranges)/sizeof(struct item_range)))
+ continue;
break;
default:
- layer=layer_poly;
+ if (mr->cur_sel && !map_selection_contains_item_range(mr->cur_sel, 0, poly_ranges, sizeof(poly_ranges)/sizeof(struct item_range)))
+ continue;
+ break;
}
- if (mr->cur_sel && !mr->cur_sel->order[layer])
- continue;
if (debug)
printf("current file: '%s'\n", file[mr->current_file]);
mr->cur_sel=mr->xsel;
poly->poly_num++;
r.lu=poly->c[0];
r.rl=poly->c[1];
- if (mr->cur_sel && (poly->order > mr->cur_sel->order[layer_poly]*3 || !coord_rect_overlap(&mr->cur_sel->u.c_rect, &r))) {
+ if (mr->cur_sel && (poly->order > mr->cur_sel->order*3 || !coord_rect_overlap(&mr->cur_sel->u.c_rect, &r))) {
poly->subpoly_num_all+=poly->polys;
mr->b.p=poly->poly_next;
continue;
dbg(0,"Unknown poly type 0x%x '%s' 0x%x,0x%x\n", poly->type,poly->name,r.lu.x,r.lu.y);
item->type=type_street_unkn;
}
+ if (!map_selection_contains_item(mr->cur_sel, 0, item->type)) {
+ poly->subpoly_num_all+=poly->polys;
+ mr->b.p=poly->poly_next;
+ continue;
+ }
} else
mr->b.p=poly->subpoly_next;
dbg(1,"%d %d %s\n", poly->subpoly_num_all, mr->b.block_num, poly->name);
if (mr->b.p == mr->b.p_start) {
street_get_data(street, &mr->b.p);
street->name_file=mr->m->file[file_strname_stn];
- if (mr->cur_sel && street->header->order > limit[mr->cur_sel->order[layer_street]])
+ if (mr->cur_sel && street->header->order > limit[mr->cur_sel->order])
return 0;
street->end=mr->b.end;
street->ref=&mr->b.b->r.lu;
item->type=type_street_unkn;
dbg(0,"unknown type 0x%x\n",street->str->type);
}
+ if (!map_selection_contains_item(mr->cur_sel, 0, item->type)) {
+ return 0;
+ }
#if 0
coord_debug=(street->str->unknown2 != 0x40 || street->str->unknown3 != 0x40);
if (coord_debug) {
twn->cidx=0;
twn->aidx=0;
twn->attr_next=attr_label;
- if (! mr->cur_sel || (twn->order <= limit[mr->cur_sel->order[layer_town]] && coord_rect_contains(&mr->cur_sel->u.c_rect,&twn->c))) {
+ if (! mr->cur_sel || (twn->order <= limit[mr->cur_sel->order] && coord_rect_contains(&mr->cur_sel->u.c_rect,&twn->c))) {
switch(twn->type) {
case 1:
size=twn->size;
printf("unknown town type 0x%x '%s' '%s' 0x%x,0x%x\n", twn->type, twn->name, twn->district, twn->c.x, twn->c.y);
item->type=type_town_label;
}
- item->id_hi=twn->country | (mr->current_file << 16);
- item->id_lo=twn->id;
- item->priv_data=twn;
- item->meth=&town_meth;
- return 1;
+ if (map_selection_contains_item(mr->cur_sel, 0, item->type)) {
+ item->id_hi=twn->country | (mr->current_file << 16);
+ item->id_lo=twn->id;
+ item->priv_data=twn;
+ item->meth=&town_meth;
+ return 1;
+ }
}
}
}
#include "debug.h"
#include "coord.h"
#include "projection.h"
-#include "map.h"
#include "item.h"
+#include "map.h"
#include "plugin.h"
#include "debug.h"
#include "plugin.h"
#include "projection.h"
+#include "item.h"
#include "map.h"
#include "maptype.h"
-#include "item.h"
#include "attr.h"
#include "transform.h"
#include "file.h"
g_free(oargs);
for (lay=layer_town ; lay < layer_end ; lay++) {
oargs=args;
- args=g_strdup_printf("%s%s%d", oargs, sep, sel->order[lay]);
+ args=g_strdup_printf("%s%s%d", oargs, sep, sel->order);
g_free(oargs);
sep=",";
}
#include "point.h"
#include "graphics.h"
#include "projection.h"
+#include "item.h"
#include "map.h"
#include "coord.h"
#include "transform.h"
gui_internal_cmd_view_on_map, wm));
}
if (display_items) {
- int i,dist=10;
+ int dist=10;
struct mapset *ms;
struct mapset_handle *h;
struct map_rect *mr;
sel.u.c_rect.lu.y=c.y+dist;
sel.u.c_rect.rl.x=c.x+dist;
sel.u.c_rect.rl.y=c.y-dist;
- for (i = 0 ; i < layer_end ; i++) {
- sel.order[i]=18;
- }
+ sel.order=18;
+ sel.range=item_range_all;
h=mapset_open(ms);
while ((m=mapset_next(h,1))) {
mr=map_rect_new(m, &sel);
char *name;
};
+struct item_range item_range_all = { type_none, type_last };
+
struct item_name item_names[]={
#define ITEM2(x,y) ITEM(y)
g_hash_table_destroy(h->h);
g_free(h);
}
+
+int
+item_range_intersects_range(struct item_range *range1, struct item_range *range2)
+{
+ if (range1->max < range2->min)
+ return 0;
+ if (range1->min > range2->max)
+ return 0;
+ return 1;
+}
+int
+item_range_contains_item(struct item_range *range, enum item_type type)
+{
+ if (type >= range->min && type <= range->max)
+ return 1;
+ return 0;
+}
void *priv_data;
};
+struct item_range {
+ enum item_type min,max;
+} item_range_all;
+
/* prototypes */
enum attr_type;
enum item_type;
ITEM(poly_street_2)
ITEM(poly_street_3)
ITEM(poly_wetland)
+ITEM2(0xffffffff,last)
#include "debug.h"
#include "coord.h"
#include "projection.h"
+#include "item.h"
#include "map.h"
#include "maptype.h"
#include "transform.h"
-#include "item.h"
#include "plugin.h"
#include "callback.h"
#include "country.h"
{
int i;
struct map_selection *ret=g_new0(struct map_selection, 1);
- for (i = 0 ; i < layer_end ; i++) {
- ret->order[i]=order;
- }
+ ret->order=order;
+ ret->range=item_range_all;
ret->u.c_rect.lu.x=center->x-distance;
ret->u.c_rect.lu.y=center->y+distance;
ret->u.c_rect.rl.x=center->x+distance;
}
+
+/**
+ * @brief Checks if a selection contains a item range
+ *
+ * This function checks if a selection contains at least one of the items in range
+ *
+ * @param sel The selection to be checked
+ * @param follow Whether the next pointer of the selection should be followed
+ * @param ranges The item ranges to be checked
+ * @count the number of elements in ranges
+ * @return True if there is a match, false otherwise
+ */
+
+int
+map_selection_contains_item_range(struct map_selection *sel, int follow, struct item_range *range, int count)
+{
+ int i;
+ if (! sel)
+ return 1;
+ while (sel) {
+ for (i = 0 ; i < count ; i++) {
+ if (item_range_intersects_range(&sel->range, &range[i]))
+ return 1;
+ }
+ if (! follow)
+ break;
+ sel=sel->next;
+ }
+ return 0;
+}
+/**
+ * @brief Checks if a selection contains a item
+ *
+ * This function checks if a selection contains a item type
+ *
+ * @param sel The selection to be checked
+ * @param follow Whether the next pointer of the selection should be followed
+ * @param item The item type to be checked
+ * @return True if there is a match, false otherwise
+ */
+
+int
+map_selection_contains_item(struct map_selection *sel, int follow, enum item_type type)
+{
+ if (! sel)
+ return 1;
+ while (sel) {
+ if (item_range_contains_item(&sel->range, type))
+ return 1;
+ if (! follow)
+ break;
+ sel=sel->next;
+ }
+ return 0;
+}
+
+
+
/**
* @brief Checks if a pointer points to the private data of a map
*
struct coord_rect c_rect; /**< For building the rectangle based on coordinates */
struct point_rect p_rect; /**< For building the rectangle based on points */
} u;
- int order[layer_end]; /**< Holds the order to be selected for each layer of items */
+ int order; /**< Holds the order */
+ struct item_range range; /**< Range of items which should be delivered */
};
/**
#include <glib.h>
#include "debug.h"
#include "projection.h"
+#include "item.h"
#include "map.h"
#include "maptype.h"
sel.order[layer_street]=18;
sel.order[layer_poly]=18;
#else
- sel.order[layer_town]=0;
- sel.order[layer_street]=0;
- sel.order[layer_poly]=0;
+ sel.order=0;
+ sel.range=item_range_all;
#endif
center=transform_center(this_->trans);
sel.u.c_rect.lu.x=center->x-dist;
#include "point.h"
#include "transform.h"
#include "projection.h"
+#include "item.h"
#include "map.h"
#include "graphics.h"
-#include "item.h"
#include "callback.h"
#include "route.h"
#include "navit_nls.h"
#include "profile.h"
#include "coord.h"
#include "projection.h"
+#include "item.h"
#include "map.h"
#include "mapset.h"
-#include "item.h"
#include "route.h"
#include "track.h"
#include "point.h"
printf("%s:Out of memory\n", __FUNCTION__);
return sel;
}
- sel->order[layer_town]=0;
- sel->order[layer_poly]=0;
- sel->order[layer_street]=order;
+ sel->order=order;
+ sel->range.min=route_item_first;
+ sel->range.max=route_item_last;
dbg(1,"%p %p\n", c1, c2);
dx=c1->x-c2->x;
dy=c1->y-c2->y;
#include <string.h>
#include "debug.h"
#include "projection.h"
+#include "item.h"
#include "map.h"
#include "mapset.h"
#include "coord.h"
-#include "item.h"
#include "search.h"
struct search_list_level {
#include "config.h"
#include "coord.h"
#include "debug.h"
+#include "item.h"
#include "map.h"
#include "transform.h"
#include "projection.h"
#include "point.h"
-#include "item.h"
struct transformation {
int angle; /* Rotation angle */
struct map_selection *ret,*curri,*curro;
struct coord_geo g;
- int i;
ret=map_selection_dup(this_->map_sel);
curri=this_->map_sel;
dbg(1,": - %f,%f\n", g.lat, g.lng);
}
dbg(1,"transform rect for %d is %d,%d - %d,%d\n", pro, curro->u.c_rect.lu.x, curro->u.c_rect.lu.y, curro->u.c_rect.rl.x, curro->u.c_rect.rl.y);
- for (i = 0 ; i < layer_end ; i++)
- curro->order[i]+=order;
+ curro->order+=order;
+ curro->range=item_range_all;
curri=curri->next;
curro=curro->next;
}