You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(4) |
Aug
(59) |
Sep
(43) |
Oct
(95) |
Nov
(135) |
Dec
(108) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(229) |
Feb
(141) |
Mar
(59) |
Apr
(70) |
May
(64) |
Jun
(87) |
Jul
(57) |
Aug
(108) |
Sep
(74) |
Oct
(203) |
Nov
(141) |
Dec
(108) |
| 2009 |
Jan
(114) |
Feb
(91) |
Mar
(101) |
Apr
(69) |
May
(54) |
Jun
(82) |
Jul
(49) |
Aug
(109) |
Sep
(81) |
Oct
(93) |
Nov
(100) |
Dec
(79) |
| 2010 |
Jan
(46) |
Feb
(36) |
Mar
(135) |
Apr
(103) |
May
(116) |
Jun
(130) |
Jul
(52) |
Aug
(31) |
Sep
(46) |
Oct
(48) |
Nov
(98) |
Dec
(110) |
| 2011 |
Jan
(234) |
Feb
(184) |
Mar
(150) |
Apr
(43) |
May
(53) |
Jun
(52) |
Jul
(112) |
Aug
(72) |
Sep
(79) |
Oct
(23) |
Nov
(6) |
Dec
(30) |
| 2012 |
Jan
(39) |
Feb
(37) |
Mar
(49) |
Apr
(60) |
May
(63) |
Jun
(38) |
Jul
(33) |
Aug
(24) |
Sep
(20) |
Oct
(14) |
Nov
(23) |
Dec
(50) |
| 2013 |
Jan
(30) |
Feb
(32) |
Mar
(27) |
Apr
(41) |
May
(59) |
Jun
(21) |
Jul
(10) |
Aug
(73) |
Sep
(23) |
Oct
(60) |
Nov
(14) |
Dec
(15) |
| 2014 |
Jan
(4) |
Feb
(8) |
Mar
(11) |
Apr
(6) |
May
(27) |
Jun
(4) |
Jul
(29) |
Aug
(62) |
Sep
(11) |
Oct
(17) |
Nov
(58) |
Dec
(9) |
| 2015 |
Jan
(23) |
Feb
(3) |
Mar
(26) |
Apr
(47) |
May
(8) |
Jun
(28) |
Jul
(10) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <sl...@us...> - 2013-03-10 20:13:55
|
Revision: 5405
http://navit.svn.sourceforge.net/navit/?rev=5405&view=rev
Author: sleske
Date: 2013-03-10 20:13:49 +0000 (Sun, 10 Mar 2013)
Log Message:
-----------
Fix:internal:Refactoring: Remove parameter step from graphics_draw_polyline_* , it's always =1
Modified Paths:
--------------
trunk/navit/navit/graphics.c
Modified: trunk/navit/navit/graphics.c
===================================================================
--- trunk/navit/navit/graphics.c 2013-03-10 07:57:20 UTC (rev 5404)
+++ trunk/navit/navit/graphics.c 2013-03-10 20:13:49 UTC (rev 5405)
@@ -1407,7 +1407,7 @@
}
static void
-graphics_draw_polyline_as_polygon(struct graphics *gra, struct graphics_gc *gc, struct point *pnt, int count, int *width, int step)
+graphics_draw_polyline_as_polygon(struct graphics *gra, struct graphics_gc *gc, struct point *pnt, int count, int *width)
{
int maxpoints=200;
struct point *res=g_alloca(sizeof(struct point)*maxpoints);
@@ -1422,7 +1422,7 @@
i=0;
for (;;) {
wi=*width;
- width+=step;
+ width++;
if (i < count - 1) {
int dxs,dys,lscales;
@@ -1508,11 +1508,8 @@
i++;
if (i >= count)
break;
- if (step) {
- wi=*width;
- calc_offsets(wi*lscale, l, dx, dy, &oo);
- } else
- oo=o;
+ wi=*width;
+ calc_offsets(wi*lscale, l, dx, dy, &oo);
dxo = -dx;
dyo = -dy;
fowo=fow;
@@ -1608,10 +1605,10 @@
}
static void
-graphics_draw_polyline_clipped(struct graphics *gra, struct graphics_gc *gc, struct point *pa, int count, int *width, int step, int poly)
+graphics_draw_polyline_clipped(struct graphics *gra, struct graphics_gc *gc, struct point *pa, int count, int *width, int poly)
{
struct point *points_to_draw=g_alloca(sizeof(struct point)*(count+1));
- int *w=g_alloca(sizeof(int)*(count*step+1));
+ int *w=g_alloca(sizeof(int)*(count+1));
struct wpoint segment_start,segment_end;
int i,points_to_draw_cnt=0;
int clip_result;
@@ -1619,11 +1616,9 @@
struct point_rect r=gra->r;
wmax=width[0];
- if (step) {
- for (i = 1 ; i < count ; i++) {
- if (width[i*step] > wmax)
- wmax=width[i*step];
- }
+ for (i = 1 ; i < count ; i++) {
+ if (width[i] > wmax)
+ wmax=width[i];
}
if (wmax <= 0)
return;
@@ -1637,28 +1632,28 @@
if (i) {
segment_start.x=pa[i-1].x;
segment_start.y=pa[i-1].y;
- segment_start.w=width[(i-1)*step];
+ segment_start.w=width[(i-1)];
segment_end.x=pa[i].x;
segment_end.y=pa[i].y;
- segment_end.w=width[i*step];
+ segment_end.w=width[i];
clip_result=clip_line(&segment_start, &segment_end, &r);
if (clip_result != CLIPRES_INVISIBLE) {
if ((i == 1) || (clip_result & CLIPRES_START_CLIPPED)) {
points_to_draw[points_to_draw_cnt].x=segment_start.x;
points_to_draw[points_to_draw_cnt].y=segment_start.y;
- w[points_to_draw_cnt*step]=segment_start.w;
+ w[points_to_draw_cnt]=segment_start.w;
points_to_draw_cnt++;
}
points_to_draw[points_to_draw_cnt].x=segment_end.x;
points_to_draw[points_to_draw_cnt].y=segment_end.y;
- w[points_to_draw_cnt*step]=segment_end.w;
+ w[points_to_draw_cnt]=segment_end.w;
points_to_draw_cnt++;
}
if ((i == count-1) || (clip_result & CLIPRES_END_CLIPPED)) {
// ... then draw the resulting polyline
if (points_to_draw_cnt > 1) {
if (poly) {
- graphics_draw_polyline_as_polygon(gra, gc, points_to_draw, points_to_draw_cnt, w, step);
+ graphics_draw_polyline_as_polygon(gra, gc, points_to_draw, points_to_draw_cnt, w);
} else
gra->meth.draw_lines(gra->priv, gc->priv, points_to_draw, points_to_draw_cnt);
points_to_draw_cnt=0;
@@ -1909,7 +1904,7 @@
if (width[i] < 2)
width[i]=2;
}
- graphics_draw_polyline_clipped(gra, gc, pa, count, width, 1, e->u.polyline.width > 1);
+ graphics_draw_polyline_clipped(gra, gc, pa, count, width, e->u.polyline.width > 1);
}
break;
case element_circle:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mar...@us...> - 2013-03-10 07:57:27
|
Revision: 5404
http://navit.svn.sourceforge.net/navit/?rev=5404&view=rev
Author: martin-s
Date: 2013-03-10 07:57:20 +0000 (Sun, 10 Mar 2013)
Log Message:
-----------
Add:xml:Demonstration on how to use the new img command
Modified Paths:
--------------
trunk/navit/navit/navit_shipped.xml
Modified: trunk/navit/navit/navit_shipped.xml
===================================================================
--- trunk/navit/navit/navit_shipped.xml 2013-03-10 07:53:37 UTC (rev 5403)
+++ trunk/navit/navit/navit_shipped.xml 2013-03-10 07:57:20 UTC (rev 5404)
@@ -102,48 +102,26 @@
<a name='Settings Layouts' class='clist' refresh_cond='navit.layout'><text>Layout</text>
<script>
foreach(layout;navit.layout)
- write("<img class='centry'",
- " src='", navit.layout==layout?"gui_active":"gui_inactive", "'",
- " onclick='set(", E("navit.layout=navit.layout[@name==*]"), ",E(",E(layout.name), "))'",
- ">",
- layout.name,
- "</img>"
- );
+ img("centry", navit.layout==layout?"gui_active":"gui_inactive", layout.name,
+ "", "navit.layout=navit.layout[@name==%{se}*]", layout.name);
</script>
</a>
<a name='Settings Maps' class='clist'><text>Maps</text>
<script>
foreach(map;navit.mapset.map)
if (map.description)
- write("<img class='centry'",
- " src='", map.active?"gui_active":"gui_inactive", "'",
- " onclick='set(", E("navit.mapset.map[@description=="+E(map.description)+"].active=*"), ",", !map.active, ");redraw_map();refresh()'",
- ">",
- map.description,
- "</img>"
- );
+ img("centry",map.active?"gui_active":"gui_inactive", map.description,
+ "","navit.mapset.map[@description==%{se}].active=%{d}*",map.description,!map.active,"redraw_map();refresh();");
else
- write("<img class='centry'",
- " src='", map.active?"gui_active":"gui_inactive", "'",
- " onclick='set(", E("navit.mapset.map[@data=="+E(map.data)+"].active=*"), ",", !map.active, ");redraw_map();refresh()'",
- ">",
- map.type,":",map.data,
- "</img>"
- );
-
-
+ img("centry",map.active?"gui_active":"gui_inactive", map.type+":"+map.data,
+ "","navit.mapset.map[@data==%{se}].active=%{d}*",map.data,!map.active,"redraw_map();refresh();");
</script>
</a>
<a name='Settings Vehicles' class='clist'><text>Vehicle</text>
<script>
foreach(vehicle;navit.vehicle)
- write("<img class='centry'",
- " src='", navit.vehicle==vehicle?"gui_active":"gui_inactive", "'",
- " onclick='name=", E(vehicle.name), ";menu(", E("#Settings Vehicle"), ")'",
- ">",
- vehicle.name,
- "</img>"
- );
+ img("centry",navit.vehicle==vehicle?"gui_active":"gui_inactive",vehicle.name,
+ "name=%{se};menu(\"#Settings Vehicle\")",vehicle.name);
</script>
</a>
<a name='Settings Vehicle' class='clist'><script>write(name)</script>
@@ -151,21 +129,11 @@
foreach(vehicle;navit.vehicle)
if (vehicle.name == name) {
if (vehicle!=navit.vehicle)
- write("<img class='centry'",
- " src='gui_active' ",
- " onclick='set(", E("navit.vehicle=navit.vehicle[@name==*]"), ",E(", E(name), "));refresh()'",
- ">",
- "Set as active",
- "</img>"
- );
+ img("centry","gui_active","Set as active",
+ "","navit.vehicle=navit.vehicle[@name==%{se}*]",name);
foreach(vehicleprofile;navit.vehicleprofile)
- write("<img class='centry'",
- " src='", vehicle.profilename==vehicleprofile.name?"gui_active":"gui_inactive", "'",
- " onclick='set(", E("navit.vehicle[@name=="+E(name)+"].profilename=*"), ",E(", E(vehicleprofile.name), "));refresh()'",
- ">",
- vehicleprofile.name,
- "</img>"
- );
+ img("centry",vehicle.profilename==vehicleprofile.name?"gui_active":"gui_inactive",vehicleprofile.name,
+ "","navit.vehicle[@name=%{se}].profilename=%{se}*",name,vehicleprofile.name,"refresh()");
}
</script>
</a>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mar...@us...> - 2013-03-10 07:53:44
|
Revision: 5403
http://navit.svn.sourceforge.net/navit/?rev=5403&view=rev
Author: martin-s
Date: 2013-03-10 07:53:37 +0000 (Sun, 10 Mar 2013)
Log Message:
-----------
Add:gui_internal:Support for decimal format string
Modified Paths:
--------------
trunk/navit/navit/gui/internal/gui_internal_command.c
Modified: trunk/navit/navit/gui/internal/gui_internal_command.c
===================================================================
--- trunk/navit/navit/gui/internal/gui_internal_command.c 2013-03-10 07:14:30 UTC (rev 5402)
+++ trunk/navit/navit/gui/internal/gui_internal_command.c 2013-03-10 07:53:37 UTC (rev 5403)
@@ -82,19 +82,25 @@
escape_mode_quote=2,
escape_mode_html=4,
escape_mode_html_quote=8,
+ escape_mode_html_apos=16,
};
+/* todo &=&, < = < */
+
static char *
gui_internal_escape(enum escape_mode mode, char *in)
{
int len=mode & escape_mode_string ? 3:1;
char *dst,*out,*src=in;
char *quot=""";
+ char *apos="'";
while (*src) {
if ((*src == '"' || *src == '\\') && (mode & (escape_mode_string | escape_mode_quote)))
len++;
if (*src == '"' && mode == escape_mode_html_quote)
len+=strlen(quot);
+ else if (*src == '\'' && mode == escape_mode_html_apos)
+ len+=strlen(apos);
else
len++;
src++;
@@ -110,6 +116,10 @@
strcpy(dst,quot);
src++;
dst+=strlen(quot);
+ } else if (*src == '\'' && mode == escape_mode_html_apos) {
+ strcpy(dst,apos);
+ src++;
+ dst+=strlen(apos);
} else
*dst++=*src++;
}
@@ -978,6 +988,15 @@
format[end-c-2]='\0';
is_arg=end[1] == '*';
c[0]='\0';
+ if (!strcmp(format,"d")) {
+ replacement=gui_internal_append_attr(NULL, escape_mode_string, "", *i++, "");
+ if (is_arg) {
+ args=g_strconcat_printf(args, "%s%s", args ? "," : "", replacement);
+ g_free(replacement);
+ replacement=g_strdup("");
+ }
+
+ }
if (!strcmp(format,"se")) {
replacement=gui_internal_append_attr(NULL, escape_mode_string, "", *i++, "");
if (is_arg) {
@@ -1060,8 +1079,8 @@
gui_internal_onclick(&in,&onclick,"set");
gui_internal_onclick(&in,&onclick,NULL);
if (strlen(onclick)) {
- char *tmp=gui_internal_escape(escape_mode_html_quote, onclick);
- str=g_strconcat_printf(str," onclick=\"%s\"",tmp);
+ char *tmp=gui_internal_escape(escape_mode_html_apos, onclick);
+ str=g_strconcat_printf(str," onclick='%s'",tmp);
g_free(tmp);
}
g_free(onclick);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mar...@us...> - 2013-03-10 07:14:37
|
Revision: 5402
http://navit.svn.sourceforge.net/navit/?rev=5402&view=rev
Author: martin-s
Date: 2013-03-10 07:14:30 +0000 (Sun, 10 Mar 2013)
Log Message:
-----------
Add:gui_internal:New command img for easier creation of buttons from script
Modified Paths:
--------------
trunk/navit/navit/gui/internal/gui_internal_command.c
Modified: trunk/navit/navit/gui/internal/gui_internal_command.c
===================================================================
--- trunk/navit/navit/gui/internal/gui_internal_command.c 2013-03-09 20:31:16 UTC (rev 5401)
+++ trunk/navit/navit/gui/internal/gui_internal_command.c 2013-03-10 07:14:30 UTC (rev 5402)
@@ -76,12 +76,53 @@
}
+enum escape_mode {
+ escape_mode_none=0,
+ escape_mode_string=1,
+ escape_mode_quote=2,
+ escape_mode_html=4,
+ escape_mode_html_quote=8,
+};
+
+static char *
+gui_internal_escape(enum escape_mode mode, char *in)
+{
+ int len=mode & escape_mode_string ? 3:1;
+ char *dst,*out,*src=in;
+ char *quot=""";
+ while (*src) {
+ if ((*src == '"' || *src == '\\') && (mode & (escape_mode_string | escape_mode_quote)))
+ len++;
+ if (*src == '"' && mode == escape_mode_html_quote)
+ len+=strlen(quot);
+ else
+ len++;
+ src++;
+ }
+ src=in;
+ out=dst=g_malloc(len);
+ if (mode & escape_mode_string)
+ *dst++='"';
+ while (*src) {
+ if ((*src == '"' || *src == '\\') && (mode & (escape_mode_string | escape_mode_quote)))
+ *dst++='\\';
+ if (*src == '"' && mode == escape_mode_html_quote) {
+ strcpy(dst,quot);
+ src++;
+ dst+=strlen(quot);
+ } else
+ *dst++=*src++;
+ }
+ if (mode & escape_mode_string)
+ *dst++='"';
+ *dst++='\0';
+ return out;
+}
+
static void
gui_internal_cmd_escape(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
{
struct attr escaped;
- int len;
- char *src,*dst;
if (!in || !in[0] || !ATTR_IS_STRING(in[0]->type)) {
dbg(0,"first parameter missing or wrong type\n");
return;
@@ -90,26 +131,8 @@
dbg(0,"output missing\n");
return;
}
- src=in[0]->u.str;
- len=3;
- while (*src) {
- if (*src == '"' || *src == '\\')
- len++;
- len++;
- src++;
- }
escaped.type=in[0]->type;
- src=in[0]->u.str;
- dst=g_malloc(len);
- escaped.u.str=dst;
- *dst++='"';
- while (*src) {
- if (*src == '"' || *src == '\\')
- *dst++='\\';
- *dst++=*src++;
- }
- *dst++='"';
- *dst++='\0';
+ escaped.u.str=gui_internal_escape(escape_mode_string,in[0]->u.str);
dbg(1,"in %s result %s\n",in[0]->u.str,escaped.u.str);
*out=attr_generic_add_attr(*out, attr_dup(&escaped));
g_free(escaped.u.str);
@@ -888,6 +911,25 @@
event_main_loop_quit();
}
+static char *
+gui_internal_append_attr(char *str, enum escape_mode mode, char *pre, struct attr *attr, char *post)
+{
+ char *astr=NULL;
+ if (ATTR_IS_STRING(attr->type))
+ astr=gui_internal_escape(mode, attr->u.str);
+ else if (ATTR_IS_COORD_GEO(attr->type)) {
+ char *str2=coordinates_geo(attr->u.coord_geo, '\n');
+ astr=gui_internal_escape(mode, str2);
+ g_free(str2);
+ } else if (ATTR_IS_INT(attr->type))
+ astr=g_strdup_printf("%d",attr->u.num);
+ else
+ astr=g_strdup_printf("Unsupported type %s",attr_to_name(attr->type));
+ str=g_strconcat_printf(str,"%s%s%s",pre,astr,post);
+ g_free(astr);
+ return str;
+}
+
static void
gui_internal_cmd_write(struct gui_priv * this, char *function, struct attr **in, struct attr ***out, int *valid)
{
@@ -896,18 +938,7 @@
if (!in)
return;
while (*in) {
- dbg(1,"%s\n",attr_to_name((*in)->type));
- if (ATTR_IS_STRING((*in)->type)) {
- str=g_strconcat_printf(str,"%s",(*in)->u.str);
- }
- if (ATTR_IS_COORD_GEO((*in)->type)) {
- char *str2=coordinates_geo((*in)->u.coord_geo, '\n');
- str=g_strconcat_printf(str,"%s",str2);
- g_free(str2);
- }
- if (ATTR_IS_INT((*in)->type)) {
- str=g_strconcat_printf(str,"%d",(*in)->u.num);
- }
+ str=gui_internal_append_attr(str, escape_mode_none, "", *in, "");
in++;
}
if (str) {
@@ -921,6 +952,130 @@
}
static void
+gui_internal_onclick(struct attr ***in, char **onclick, char *set)
+{
+ struct attr **i=*in;
+ char *c,*str=NULL,*args=NULL,*sep="";
+
+ if (!*i || !ATTR_IS_STRING((*i)->type) || !(*i)->u.str)
+ goto error;
+ str=g_strdup((*i)->u.str);
+ i++;
+ c=str;
+ while (*c) {
+ if (c[0] == '%' && c[1] == '{') {
+ char format[4],*end=strchr(c+2,'}'),*replacement=NULL,*new_str;
+ int is_arg;
+ if (!end) {
+ dbg(0,"Missing closing brace in format string %s\n",c);
+ goto error;
+ }
+ if (end-c > sizeof(format)) {
+ dbg(0,"Invalid format string %s\n",c);
+ goto error;
+ }
+ strncpy(format, c+2, end-c-2);
+ format[end-c-2]='\0';
+ is_arg=end[1] == '*';
+ c[0]='\0';
+ if (!strcmp(format,"se")) {
+ replacement=gui_internal_append_attr(NULL, escape_mode_string, "", *i++, "");
+ if (is_arg) {
+ char *arg=gui_internal_escape(escape_mode_string, replacement);
+ args=g_strconcat_printf(args, "%s%s", args ? "," : "", arg);
+ g_free(replacement);
+ g_free(arg);
+ replacement=g_strdup("");
+ }
+ }
+ if (!replacement) {
+ dbg(0,"Unsupported format string %s\n",format);
+ goto error;
+ }
+ new_str=g_strconcat(str, replacement, end+1, NULL);
+ c=new_str+strlen(str)+strlen(replacement);
+ g_free(str);
+ g_free(replacement);
+ str=new_str;
+ }
+ c++;
+ }
+ *in=i;
+ if (*onclick && strlen(*onclick))
+ sep=";";
+ if (str && strlen(str)) {
+ char *old=*onclick;
+ if (set) {
+ char *setstr=gui_internal_escape(escape_mode_string,str);
+ char *argssep="";
+ if (args && strlen(args))
+ argssep=",";
+ *onclick=g_strconcat(old,sep,set,"(",setstr,argssep,args,")",NULL);
+ } else {
+ *onclick=g_strconcat(old,sep,str,NULL);
+ }
+ g_free(old);
+ }
+error:
+ g_free(str);
+ g_free(args);
+ return;
+}
+
+
+static void
+gui_internal_cmd_img(struct gui_priv * this, char *function, struct attr **in, struct attr ***out, int *valid)
+{
+ char *str=g_strdup("<img"),*suffix=NULL,*onclick=g_strdup(""),*html;
+
+ if (ATTR_IS_STRING((*in)->type)) {
+ if ((*in)->u.str && strlen((*in)->u.str))
+ str=gui_internal_append_attr(str, escape_mode_string|escape_mode_html, " class=", *in, "");
+ in++;
+ } else {
+ dbg(0,"argument error: class argument not string\n");
+ goto error;
+ }
+ if (ATTR_IS_STRING((*in)->type) && (*in)->u.str) {
+ if ((*in)->u.str && strlen((*in)->u.str)) {
+ str=gui_internal_append_attr(str, escape_mode_string|escape_mode_html, " src=", *in, "");
+ }
+ in++;
+ } else {
+ dbg(0,"argument error: image argument not string\n");
+ goto error;
+ }
+ if (ATTR_IS_STRING((*in)->type) && (*in)->u.str) {
+ if ((*in)->u.str && strlen((*in)->u.str)) {
+ suffix=gui_internal_append_attr(NULL, escape_mode_html, ">", *in, "</img>");
+ } else {
+ suffix=g_strdup("/>");
+ }
+ in++;
+ } else {
+ dbg(0,"argument error: text argument not string\n");
+ goto error;
+ }
+ gui_internal_onclick(&in,&onclick,NULL);
+ gui_internal_onclick(&in,&onclick,"set");
+ gui_internal_onclick(&in,&onclick,NULL);
+ if (strlen(onclick)) {
+ char *tmp=gui_internal_escape(escape_mode_html_quote, onclick);
+ str=g_strconcat_printf(str," onclick=\"%s\"",tmp);
+ g_free(tmp);
+ }
+ g_free(onclick);
+ html=g_strdup_printf("<html>%s%s</html>\n",str,suffix);
+ dbg(1,"return %s",html);
+ gui_internal_html_parse_text(this, html);
+ g_free(html);
+error:
+ g_free(suffix);
+ g_free(str);
+ return;
+}
+
+static void
gui_internal_cmd_debug(struct gui_priv * this, char *function, struct attr **in, struct attr ***out, int *valid)
{
char *str;
@@ -997,6 +1152,7 @@
{"debug",command_cast(gui_internal_cmd_debug)},
{"formerdests",command_cast(gui_internal_cmd2)},
{"get_data",command_cast(gui_internal_get_data)},
+ {"img",command_cast(gui_internal_cmd_img)},
{"locale",command_cast(gui_internal_cmd2)},
{"log",command_cast(gui_internal_cmd_log)},
{"menu",command_cast(gui_internal_cmd_menu2)},
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mar...@us...> - 2013-03-09 20:31:23
|
Revision: 5401
http://navit.svn.sourceforge.net/navit/?rev=5401&view=rev
Author: martin-s
Date: 2013-03-09 20:31:16 +0000 (Sat, 09 Mar 2013)
Log Message:
-----------
Fix:Core:Correctly unescape strings
Modified Paths:
--------------
trunk/navit/navit/command.c
Modified: trunk/navit/navit/command.c
===================================================================
--- trunk/navit/navit/command.c 2013-03-05 22:01:06 UTC (rev 5400)
+++ trunk/navit/navit/command.c 2013-03-09 20:31:16 UTC (rev 5401)
@@ -541,9 +541,13 @@
return;
}
if (op[0] == '"') {
+ int escaped=0;
do {
- if (op[0] == '\\' && op[1] == '"')
- op++;
+ if (op[0] == '\\') {
+ escaped=1;
+ if (op[1] == '"')
+ op++;
+ }
op++;
} while (op[0] && op[0] != '"');
if(!*op) {
@@ -551,7 +555,19 @@
return;
}
op++;
- result_set(ctx, set_type_string, ctx->expr, op-ctx->expr, res);
+ if (escaped) {
+ char *tmpstr=g_malloc(op-ctx->expr+1),*s=tmpstr;
+ op=ctx->expr;
+ do {
+ if (op[0] == '\\')
+ op++;
+ *s++=*op++;
+ } while (op[0] != '"');
+ *s++=*op++;
+ result_set(ctx, set_type_string, tmpstr, s-tmpstr, res);
+ g_free(tmpstr);
+ } else
+ result_set(ctx, set_type_string, ctx->expr, op-ctx->expr, res);
ctx->expr=op;
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mar...@us...> - 2013-03-05 22:01:15
|
Revision: 5400
http://navit.svn.sourceforge.net/navit/?rev=5400&view=rev
Author: martin-s
Date: 2013-03-05 22:01:06 +0000 (Tue, 05 Mar 2013)
Log Message:
-----------
Add:Core:Beginning of work to create vehicleprofile options instead of multiple vehicle profiles
Modified Paths:
--------------
trunk/navit/navit/CMakeLists.txt
trunk/navit/navit/Makefile.am
trunk/navit/navit/attr_def.h
trunk/navit/navit/navit_shipped.xml
trunk/navit/navit/xmlconfig.c
trunk/navit/navit/xmlconfig.h
Added Paths:
-----------
trunk/navit/navit/profile_option.c
Modified: trunk/navit/navit/CMakeLists.txt
===================================================================
--- trunk/navit/navit/CMakeLists.txt 2013-03-05 21:04:40 UTC (rev 5399)
+++ trunk/navit/navit/CMakeLists.txt 2013-03-05 22:01:06 UTC (rev 5400)
@@ -8,7 +8,7 @@
set(NAVIT_SRC announcement.c atom.c attr.c cache.c callback.c command.c compass.c config_.c coord.c country.c data_window.c debug.c
event.c file.c geom.c graphics.c gui.c item.c layout.c log.c main.c map.c maps.c
linguistics.c mapset.c maptype.c menu.c messages.c bookmarks.c navit.c navigation.c osd.c param.c phrase.c plugin.c popup.c
- profile.c projection.c roadprofile.c route.c routech.c search.c speech.c start_real.c sunriset.c transform.c track.c
+ profile.c profile_option.c projection.c roadprofile.c route.c routech.c search.c speech.c start_real.c sunriset.c transform.c track.c
util.c vehicle.c vehicleprofile.c xmlconfig.c )
if(NOT USE_PLUGINS)
Modified: trunk/navit/navit/Makefile.am
===================================================================
--- trunk/navit/navit/Makefile.am 2013-03-05 21:04:40 UTC (rev 5399)
+++ trunk/navit/navit/Makefile.am 2013-03-05 22:01:06 UTC (rev 5400)
@@ -51,7 +51,7 @@
lib@LIBNAVIT@_la_SOURCES = announcement.c atom.c attr.c cache.c callback.c command.c compass.c config_.c coord.c country.c data_window.c debug.c \
event.c event_glib.h file.c geom.c graphics.c gui.c item.c layout.c log.c main.c map.c maps.c \
linguistics.c mapset.c maptype.c menu.c messages.c bookmarks.c bookmarks.h navit.c navigation.c osd.c param.c phrase.c plugin.c popup.c \
- profile.c projection.c roadprofile.c route.c routech.c search.c speech.c start_real.c transform.c track.c \
+ profile.c profile_option.c projection.c roadprofile.c route.c routech.c search.c speech.c start_real.c transform.c track.c \
util.c vehicle.c vehicleprofile.c xmlconfig.c announcement.h atom.h attr.h attr_def.h cache.h callback.h color.h command.h compass.h config_.h coord.h country.h \
android.h data.h data_window.h data_window_int.h debug.h destination.h draw_info.h endianess.h event.h \
file.h geom.h graphics.h gtkext.h gui.h item.h item_def.h keys.h log.h layer.h layout.h linguistics.h main.h map-share.h map.h\
Modified: trunk/navit/navit/attr_def.h
===================================================================
--- trunk/navit/navit/attr_def.h 2013-03-05 21:04:40 UTC (rev 5399)
+++ trunk/navit/navit/attr_def.h 2013-03-05 22:01:06 UTC (rev 5400)
@@ -441,6 +441,7 @@
ATTR(config)
ATTR(maps)
ATTR(layout)
+ATTR(profile_option)
ATTR2(0x0008ffff,type_object_end)
ATTR2(0x00090000,type_coord_begin)
ATTR2(0x0009ffff,type_coord_end)
Modified: trunk/navit/navit/navit_shipped.xml
===================================================================
--- trunk/navit/navit/navit_shipped.xml 2013-03-05 21:04:40 UTC (rev 5399)
+++ trunk/navit/navit/navit_shipped.xml 2013-03-05 22:01:06 UTC (rev 5400)
@@ -276,6 +276,11 @@
</roadprofile>
<roadprofile item_types="roundabout" speed="10" route_weight="10"/>
<roadprofile item_types="ferry" speed="40" route_weight="40"/>
+ <profile_option name="shortest">
+ <roadprofile item_types="street_0,street_1_city,living_street,street_service,track_gravelled,track_unpaved,street_parking_lane,street_2_city,track_paved,street_3_city,street_4_city,highway_city,street_1_land,street_2_land,street_3_land,street_4_land,street_n_lanes,highway_land,ramp,roundabout,ferry" route_weight="60" />
+ </profile_option>
+ <profile_option name="avoid_tolls" flags_forward_mask="0x4000402" flags_reverse_mask="0x4000401" />
+ <profile_option name="pedantic" route_depth="18:25%,18:40000" />
</vehicleprofile>
<vehicleprofile name="car_shortest" flags="0x4000000" flags_forward_mask="0x4000002" flags_reverse_mask="0x4000001" maxspeed_handling="0" route_mode="0" static_speed="5" static_distance="25">
Added: trunk/navit/navit/profile_option.c
===================================================================
--- trunk/navit/navit/profile_option.c (rev 0)
+++ trunk/navit/navit/profile_option.c 2013-03-05 22:01:06 UTC (rev 5400)
@@ -0,0 +1,61 @@
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2012 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terpo 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 "item.h"
+#include "debug.h"
+#include "xmlconfig.h"
+
+struct profile_option
+{
+ NAVIT_OBJECT
+};
+
+struct profile_option *
+profile_option_new(struct attr *parent, struct attr **attrs)
+{
+ struct profile_option *po=g_new0(struct profile_option, 1);
+ po->func=&profile_option_func;
+ navit_object_ref((struct navit_object *)po);
+ po->attrs=attr_list_dup(attrs);
+ return po;
+}
+
+void
+profile_option_destroy(struct profile_option *po)
+{
+ attr_list_free(po->attrs);
+ g_free(po);
+}
+
+struct object_func profile_option_func = {
+ attr_profile_option,
+ (object_func_new)profile_option_new,
+ (object_func_get_attr)NULL,
+ (object_func_iter_new)NULL,
+ (object_func_iter_destroy)NULL,
+ (object_func_set_attr)NULL,
+ (object_func_add_attr)NULL,
+ (object_func_remove_attr)NULL,
+ (object_func_init)NULL,
+ (object_func_destroy)profile_option_destroy,
+ (object_func_dup)NULL,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
+};
Modified: trunk/navit/navit/xmlconfig.c
===================================================================
--- trunk/navit/navit/xmlconfig.c 2013-03-05 21:04:40 UTC (rev 5399)
+++ trunk/navit/navit/xmlconfig.c 2013-03-05 22:01:06 UTC (rev 5400)
@@ -286,6 +286,8 @@
return &mapset_func;
case attr_navit:
return &navit_func;
+ case attr_profile_option:
+ return &profile_option_func;
case attr_osd:
return &osd_func;
case attr_trackingo:
@@ -343,7 +345,7 @@
};
static void initStatic(void) {
- elements=g_new0(struct element_func,41); //40 is a number of elements + ending NULL element
+ elements=g_new0(struct element_func,43); //42 is a number of elements + ending NULL element
elements[0].name="config";
elements[0].parent=NULL;
@@ -543,6 +545,16 @@
elements[39].parent="navit";
elements[39].func=NULL;
elements[39].type=attr_layer;
+
+ elements[40].name="profile_option";
+ elements[40].parent="vehicleprofile";
+ elements[40].func=NULL;
+ elements[40].type=attr_profile_option;
+
+ elements[41].name="roadprofile";
+ elements[41].parent="profile_option";
+ elements[41].func=NULL;
+ elements[41].type=attr_roadprofile;
}
/**
Modified: trunk/navit/navit/xmlconfig.h
===================================================================
--- trunk/navit/navit/xmlconfig.h 2013-03-05 21:04:40 UTC (rev 5399)
+++ trunk/navit/navit/xmlconfig.h 2013-03-05 22:01:06 UTC (rev 5400)
@@ -54,9 +54,9 @@
void *(*unref)(void *);
};
-extern struct object_func map_func, mapset_func, navit_func, osd_func, tracking_func, vehicle_func, maps_func, layout_func, vehicleprofile_func, layer_func, config_func;
+extern struct object_func map_func, mapset_func, navit_func, osd_func, tracking_func, vehicle_func, maps_func, layout_func, vehicleprofile_func, layer_func, config_func, profile_option_func;
-#define HAS_OBJECT_FUNC(x) ((x) == attr_map || (x) == attr_mapset || (x) == attr_navit || (x) == attr_osd || (x) == attr_trackingo || (x) == attr_vehicle || (x) == attr_maps || (x) == attr_layout || (x) == attr_vehicleprofile || (x) == attr_layer || (x) == attr_config)
+#define HAS_OBJECT_FUNC(x) ((x) == attr_map || (x) == attr_mapset || (x) == attr_navit || (x) == attr_osd || (x) == attr_trackingo || (x) == attr_vehicle || (x) == attr_maps || (x) == attr_layout || (x) == attr_vehicleprofile || (x) == attr_layer || (x) == attr_config || (x) == attr_profile_option)
#define NAVIT_OBJECT struct object_func *func; int refcount; struct attr **attrs;
struct navit_object {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mar...@us...> - 2013-03-05 21:04:47
|
Revision: 5399
http://navit.svn.sourceforge.net/navit/?rev=5399&view=rev
Author: martin-s
Date: 2013-03-05 21:04:40 +0000 (Tue, 05 Mar 2013)
Log Message:
-----------
Fix:osd_core:Allow accesskey usage on non-overlay osds
Modified Paths:
--------------
trunk/navit/navit/osd/core/osd_core.c
trunk/navit/navit/osd.c
trunk/navit/navit/osd.h
Modified: trunk/navit/navit/osd/core/osd_core.c
===================================================================
--- trunk/navit/navit/osd/core/osd_core.c 2013-03-05 20:32:32 UTC (rev 5398)
+++ trunk/navit/navit/osd/core/osd_core.c 2013-03-05 21:04:40 UTC (rev 5399)
@@ -1471,6 +1471,7 @@
graphics_image_free(opc->osd_item.gr, img);
} else {
osd_set_std_config(nav, &opc->osd_item);
+ osd_set_keypress(nav, &opc->osd_item);
opc->osd_item.gr=gra;
opc->osd_item.graphic_bg=graphics_gc_new(opc->osd_item.gr);
graphics_add_callback(gra, this->draw_cb=callback_new_attr_2(callback_cast(osd_button_draw), attr_postdraw, opc, nav));
Modified: trunk/navit/navit/osd.c
===================================================================
--- trunk/navit/navit/osd.c 2013-03-05 20:32:32 UTC (rev 5398)
+++ trunk/navit/navit/osd.c 2013-03-05 21:04:40 UTC (rev 5399)
@@ -318,6 +318,17 @@
}
void
+osd_set_keypress(struct navit *nav, struct osd_item *item)
+{
+ struct graphics *navit_gr = navit_get_graphics(nav);
+ dbg(2,"accesskey %s\n",item->accesskey);
+ if (item->accesskey) {
+ item->keypress_cb=callback_new_attr_2(callback_cast(osd_std_keypress), attr_keypress, item, nav);
+ graphics_add_callback(navit_gr, item->keypress_cb);
+ }
+}
+
+void
osd_set_std_graphic(struct navit *nav, struct osd_item *item, struct osd_priv *priv)
{
struct graphics *navit_gr;
@@ -342,12 +353,7 @@
item->resize_cb = callback_new_attr_2(callback_cast(osd_std_calculate_sizes), attr_resize, item, priv);
graphics_add_callback(navit_gr, item->resize_cb);
- dbg(2,"accesskey %s\n",item->accesskey);
- if (item->accesskey) {
- item->keypress_cb=callback_new_attr_2(callback_cast(osd_std_keypress), attr_keypress, item, nav);
- graphics_add_callback(navit_gr, item->keypress_cb);
- }
-
+ osd_set_keypress(nav, item);
}
void
Modified: trunk/navit/navit/osd.h
===================================================================
--- trunk/navit/navit/osd.h 2013-03-05 20:32:32 UTC (rev 5398)
+++ trunk/navit/navit/osd.h 2013-03-05 21:04:40 UTC (rev 5399)
@@ -65,6 +65,7 @@
void osd_std_click(struct osd_item *this, struct navit *nav, int pressed, int button, struct point *p);
void osd_set_std_attr(struct attr **attrs, struct osd_item *item, int flags);
void osd_std_config(struct osd_item *item, struct navit *navit);
+void osd_set_keypress(struct navit *nav, struct osd_item *item);
void osd_set_std_config(struct navit *nav, struct osd_item *item);
void osd_set_std_graphic(struct navit *nav, struct osd_item *item, struct osd_priv *priv);
void osd_std_resize(struct osd_item *item);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2013-03-05 20:32:40
|
Revision: 5398
http://navit.svn.sourceforge.net/navit/?rev=5398&view=rev
Author: mdankov
Date: 2013-03-05 20:32:32 +0000 (Tue, 05 Mar 2013)
Log Message:
-----------
Add:core:Move maptool/geom.c code to navit core.
Modified Paths:
--------------
trunk/navit/navit/CMakeLists.txt
trunk/navit/navit/Makefile.am
trunk/navit/navit/maptool/CMakeLists.txt
trunk/navit/navit/maptool/Makefile.am
trunk/navit/navit/maptool/maptool.h
Added Paths:
-----------
trunk/navit/navit/geom.c
trunk/navit/navit/geom.h
Removed Paths:
-------------
trunk/navit/navit/maptool/geom.c
Modified: trunk/navit/navit/CMakeLists.txt
===================================================================
--- trunk/navit/navit/CMakeLists.txt 2013-03-04 19:31:34 UTC (rev 5397)
+++ trunk/navit/navit/CMakeLists.txt 2013-03-05 20:32:32 UTC (rev 5398)
@@ -6,7 +6,7 @@
# navit cre
set(NAVIT_SRC announcement.c atom.c attr.c cache.c callback.c command.c compass.c config_.c coord.c country.c data_window.c debug.c
- event.c file.c graphics.c gui.c item.c layout.c log.c main.c map.c maps.c
+ event.c file.c geom.c graphics.c gui.c item.c layout.c log.c main.c map.c maps.c
linguistics.c mapset.c maptype.c menu.c messages.c bookmarks.c navit.c navigation.c osd.c param.c phrase.c plugin.c popup.c
profile.c projection.c roadprofile.c route.c routech.c search.c speech.c start_real.c sunriset.c transform.c track.c
util.c vehicle.c vehicleprofile.c xmlconfig.c )
Modified: trunk/navit/navit/Makefile.am
===================================================================
--- trunk/navit/navit/Makefile.am 2013-03-04 19:31:34 UTC (rev 5397)
+++ trunk/navit/navit/Makefile.am 2013-03-05 20:32:32 UTC (rev 5398)
@@ -49,12 +49,12 @@
EXTRA_DIST = navit_shipped.xml navit.dtd
lib@LIBNAVIT@_la_SOURCES = announcement.c atom.c attr.c cache.c callback.c command.c compass.c config_.c coord.c country.c data_window.c debug.c \
- event.c event_glib.h file.c graphics.c gui.c item.c layout.c log.c main.c map.c maps.c \
+ event.c event_glib.h file.c geom.c graphics.c gui.c item.c layout.c log.c main.c map.c maps.c \
linguistics.c mapset.c maptype.c menu.c messages.c bookmarks.c bookmarks.h navit.c navigation.c osd.c param.c phrase.c plugin.c popup.c \
profile.c projection.c roadprofile.c route.c routech.c search.c speech.c start_real.c transform.c track.c \
util.c vehicle.c vehicleprofile.c xmlconfig.c announcement.h atom.h attr.h attr_def.h cache.h callback.h color.h command.h compass.h config_.h coord.h country.h \
android.h data.h data_window.h data_window_int.h debug.h destination.h draw_info.h endianess.h event.h \
- file.h graphics.h gtkext.h gui.h item.h item_def.h keys.h log.h layer.h layout.h linguistics.h main.h map-share.h map.h\
+ file.h geom.h graphics.h gtkext.h gui.h item.h item_def.h keys.h log.h layer.h layout.h linguistics.h main.h map-share.h map.h\
map_data.h mapset.h maptype.h menu.h messages.h navigation.h navit.h osd.h \
param.h phrase.h plugin.h point.h plugin_def.h projection.h popup.h route.h profile.h roadprofile.h search.h speech.h start_real.h \
transform.h track.h types.h util.h vehicle.h vehicleprofile.h window.h xmlconfig.h zipfile.h \
Added: trunk/navit/navit/geom.c
===================================================================
--- trunk/navit/navit/geom.c (rev 0)
+++ trunk/navit/navit/geom.c 2013-03-05 20:32:32 UTC (rev 5398)
@@ -0,0 +1,514 @@
+/**
+ * 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 <string.h>
+#include <math.h>
+#include "geom.h"
+
+void
+geom_coord_copy(struct coord *from, struct coord *to, int count, int reverse)
+{
+ int i;
+ if (!reverse) {
+ memcpy(to, from, count*sizeof(struct coord));
+ return;
+ }
+ from+=count;
+ for (i = 0 ; i < count ; i++)
+ *to++=*--from;
+}
+
+/**
+ * Get coordinates of polyline middle point.
+ * @param in *p array of poly vertex coordinates
+ * @param in count count of poly vertexes
+ * @param out *c coordinates of middle point
+ * @returns number of first vertex of segment containing middle point
+ */
+int
+geom_line_middle(struct coord *p, int count, struct coord *c)
+{
+ double length=0,half=0,len=0;
+ int i;
+
+ if(count==1) {
+ *c=*p;
+ return 0;
+ }
+
+ for (i=0; i<count-1; i++) {
+ length+=sqrt(sq(p[i].x-p[i+1].x)+sq(p[i].y-p[i+1].y));
+ }
+
+ length/=2;
+ for (i=0; (i<count-1) && (half<length); i++) {
+ len=sqrt(sq(p[i].x-p[i+1].x)+sq(p[i].y-p[i+1].y));
+ half+=len;
+ }
+ if (i > 0) {
+ i--;
+ half-=length;
+ if (len) {
+ c->x=(p[i].x*half+p[i+1].x*(len-half))/len;
+ c->y=(p[i].y*half+p[i+1].y*(len-half))/len;
+ } else
+ *c=p[i];
+ } else
+ *c=p[0];
+ return i;
+}
+
+
+void
+geom_coord_revert(struct coord *c, int count)
+{
+ struct coord tmp;
+ int i;
+
+ for (i = 0 ; i < count/2 ; i++) {
+ tmp=c[i];
+ c[i]=c[count-1-i];
+ c[count-1-i]=tmp;
+ }
+}
+
+
+long long
+geom_poly_area(struct coord *c, int count)
+{
+ long long area=0;
+ int i,j=0;
+#if 0
+ fprintf(stderr,"count=%d\n",count);
+#endif
+ for (i=0; i<count; i++) {
+ if (++j == count)
+ j=0;
+#if 0
+ fprintf(stderr,"(%d+%d)*(%d-%d)=%d*%d="LONGLONG_FMT"\n",c[i].x,c[j].x,c[i].y,c[j].y,c[i].x+c[j].x,c[i].y-c[j].y,(long long)(c[i].x+c[j].x)*(c[i].y-c[j].y));
+#endif
+ area+=(long long)(c[i].x+c[j].x)*(c[i].y-c[j].y);
+#if 0
+ fprintf(stderr,"area="LONGLONG_FMT"\n",area);
+#endif
+ }
+ return area/2;
+}
+
+/**
+ * Get poly centroid coordinates.
+ * @param in *p array of poly vertex coordinates
+ * @param in count count of poly vertexes
+ * @param out *c coordinates of poly centroid
+ * @returns 1 on success, 0 if poly area is 0
+ */
+int
+geom_poly_centroid(struct coord *p, int count, struct coord *c)
+{
+ long long area=0;
+ long long sx=0,sy=0,tmp;
+ int i,j;
+ long long x0=p[0].x, y0=p[0].y, xi, yi, xj, yj;
+
+ /*fprintf(stderr,"area="LONGLONG_FMT"\n", area );*/
+ for (i=0,j=0; i<count; i++) {
+ if (++j == count)
+ j=0;
+ xi=p[i].x-x0;
+ yi=p[i].y-y0;
+ xj=p[j].x-x0;
+ yj=p[j].y-y0;
+ tmp=(xi*yj-xj*yi);
+ sx+=(xi+xj)*tmp;
+ sy+=(yi+yj)*tmp;
+ area+=xi*yj-xj*yi;
+ }
+ if(area!=0) {
+ c->x=x0+sx/3/area;
+ c->y=y0+sy/3/area;
+ return 1;
+ }
+ return 0;
+}
+
+/**
+ * Get coordinates of polyline point c most close to given point p.
+ * @param in *pl array of polyline vertex coordinates
+ * @param in count count of polyline vertexes
+ * @param in *p point coordinates
+ * @param out *c coordinates of polyline point most close to given point.
+ * @returns first vertex number of polyline segment to which c belongs
+ */
+int
+geom_poly_closest_point(struct coord *pl, int count, struct coord *p, struct coord *c)
+{
+ int i,vertex=0;
+ long long x, y, xi, xj, yi, yj, u, d, dmin=0;
+ if(count<2) {
+ c->x=pl->x;
+ c->y=pl->y;
+ return 0;
+ }
+ for(i=0;i<count-1;i++) {
+ xi=pl[i].x;
+ yi=pl[i].y;
+ xj=pl[i+1].x;
+ yj=pl[i+1].y;
+ u=(xj-xi)*(xj-xi)+(yj-yi)*(yj-yi);
+ if(u!=0) {
+ u=((p->x-xi)*(xj-xi)+(p->y-yi)*(yj-yi))*1000/u;
+ }
+ if(u<0)
+ u=0;
+ else if (u>1000)
+ u=1000;
+ x=xi+u*(xj-xi)/1000;
+ y=yi+u*(yj-yi)/1000;
+ d=(p->x-x)*(p->x-x)+(p->y-y)*(p->y-y);
+ if(i==0 || d<dmin) {
+ dmin=d;
+ c->x=x;
+ c->y=y;
+ vertex=i;
+ }
+ }
+ return vertex;
+}
+
+/**
+ * Check if point is inside polgone.
+ * @param in *cp array of polygon vertex coordinates
+ * @param in count count of polygon vertexes
+ * @param in *c point coordinates
+ * @returns 1 - inside, 0 - outside
+ */
+int
+geom_poly_point_inside(struct coord *cp, int count, struct coord *c)
+{
+ int ret=0;
+ struct coord *last=cp+count-1;
+ while (cp < last) {
+ if ((cp[0].y > c->y) != (cp[1].y > c->y) &&
+ c->x < ((long long)cp[1].x-cp[0].x)*(c->y-cp[0].y)/(cp[1].y-cp[0].y)+cp[0].x) {
+#if 0
+ fprintf(stderr," cross 0x%x,0x%x-0x%x,0x%x %dx%d",cp,cp[0].x,cp[0].y,cp[1].x,cp[1].y,cp[1].x-cp[0].x,c->y-cp[0].y);
+ printf("type=selected_line\n");
+ coord_print(projection_mg, &cp[0], stdout);
+ coord_print(projection_mg, &cp[1], stdout);
+#endif
+ ret=!ret;
+ }
+ cp++;
+ }
+ return ret;
+}
+
+
+
+GList *
+geom_poly_segments_insert(GList *list, struct geom_poly_segment *first, struct geom_poly_segment *second, struct geom_poly_segment *third)
+{
+ int count;
+ struct geom_poly_segment *ret;
+ struct coord *pos;
+
+ if (!second)
+ return NULL;
+ ret=g_new(struct geom_poly_segment, 1);
+ ret->type=second->type;
+ count=(second->last-second->first)+1;
+ if (first)
+ count+=(first->last-first->first);
+ if (third)
+ count+=(third->last-third->first);
+#if 0
+ fprintf(stderr,"count=%d first=%p second=%p third=%p\n",count,first,second,third);
+ if (first)
+ fprintf(stderr,"first:0x%x,0x%x-0x%x,0x%x (%d)\n",first->first->x,first->first->y,first->last->x,first->last->y, first->last-first->first+1);
+ if (second)
+ fprintf(stderr,"second:0x%x,0x%x-0x%x,0x%x (%d)\n",second->first->x,second->first->y,second->last->x,second->last->y, second->last-second->first+1);
+ if (third)
+ fprintf(stderr,"third:0x%x,0x%x-0x%x,0x%x (%d)\n",third->first->x,third->first->y,third->last->x,third->last->y, third->last-third->first+1);
+#endif
+ ret->first=g_new(struct coord, count);
+ pos=ret->first;
+ if (first) {
+ count=(first->last-first->first)+1;
+ geom_coord_copy(first->first, pos, count, coord_is_equal(*first->first, *second->first));
+ pos+=count-1;
+ }
+ count=(second->last-second->first)+1;
+ geom_coord_copy(second->first, pos, count, 0);
+ pos+=count;
+ if (third) {
+ pos--;
+ count=(third->last-third->first)+1;
+ geom_coord_copy(third->first, pos, count, coord_is_equal(*third->last, *second->last));
+ pos+=count;
+ }
+ ret->last=pos-1;
+#if 0
+ fprintf(stderr,"result:0x%x,0x%x-0x%x,0x%x (%d)\n",ret->first->x,ret->first->y,ret->last->x,ret->last->y, ret->last-ret->first+1);
+#endif
+ list=g_list_prepend(list, ret);
+#if 0
+ fprintf(stderr,"List=%p\n",list);
+#endif
+ return list;
+}
+
+void
+geom_poly_segment_destroy(struct geom_poly_segment *seg)
+{
+ g_free(seg->first);
+ g_free(seg);
+}
+
+GList *
+geom_poly_segments_remove(GList *list, struct geom_poly_segment *seg)
+{
+ if (seg) {
+ list=g_list_remove(list, seg);
+ geom_poly_segment_destroy(seg);
+ }
+ return list;
+}
+
+int
+geom_poly_segment_compatible(struct geom_poly_segment *s1, struct geom_poly_segment *s2, int dir)
+{
+ int same=0,opposite=0;
+ if (s1->type == geom_poly_segment_type_none || s2->type == geom_poly_segment_type_none)
+ return 0;
+ if (s1->type == s2->type) {
+ same=1;
+ if (s1->type == geom_poly_segment_type_way_inner || s1->type == geom_poly_segment_type_way_outer) {
+ opposite=1;
+ }
+ }
+ if (s1->type == geom_poly_segment_type_way_left_side && s2->type == geom_poly_segment_type_way_right_side)
+ opposite=1;
+ if (s1->type == geom_poly_segment_type_way_right_side && s2->type == geom_poly_segment_type_way_left_side)
+ opposite=1;
+ if (s1->type == geom_poly_segment_type_way_unknown || s2->type == geom_poly_segment_type_way_unknown) {
+ same=1;
+ opposite=1;
+ }
+ if (dir < 0) {
+ if ((opposite && coord_is_equal(*s1->first, *s2->first)) || (same && coord_is_equal(*s1->first, *s2->last)))
+ return 1;
+ } else {
+ if ((opposite && coord_is_equal(*s1->last, *s2->last)) || (same && coord_is_equal(*s1->last, *s2->first)))
+ return 1;
+ }
+ return 0;
+}
+
+
+GList *
+geom_poly_segments_sort(GList *in, enum geom_poly_segment_type type)
+{
+ GList *ret=NULL;
+ while (in) {
+ struct geom_poly_segment *seg=in->data;
+ GList *tmp=ret;
+ struct geom_poly_segment *merge_first=NULL,*merge_last=NULL;
+ while (tmp) {
+ struct geom_poly_segment *cseg=tmp->data;
+ if (geom_poly_segment_compatible(seg, cseg, -1))
+ merge_first=cseg;
+ if (geom_poly_segment_compatible(seg, cseg, 1))
+ merge_last=cseg;
+ tmp=g_list_next(tmp);
+ }
+ if (merge_first == merge_last)
+ merge_last=NULL;
+ ret=geom_poly_segments_insert(ret, merge_first, seg, merge_last);
+ ret=geom_poly_segments_remove(ret, merge_first);
+ ret=geom_poly_segments_remove(ret, merge_last);
+ in=g_list_next(in);
+ }
+ in=ret;
+ while (in) {
+ struct geom_poly_segment *seg=in->data;
+ if (coord_is_equal(*seg->first, *seg->last)) {
+ long long area=geom_poly_area(seg->first,seg->last-seg->first+1);
+ if (type == geom_poly_segment_type_way_right_side && seg->type == geom_poly_segment_type_way_right_side) {
+ seg->type=area > 0 ? geom_poly_segment_type_way_outer : geom_poly_segment_type_way_inner;
+ }
+ }
+ in=g_list_next(in);
+ }
+ return ret;
+}
+
+int
+geom_poly_segments_point_inside(GList *in, struct coord *c)
+{
+ int open_matches=0,closed_matches=0;
+ struct coord *cp;
+#if 0
+ fprintf(stderr,"try 0x%x,0x%x:",c->x,c->y);
+#endif
+ while (in) {
+ struct geom_poly_segment *seg=in->data;
+ cp=seg->first;
+ if (geom_poly_point_inside(seg->first, seg->last-seg->first+1, c)) {
+#if 0
+ fprintf(stderr," inside");
+#endif
+ if (coord_is_equal(*seg->first,*seg->last))
+ closed_matches++;
+ else
+ open_matches++;
+ } else {
+#if 0
+ fprintf(stderr," outside");
+#endif
+ }
+ in=g_list_next(in);
+ }
+#if 0
+ fprintf(stderr,"\n");
+ fprintf(stderr,"open_matches %d closed_matches %d\n",open_matches,closed_matches);
+#endif
+ if (closed_matches) {
+ if (closed_matches & 1)
+ return 1;
+ else
+ return 0;
+ }
+ if (open_matches) {
+ if (open_matches & 1)
+ return -1;
+ else
+ return 0;
+ }
+ return 0;
+}
+
+int
+clipcode(struct coord *p, struct rect *r)
+{
+ int code=0;
+ if (p->x < r->l.x)
+ code=1;
+ if (p->x > r->h.x)
+ code=2;
+ if (p->y < r->l.y)
+ code |=4;
+ if (p->y > r->h.y)
+ code |=8;
+ return code;
+}
+
+
+int
+geom_clip_line_code(struct coord *p1, struct coord *p2, struct rect *r)
+{
+ int code1,code2,ret=1;
+ long long dx,dy;
+ code1=clipcode(p1, r);
+ if (code1)
+ ret |= 2;
+ code2=clipcode(p2, r);
+ if (code2)
+ ret |= 4;
+ dx=p2->x-p1->x;
+ dy=p2->y-p1->y;
+ while (code1 || code2) {
+ if (code1 & code2)
+ return 0;
+ if (code1 & 1) {
+ p1->y+=(r->l.x-p1->x)*dy/dx;
+ p1->x=r->l.x;
+ } else if (code1 & 2) {
+ p1->y+=(r->h.x-p1->x)*dy/dx;
+ p1->x=r->h.x;
+ } else if (code1 & 4) {
+ p1->x+=(r->l.y-p1->y)*dx/dy;
+ p1->y=r->l.y;
+ } else if (code1 & 8) {
+ p1->x+=(r->h.y-p1->y)*dx/dy;
+ p1->y=r->h.y;
+ }
+ code1=clipcode(p1, r);
+ if (code1 & code2)
+ return 0;
+ if (code2 & 1) {
+ p2->y+=(r->l.x-p2->x)*dy/dx;
+ p2->x=r->l.x;
+ } else if (code2 & 2) {
+ p2->y+=(r->h.x-p2->x)*dy/dx;
+ p2->x=r->h.x;
+ } else if (code2 & 4) {
+ p2->x+=(r->l.y-p2->y)*dx/dy;
+ p2->y=r->l.y;
+ } else if (code2 & 8) {
+ p2->x+=(r->h.y-p2->y)*dx/dy;
+ p2->y=r->h.y;
+ }
+ code2=clipcode(p2, r);
+ }
+ if (p1->x == p2->x && p1->y == p2->y)
+ ret=0;
+ return ret;
+}
+
+int
+geom_is_inside(struct coord *p, struct rect *r, int edge)
+{
+ switch(edge) {
+ case 0:
+ return p->x >= r->l.x;
+ case 1:
+ return p->x <= r->h.x;
+ case 2:
+ return p->y >= r->l.y;
+ case 3:
+ return p->y <= r->h.y;
+ default:
+ return 0;
+ }
+}
+
+void
+geom_poly_intersection(struct coord *p1, struct coord *p2, struct rect *r, int edge, struct coord *ret)
+{
+ int dx=p2->x-p1->x;
+ int dy=p2->y-p1->y;
+ switch(edge) {
+ case 0:
+ ret->y=p1->y+(r->l.x-p1->x)*dy/dx;
+ ret->x=r->l.x;
+ break;
+ case 1:
+ ret->y=p1->y+(r->h.x-p1->x)*dy/dx;
+ ret->x=r->h.x;
+ break;
+ case 2:
+ ret->x=p1->x+(r->l.y-p1->y)*dx/dy;
+ ret->y=r->l.y;
+ break;
+ case 3:
+ ret->x=p1->x+(r->h.y-p1->y)*dx/dy;
+ ret->y=r->h.y;
+ break;
+ }
+}
+
Added: trunk/navit/navit/geom.h
===================================================================
--- trunk/navit/navit/geom.h (rev 0)
+++ trunk/navit/navit/geom.h 2013-03-05 20:32:32 UTC (rev 5398)
@@ -0,0 +1,61 @@
+/**
+ * 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 "config.h"
+#include "coord.h"
+#include "item.h"
+#include "attr.h"
+
+
+#define sq(x) ((double)(x)*(x))
+
+struct rect {struct coord l,h;};
+
+enum geom_poly_segment_type {
+ geom_poly_segment_type_none,
+ geom_poly_segment_type_way_inner,
+ geom_poly_segment_type_way_outer,
+ geom_poly_segment_type_way_left_side,
+ geom_poly_segment_type_way_right_side,
+ geom_poly_segment_type_way_unknown,
+
+};
+
+struct geom_poly_segment {
+ enum geom_poly_segment_type type;
+ struct coord *first,*last;
+};
+
+void geom_coord_copy(struct coord *from, struct coord *to, int count, int reverse);
+void geom_coord_revert(struct coord *c, int count);
+int geom_line_middle(struct coord *p, int count, struct coord *c);
+long long geom_poly_area(struct coord *c, int count);
+int geom_poly_centroid(struct coord *c, int count, struct coord *r);
+int geom_poly_point_inside(struct coord *cp, int count, struct coord *c);
+int geom_poly_closest_point(struct coord *pl, int count, struct coord *p, struct coord *c);
+GList *geom_poly_segments_insert(GList *list, struct geom_poly_segment *first, struct geom_poly_segment *second, struct geom_poly_segment *third);
+void geom_poly_segment_destroy(struct geom_poly_segment *seg);
+GList *geom_poly_segments_remove(GList *list, struct geom_poly_segment *seg);
+int geom_poly_segment_compatible(struct geom_poly_segment *s1, struct geom_poly_segment *s2, int dir);
+GList *geom_poly_segments_sort(GList *in, enum geom_poly_segment_type type);
+int geom_poly_segments_point_inside(GList *in, struct coord *c);
+int geom_clip_line_code(struct coord *p1, struct coord *p2, struct rect *r);
+int geom_is_inside(struct coord *p, struct rect *r, int edge);
+void geom_poly_intersection(struct coord *p1, struct coord *p2, struct rect *r, int edge, struct coord *ret);
+
Modified: trunk/navit/navit/maptool/CMakeLists.txt
===================================================================
--- trunk/navit/navit/maptool/CMakeLists.txt 2013-03-04 19:31:34 UTC (rev 5397)
+++ trunk/navit/navit/maptool/CMakeLists.txt 2013-03-05 20:32:32 UTC (rev 5398)
@@ -2,7 +2,7 @@
if(BUILD_MAPTOOL)
add_definitions( -DMODULE=maptool ${NAVIT_COMPILE_FLAGS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
- SET(MAPTOOL_SOURCE boundaries.c buffer.c ch.c coastline.c geom.c itembin.c itembin_buffer.c misc.c osm.c osm_o5m.c osm_relations.c sourcesink.c tempfile.c tile.c zip.c osm_xml.c)
+ SET(MAPTOOL_SOURCE boundaries.c buffer.c ch.c coastline.c itembin.c itembin_buffer.c misc.c osm.c osm_o5m.c osm_relations.c sourcesink.c tempfile.c tile.c zip.c osm_xml.c)
if(NOT MSVC)
SET(MAPTOOL_SOURCE ${MAPTOOL_SOURCE} osm_protobuf.c osm_protobufdb.c generated-code/fileformat.pb-c.c generated-code/osmformat.pb-c.c google/protobuf-c/protobuf-c.c)
endif(NOT MSVC)
Modified: trunk/navit/navit/maptool/Makefile.am
===================================================================
--- trunk/navit/navit/maptool/Makefile.am 2013-03-04 19:31:34 UTC (rev 5397)
+++ trunk/navit/navit/maptool/Makefile.am 2013-03-05 20:32:32 UTC (rev 5398)
@@ -5,6 +5,6 @@
endif
AM_CPPFLAGS = @NAVIT_CFLAGS@ -I$(top_srcdir)/navit @ZLIB_CFLAGS@ @POSTGRESQL_CFLAGS@ -DMODULE=maptool
-libmaptool_la_SOURCES = boundaries.c buffer.c ch.c coastline.c geom.c itembin.c itembin_buffer.c misc.c osm.c osm_o5m.c osm_psql.c osm_protobuf.c osm_protobufdb.c osm_relations.c osm_xml.c sourcesink.c tempfile.c tile.c zip.c maptool.h generated-code/fileformat.pb-c.c generated-code/fileformat.pb-c.h generated-code/osmformat.pb-c.c generated-code/osmformat.pb-c.h google/protobuf-c/protobuf-c.c google/protobuf-c/protobuf-c.h google/protobuf-c/protobuf-c-private.h
+libmaptool_la_SOURCES = boundaries.c buffer.c ch.c coastline.c itembin.c itembin_buffer.c misc.c osm.c osm_o5m.c osm_psql.c osm_protobuf.c osm_protobufdb.c osm_relations.c osm_xml.c sourcesink.c tempfile.c tile.c zip.c maptool.h generated-code/fileformat.pb-c.c generated-code/fileformat.pb-c.h generated-code/osmformat.pb-c.c generated-code/osmformat.pb-c.h google/protobuf-c/protobuf-c.c google/protobuf-c/protobuf-c.h google/protobuf-c/protobuf-c-private.h
maptool_SOURCES = maptool.c
maptool_LDADD = libmaptool.la ../libnavit.la @NAVIT_LIBS@ @WORDEXP_LIBS@ @ZLIB_LIBS@ @POSTGRESQL_LIBS@ @CRYPTO_LIBS@ @INTLLIBS@ @LIBC_LIBS@
Deleted: trunk/navit/navit/maptool/geom.c
===================================================================
--- trunk/navit/navit/maptool/geom.c 2013-03-04 19:31:34 UTC (rev 5397)
+++ trunk/navit/navit/maptool/geom.c 2013-03-05 20:32:32 UTC (rev 5398)
@@ -1,514 +0,0 @@
-/**
- * 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 <string.h>
-#include <math.h>
-#include "maptool.h"
-
-void
-geom_coord_copy(struct coord *from, struct coord *to, int count, int reverse)
-{
- int i;
- if (!reverse) {
- memcpy(to, from, count*sizeof(struct coord));
- return;
- }
- from+=count;
- for (i = 0 ; i < count ; i++)
- *to++=*--from;
-}
-
-/**
- * Get coordinates of polyline middle point.
- * @param in *p array of poly vertex coordinates
- * @param in count count of poly vertexes
- * @param out *c coordinates of middle point
- * @returns number of first vertex of segment containing middle point
- */
-int
-geom_line_middle(struct coord *p, int count, struct coord *c)
-{
- double length=0,half=0,len=0;
- int i;
-
- if(count==1) {
- *c=*p;
- return 0;
- }
-
- for (i=0; i<count-1; i++) {
- length+=sqrt(sq(p[i].x-p[i+1].x)+sq(p[i].y-p[i+1].y));
- }
-
- length/=2;
- for (i=0; (i<count-1) && (half<length); i++) {
- len=sqrt(sq(p[i].x-p[i+1].x)+sq(p[i].y-p[i+1].y));
- half+=len;
- }
- if (i > 0) {
- i--;
- half-=length;
- if (len) {
- c->x=(p[i].x*half+p[i+1].x*(len-half))/len;
- c->y=(p[i].y*half+p[i+1].y*(len-half))/len;
- } else
- *c=p[i];
- } else
- *c=p[0];
- return i;
-}
-
-
-void
-geom_coord_revert(struct coord *c, int count)
-{
- struct coord tmp;
- int i;
-
- for (i = 0 ; i < count/2 ; i++) {
- tmp=c[i];
- c[i]=c[count-1-i];
- c[count-1-i]=tmp;
- }
-}
-
-
-long long
-geom_poly_area(struct coord *c, int count)
-{
- long long area=0;
- int i,j=0;
-#if 0
- fprintf(stderr,"count=%d\n",count);
-#endif
- for (i=0; i<count; i++) {
- if (++j == count)
- j=0;
-#if 0
- fprintf(stderr,"(%d+%d)*(%d-%d)=%d*%d="LONGLONG_FMT"\n",c[i].x,c[j].x,c[i].y,c[j].y,c[i].x+c[j].x,c[i].y-c[j].y,(long long)(c[i].x+c[j].x)*(c[i].y-c[j].y));
-#endif
- area+=(long long)(c[i].x+c[j].x)*(c[i].y-c[j].y);
-#if 0
- fprintf(stderr,"area="LONGLONG_FMT"\n",area);
-#endif
- }
- return area/2;
-}
-
-/**
- * Get poly centroid coordinates.
- * @param in *p array of poly vertex coordinates
- * @param in count count of poly vertexes
- * @param out *c coordinates of poly centroid
- * @returns 1 on success, 0 if poly area is 0
- */
-int
-geom_poly_centroid(struct coord *p, int count, struct coord *c)
-{
- long long area=0;
- long long sx=0,sy=0,tmp;
- int i,j;
- long long x0=p[0].x, y0=p[0].y, xi, yi, xj, yj;
-
- /*fprintf(stderr,"area="LONGLONG_FMT"\n", area );*/
- for (i=0,j=0; i<count; i++) {
- if (++j == count)
- j=0;
- xi=p[i].x-x0;
- yi=p[i].y-y0;
- xj=p[j].x-x0;
- yj=p[j].y-y0;
- tmp=(xi*yj-xj*yi);
- sx+=(xi+xj)*tmp;
- sy+=(yi+yj)*tmp;
- area+=xi*yj-xj*yi;
- }
- if(area!=0) {
- c->x=x0+sx/3/area;
- c->y=y0+sy/3/area;
- return 1;
- }
- return 0;
-}
-
-/**
- * Get coordinates of polyline point c most close to given point p.
- * @param in *pl array of polyline vertex coordinates
- * @param in count count of polyline vertexes
- * @param in *p point coordinates
- * @param out *c coordinates of polyline point most close to given point.
- * @returns first vertex number of polyline segment to which c belongs
- */
-int
-geom_poly_closest_point(struct coord *pl, int count, struct coord *p, struct coord *c)
-{
- int i,vertex=0;
- long long x, y, xi, xj, yi, yj, u, d, dmin=0;
- if(count<2) {
- c->x=pl->x;
- c->y=pl->y;
- return 0;
- }
- for(i=0;i<count-1;i++) {
- xi=pl[i].x;
- yi=pl[i].y;
- xj=pl[i+1].x;
- yj=pl[i+1].y;
- u=(xj-xi)*(xj-xi)+(yj-yi)*(yj-yi);
- if(u!=0) {
- u=((p->x-xi)*(xj-xi)+(p->y-yi)*(yj-yi))*1000/u;
- }
- if(u<0)
- u=0;
- else if (u>1000)
- u=1000;
- x=xi+u*(xj-xi)/1000;
- y=yi+u*(yj-yi)/1000;
- d=(p->x-x)*(p->x-x)+(p->y-y)*(p->y-y);
- if(i==0 || d<dmin) {
- dmin=d;
- c->x=x;
- c->y=y;
- vertex=i;
- }
- }
- return vertex;
-}
-
-/**
- * Check if point is inside polgone.
- * @param in *cp array of polygon vertex coordinates
- * @param in count count of polygon vertexes
- * @param in *c point coordinates
- * @returns 1 - inside, 0 - outside
- */
-int
-geom_poly_point_inside(struct coord *cp, int count, struct coord *c)
-{
- int ret=0;
- struct coord *last=cp+count-1;
- while (cp < last) {
- if ((cp[0].y > c->y) != (cp[1].y > c->y) &&
- c->x < ((long long)cp[1].x-cp[0].x)*(c->y-cp[0].y)/(cp[1].y-cp[0].y)+cp[0].x) {
-#if 0
- fprintf(stderr," cross 0x%x,0x%x-0x%x,0x%x %dx%d",cp,cp[0].x,cp[0].y,cp[1].x,cp[1].y,cp[1].x-cp[0].x,c->y-cp[0].y);
- printf("type=selected_line\n");
- coord_print(projection_mg, &cp[0], stdout);
- coord_print(projection_mg, &cp[1], stdout);
-#endif
- ret=!ret;
- }
- cp++;
- }
- return ret;
-}
-
-
-
-GList *
-geom_poly_segments_insert(GList *list, struct geom_poly_segment *first, struct geom_poly_segment *second, struct geom_poly_segment *third)
-{
- int count;
- struct geom_poly_segment *ret;
- struct coord *pos;
-
- if (!second)
- return NULL;
- ret=g_new(struct geom_poly_segment, 1);
- ret->type=second->type;
- count=(second->last-second->first)+1;
- if (first)
- count+=(first->last-first->first);
- if (third)
- count+=(third->last-third->first);
-#if 0
- fprintf(stderr,"count=%d first=%p second=%p third=%p\n",count,first,second,third);
- if (first)
- fprintf(stderr,"first:0x%x,0x%x-0x%x,0x%x (%d)\n",first->first->x,first->first->y,first->last->x,first->last->y, first->last-first->first+1);
- if (second)
- fprintf(stderr,"second:0x%x,0x%x-0x%x,0x%x (%d)\n",second->first->x,second->first->y,second->last->x,second->last->y, second->last-second->first+1);
- if (third)
- fprintf(stderr,"third:0x%x,0x%x-0x%x,0x%x (%d)\n",third->first->x,third->first->y,third->last->x,third->last->y, third->last-third->first+1);
-#endif
- ret->first=g_new(struct coord, count);
- pos=ret->first;
- if (first) {
- count=(first->last-first->first)+1;
- geom_coord_copy(first->first, pos, count, coord_is_equal(*first->first, *second->first));
- pos+=count-1;
- }
- count=(second->last-second->first)+1;
- geom_coord_copy(second->first, pos, count, 0);
- pos+=count;
- if (third) {
- pos--;
- count=(third->last-third->first)+1;
- geom_coord_copy(third->first, pos, count, coord_is_equal(*third->last, *second->last));
- pos+=count;
- }
- ret->last=pos-1;
-#if 0
- fprintf(stderr,"result:0x%x,0x%x-0x%x,0x%x (%d)\n",ret->first->x,ret->first->y,ret->last->x,ret->last->y, ret->last-ret->first+1);
-#endif
- list=g_list_prepend(list, ret);
-#if 0
- fprintf(stderr,"List=%p\n",list);
-#endif
- return list;
-}
-
-void
-geom_poly_segment_destroy(struct geom_poly_segment *seg)
-{
- g_free(seg->first);
- g_free(seg);
-}
-
-GList *
-geom_poly_segments_remove(GList *list, struct geom_poly_segment *seg)
-{
- if (seg) {
- list=g_list_remove(list, seg);
- geom_poly_segment_destroy(seg);
- }
- return list;
-}
-
-int
-geom_poly_segment_compatible(struct geom_poly_segment *s1, struct geom_poly_segment *s2, int dir)
-{
- int same=0,opposite=0;
- if (s1->type == geom_poly_segment_type_none || s2->type == geom_poly_segment_type_none)
- return 0;
- if (s1->type == s2->type) {
- same=1;
- if (s1->type == geom_poly_segment_type_way_inner || s1->type == geom_poly_segment_type_way_outer) {
- opposite=1;
- }
- }
- if (s1->type == geom_poly_segment_type_way_left_side && s2->type == geom_poly_segment_type_way_right_side)
- opposite=1;
- if (s1->type == geom_poly_segment_type_way_right_side && s2->type == geom_poly_segment_type_way_left_side)
- opposite=1;
- if (s1->type == geom_poly_segment_type_way_unknown || s2->type == geom_poly_segment_type_way_unknown) {
- same=1;
- opposite=1;
- }
- if (dir < 0) {
- if ((opposite && coord_is_equal(*s1->first, *s2->first)) || (same && coord_is_equal(*s1->first, *s2->last)))
- return 1;
- } else {
- if ((opposite && coord_is_equal(*s1->last, *s2->last)) || (same && coord_is_equal(*s1->last, *s2->first)))
- return 1;
- }
- return 0;
-}
-
-
-GList *
-geom_poly_segments_sort(GList *in, enum geom_poly_segment_type type)
-{
- GList *ret=NULL;
- while (in) {
- struct geom_poly_segment *seg=in->data;
- GList *tmp=ret;
- struct geom_poly_segment *merge_first=NULL,*merge_last=NULL;
- while (tmp) {
- struct geom_poly_segment *cseg=tmp->data;
- if (geom_poly_segment_compatible(seg, cseg, -1))
- merge_first=cseg;
- if (geom_poly_segment_compatible(seg, cseg, 1))
- merge_last=cseg;
- tmp=g_list_next(tmp);
- }
- if (merge_first == merge_last)
- merge_last=NULL;
- ret=geom_poly_segments_insert(ret, merge_first, seg, merge_last);
- ret=geom_poly_segments_remove(ret, merge_first);
- ret=geom_poly_segments_remove(ret, merge_last);
- in=g_list_next(in);
- }
- in=ret;
- while (in) {
- struct geom_poly_segment *seg=in->data;
- if (coord_is_equal(*seg->first, *seg->last)) {
- long long area=geom_poly_area(seg->first,seg->last-seg->first+1);
- if (type == geom_poly_segment_type_way_right_side && seg->type == geom_poly_segment_type_way_right_side) {
- seg->type=area > 0 ? geom_poly_segment_type_way_outer : geom_poly_segment_type_way_inner;
- }
- }
- in=g_list_next(in);
- }
- return ret;
-}
-
-int
-geom_poly_segments_point_inside(GList *in, struct coord *c)
-{
- int open_matches=0,closed_matches=0;
- struct coord *cp;
-#if 0
- fprintf(stderr,"try 0x%x,0x%x:",c->x,c->y);
-#endif
- while (in) {
- struct geom_poly_segment *seg=in->data;
- cp=seg->first;
- if (geom_poly_point_inside(seg->first, seg->last-seg->first+1, c)) {
-#if 0
- fprintf(stderr," inside");
-#endif
- if (coord_is_equal(*seg->first,*seg->last))
- closed_matches++;
- else
- open_matches++;
- } else {
-#if 0
- fprintf(stderr," outside");
-#endif
- }
- in=g_list_next(in);
- }
-#if 0
- fprintf(stderr,"\n");
- fprintf(stderr,"open_matches %d closed_matches %d\n",open_matches,closed_matches);
-#endif
- if (closed_matches) {
- if (closed_matches & 1)
- return 1;
- else
- return 0;
- }
- if (open_matches) {
- if (open_matches & 1)
- return -1;
- else
- return 0;
- }
- return 0;
-}
-
-int
-clipcode(struct coord *p, struct rect *r)
-{
- int code=0;
- if (p->x < r->l.x)
- code=1;
- if (p->x > r->h.x)
- code=2;
- if (p->y < r->l.y)
- code |=4;
- if (p->y > r->h.y)
- code |=8;
- return code;
-}
-
-
-int
-geom_clip_line_code(struct coord *p1, struct coord *p2, struct rect *r)
-{
- int code1,code2,ret=1;
- long long dx,dy;
- code1=clipcode(p1, r);
- if (code1)
- ret |= 2;
- code2=clipcode(p2, r);
- if (code2)
- ret |= 4;
- dx=p2->x-p1->x;
- dy=p2->y-p1->y;
- while (code1 || code2) {
- if (code1 & code2)
- return 0;
- if (code1 & 1) {
- p1->y+=(r->l.x-p1->x)*dy/dx;
- p1->x=r->l.x;
- } else if (code1 & 2) {
- p1->y+=(r->h.x-p1->x)*dy/dx;
- p1->x=r->h.x;
- } else if (code1 & 4) {
- p1->x+=(r->l.y-p1->y)*dx/dy;
- p1->y=r->l.y;
- } else if (code1 & 8) {
- p1->x+=(r->h.y-p1->y)*dx/dy;
- p1->y=r->h.y;
- }
- code1=clipcode(p1, r);
- if (code1 & code2)
- return 0;
- if (code2 & 1) {
- p2->y+=(r->l.x-p2->x)*dy/dx;
- p2->x=r->l.x;
- } else if (code2 & 2) {
- p2->y+=(r->h.x-p2->x)*dy/dx;
- p2->x=r->h.x;
- } else if (code2 & 4) {
- p2->x+=(r->l.y-p2->y)*dx/dy;
- p2->y=r->l.y;
- } else if (code2 & 8) {
- p2->x+=(r->h.y-p2->y)*dx/dy;
- p2->y=r->h.y;
- }
- code2=clipcode(p2, r);
- }
- if (p1->x == p2->x && p1->y == p2->y)
- ret=0;
- return ret;
-}
-
-int
-geom_is_inside(struct coord *p, struct rect *r, int edge)
-{
- switch(edge) {
- case 0:
- return p->x >= r->l.x;
- case 1:
- return p->x <= r->h.x;
- case 2:
- return p->y >= r->l.y;
- case 3:
- return p->y <= r->h.y;
- default:
- return 0;
- }
-}
-
-void
-geom_poly_intersection(struct coord *p1, struct coord *p2, struct rect *r, int edge, struct coord *ret)
-{
- int dx=p2->x-p1->x;
- int dy=p2->y-p1->y;
- switch(edge) {
- case 0:
- ret->y=p1->y+(r->l.x-p1->x)*dy/dx;
- ret->x=r->l.x;
- break;
- case 1:
- ret->y=p1->y+(r->h.x-p1->x)*dy/dx;
- ret->x=r->h.x;
- break;
- case 2:
- ret->x=p1->x+(r->l.y-p1->y)*dx/dy;
- ret->y=r->l.y;
- break;
- case 3:
- ret->x=p1->x+(r->h.y-p1->y)*dx/dy;
- ret->y=r->h.y;
- break;
- }
-}
-
Modified: trunk/navit/navit/maptool/maptool.h
===================================================================
--- trunk/navit/navit/maptool/maptool.h 2013-03-04 19:31:34 UTC (rev 5397)
+++ trunk/navit/navit/maptool/maptool.h 2013-03-05 20:32:32 UTC (rev 5398)
@@ -21,6 +21,7 @@
#include "coord.h"
#include "item.h"
#include "attr.h"
+#include "geom.h"
#ifdef HAVE_LIBCRYPTO
#include <openssl/md5.h>
#endif
@@ -39,10 +40,6 @@
#define debug_tile(x) 0
#define debug_itembin(x) 0
-struct rect {
- struct coord l,h;
-};
-
struct tile_data {
char buffer[1024];
int tile_depth;
@@ -157,44 +154,6 @@
void process_coastlines(FILE *in, FILE *out);
-/* geom.c */
-
-enum geom_poly_segment_type {
- geom_poly_segment_type_none,
- geom_poly_segment_type_way_inner,
- geom_poly_segment_type_way_outer,
- geom_poly_segment_type_way_left_side,
- geom_poly_segment_type_way_right_side,
- geom_poly_segment_type_way_unknown,
-
-};
-
-struct geom_poly_segment {
- enum geom_poly_segment_type type;
- struct coord *first,*last;
-};
-
-void geom_coord_copy(struct coord *from, struct coord *to, int count, int reverse);
-void geom_coord_revert(struct coord *c, int count);
-int geom_line_middle(struct coord *p, int count, struct coord *c);
-long long geom_poly_area(struct coord *c, int count);
-int geom_poly_centroid(struct coord *c, int count, struct coord *r);
-int geom_poly_point_inside(struct coord *cp, int count, struct coord *c);
-int geom_poly_closest_point(struct coord *pl, int count, struct coord *p, struct coord *c);
-GList *geom_poly_segments_insert(GList *list, struct geom_poly_segment *first, struct geom_poly_segment *second, struct geom_poly_segment *third);
-void geom_poly_segment_destroy(struct geom_poly_segment *seg);
-GList *geom_poly_segments_remove(GList *list, struct geom_poly_segment *seg);
-int geom_poly_segment_compatible(struct geom_poly_segment *s1, struct geom_poly_segment *s2, int dir);
-GList *geom_poly_segments_sort(GList *in, enum geom_poly_segment_type type);
-struct geom_poly_segment *item_bin_to_poly_segment(struct item_bin *ib, int type);
-int geom_poly_segments_point_inside(GList *in, struct coord *c);
-int geom_clip_line_code(struct coord *p1, struct coord *p2, struct rect *r);
-int geom_is_inside(struct coord *p, struct rect *r, int edge);
-void geom_poly_intersection(struct coord *p1, struct coord *p2, struct rect *r, int edge, struct coord *ret);
-
-void clip_line(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out);
-void clip_polygon(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out);
-
/* itembin.c */
int item_bin_read(struct item_bin *ib, FILE *in);
@@ -227,6 +186,9 @@
void item_bin_set_type_by_population(struct item_bin *ib, int population);
void item_bin_write_match(struct item_bin *ib, enum attr_type type, enum attr_type match, int maxdepth, FILE *out);
int item_bin_sort_file(char *in_file, char *out_file, struct rect *r, int *size);
+void clip_line(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out);
+void clip_polygon(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out);
+struct geom_poly_segment *item_bin_to_poly_segment(struct item_bin *ib, int type);
/* itembin_buffer.c */
struct node_item *read_node_item(FILE *in);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2013-03-04 19:31:43
|
Revision: 5397
http://navit.svn.sourceforge.net/navit/?rev=5397&view=rev
Author: mdankov
Date: 2013-03-04 19:31:34 +0000 (Mon, 04 Mar 2013)
Log Message:
-----------
Add:maptool:Clean up geom.c to move it to core.
Modified Paths:
--------------
trunk/navit/navit/maptool/geom.c
trunk/navit/navit/maptool/itembin.c
trunk/navit/navit/maptool/maptool.h
Modified: trunk/navit/navit/maptool/geom.c
===================================================================
--- trunk/navit/navit/maptool/geom.c 2013-03-03 06:54:09 UTC (rev 5396)
+++ trunk/navit/navit/maptool/geom.c 2013-03-04 19:31:34 UTC (rev 5397)
@@ -402,20 +402,7 @@
return 0;
}
-struct geom_poly_segment *
-item_bin_to_poly_segment(struct item_bin *ib, int type)
-{
- struct geom_poly_segment *ret=g_new(struct geom_poly_segment, 1);
- int count=ib->clen*sizeof(int)/sizeof(struct coord);
- ret->type=type;
- ret->first=g_new(struct coord, count);
- ret->last=ret->first+count-1;
- geom_coord_copy((struct coord *)(ib+1), ret->first, count, 0);
- return ret;
-}
-
-
-static int
+int
clipcode(struct coord *p, struct rect *r)
{
int code=0;
@@ -431,8 +418,8 @@
}
-static int
-clip_line_code(struct coord *p1, struct coord *p2, struct rect *r)
+int
+geom_clip_line_code(struct coord *p1, struct coord *p2, struct rect *r)
{
int code1,code2,ret=1;
long long dx,dy;
@@ -483,55 +470,9 @@
return ret;
}
-void
-clip_line(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out)
+int
+geom_is_inside(struct coord *p, struct rect *r, int edge)
{
- char *buffer=g_alloca(sizeof(char)*(ib->len*4+32));
- struct item_bin *ib_new=(struct item_bin *)buffer;
- struct coord *pa=(struct coord *)(ib+1);
- int count=ib->clen/2;
- struct coord p1,p2;
- int i,code;
- item_bin_init(ib_new, ib->type);
- for (i = 0 ; i < count ; i++) {
- if (i) {
- p1.x=pa[i-1].x;
- p1.y=pa[i-1].y;
- p2.x=pa[i].x;
- p2.y=pa[i].y;
- /* 0 = invisible, 1 = completely visible, 3 = start point clipped, 5 = end point clipped, 7 both points clipped */
- code=clip_line_code(&p1, &p2, r);
-#if 1
- if (((code == 1 || code == 5) && ib_new->clen == 0) || (code & 2)) {
- item_bin_add_coord(ib_new, &p1, 1);
- }
- if (code) {
- item_bin_add_coord(ib_new, &p2, 1);
- }
- if (i == count-1 || (code & 4)) {
- if (param->attr_to_copy)
- item_bin_copy_attr(ib_new, ib, param->attr_to_copy);
- if (ib_new->clen)
- item_bin_write_clipped(ib_new, param, out);
- item_bin_init(ib_new, ib->type);
- }
-#else
- if (code) {
- item_bin_init(ib_new, ib->type);
- item_bin_add_coord(ib_new, &p1, 1);
- item_bin_add_coord(ib_new, &p2, 1);
- if (param->attr_to_copy)
- item_bin_copy_attr(ib_new, ib, param->attr_to_copy);
- item_bin_write_clipped(ib_new, param, out);
- }
-#endif
- }
- }
-}
-
-static int
-is_inside(struct coord *p, struct rect *r, int edge)
-{
switch(edge) {
case 0:
return p->x >= r->l.x;
@@ -546,8 +487,8 @@
}
}
-static void
-poly_intersection(struct coord *p1, struct coord *p2, struct rect *r, int edge, struct coord *ret)
+void
+geom_poly_intersection(struct coord *p1, struct coord *p2, struct rect *r, int edge, struct coord *ret)
{
int dx=p2->x-p1->x;
int dy=p2->y-p1->y;
@@ -571,52 +512,3 @@
}
}
-void
-clip_polygon(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out)
-{
- int count_in=ib->clen/2;
- struct coord *pin,*p,*s,pi;
- char *buffer1=g_alloca(sizeof(char)*(ib->len*4+ib->clen*7+32));
- struct item_bin *ib1=(struct item_bin *)buffer1;
- char *buffer2=g_alloca(sizeof(char)*(ib->len*4+ib->clen*7+32));
- struct item_bin *ib2=(struct item_bin *)buffer2;
- struct item_bin *ib_in,*ib_out;
- int edge,i;
- ib_out=ib1;
- ib_in=ib;
- for (edge = 0 ; edge < 4 ; edge++) {
- count_in=ib_in->clen/2;
- pin=(struct coord *)(ib_in+1);
- p=pin;
- s=pin+count_in-1;
- item_bin_init(ib_out, ib_in->type);
- for (i = 0 ; i < count_in ; i++) {
- if (is_inside(p, r, edge)) {
- if (! is_inside(s, r, edge)) {
- poly_intersection(s,p,r,edge,&pi);
- item_bin_add_coord(ib_out, &pi, 1);
- }
- item_bin_add_coord(ib_out, p, 1);
- } else {
- if (is_inside(s, r, edge)) {
- poly_intersection(p,s,r,edge,&pi);
- item_bin_add_coord(ib_out, &pi, 1);
- }
- }
- s=p;
- p++;
- }
- if (ib_in == ib1) {
- ib_in=ib2;
- ib_out=ib1;
- } else {
- ib_in=ib1;
- ib_out=ib2;
- }
- }
- if (ib_in->clen) {
- if (param->attr_to_copy)
- item_bin_copy_attr(ib_in, ib, param->attr_to_copy);
- item_bin_write_clipped(ib_in, param, out);
- }
-}
Modified: trunk/navit/navit/maptool/itembin.c
===================================================================
--- trunk/navit/navit/maptool/itembin.c 2013-03-03 06:54:09 UTC (rev 5396)
+++ trunk/navit/navit/maptool/itembin.c 2013-03-04 19:31:34 UTC (rev 5397)
@@ -618,3 +618,112 @@
}
return 0;
}
+
+struct geom_poly_segment *
+item_bin_to_poly_segment(struct item_bin *ib, int type)
+{
+ struct geom_poly_segment *ret=g_new(struct geom_poly_segment, 1);
+ int count=ib->clen*sizeof(int)/sizeof(struct coord);
+ ret->type=type;
+ ret->first=g_new(struct coord, count);
+ ret->last=ret->first+count-1;
+ geom_coord_copy((struct coord *)(ib+1), ret->first, count, 0);
+ return ret;
+}
+
+void
+clip_line(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out)
+{
+ char *buffer=g_alloca(sizeof(char)*(ib->len*4+32));
+ struct item_bin *ib_new=(struct item_bin *)buffer;
+ struct coord *pa=(struct coord *)(ib+1);
+ int count=ib->clen/2;
+ struct coord p1,p2;
+ int i,code;
+ item_bin_init(ib_new, ib->type);
+ for (i = 0 ; i < count ; i++) {
+ if (i) {
+ p1.x=pa[i-1].x;
+ p1.y=pa[i-1].y;
+ p2.x=pa[i].x;
+ p2.y=pa[i].y;
+ /* 0 = invisible, 1 = completely visible, 3 = start point clipped, 5 = end point clipped, 7 both points clipped */
+ code=geom_clip_line_code(&p1, &p2, r);
+#if 1
+ if (((code == 1 || code == 5) && ib_new->clen == 0) || (code & 2)) {
+ item_bin_add_coord(ib_new, &p1, 1);
+ }
+ if (code) {
+ item_bin_add_coord(ib_new, &p2, 1);
+ }
+ if (i == count-1 || (code & 4)) {
+ if (param->attr_to_copy)
+ item_bin_copy_attr(ib_new, ib, param->attr_to_copy);
+ if (ib_new->clen)
+ item_bin_write_clipped(ib_new, param, out);
+ item_bin_init(ib_new, ib->type);
+ }
+#else
+ if (code) {
+ item_bin_init(ib_new, ib->type);
+ item_bin_add_coord(ib_new, &p1, 1);
+ item_bin_add_coord(ib_new, &p2, 1);
+ if (param->attr_to_copy)
+ item_bin_copy_attr(ib_new, ib, param->attr_to_copy);
+ item_bin_write_clipped(ib_new, param, out);
+ }
+#endif
+ }
+ }
+}
+
+void
+clip_polygon(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out)
+{
+ int count_in=ib->clen/2;
+ struct coord *pin,*p,*s,pi;
+ char *buffer1=g_alloca(sizeof(char)*(ib->len*4+ib->clen*7+32));
+ struct item_bin *ib1=(struct item_bin *)buffer1;
+ char *buffer2=g_alloca(sizeof(char)*(ib->len*4+ib->clen*7+32));
+ struct item_bin *ib2=(struct item_bin *)buffer2;
+ struct item_bin *ib_in,*ib_out;
+ int edge,i;
+ ib_out=ib1;
+ ib_in=ib;
+ for (edge = 0 ; edge < 4 ; edge++) {
+ count_in=ib_in->clen/2;
+ pin=(struct coord *)(ib_in+1);
+ p=pin;
+ s=pin+count_in-1;
+ item_bin_init(ib_out, ib_in->type);
+ for (i = 0 ; i < count_in ; i++) {
+ if (geom_is_inside(p, r, edge)) {
+ if (! geom_is_inside(s, r, edge)) {
+ geom_poly_intersection(s,p,r,edge,&pi);
+ item_bin_add_coord(ib_out, &pi, 1);
+ }
+ item_bin_add_coord(ib_out, p, 1);
+ } else {
+ if (geom_is_inside(s, r, edge)) {
+ geom_poly_intersection(p,s,r,edge,&pi);
+ item_bin_add_coord(ib_out, &pi, 1);
+ }
+ }
+ s=p;
+ p++;
+ }
+ if (ib_in == ib1) {
+ ib_in=ib2;
+ ib_out=ib1;
+ } else {
+ ib_in=ib1;
+ ib_out=ib2;
+ }
+ }
+ if (ib_in->clen) {
+ if (param->attr_to_copy)
+ item_bin_copy_attr(ib_in, ib, param->attr_to_copy);
+ item_bin_write_clipped(ib_in, param, out);
+ }
+}
+
Modified: trunk/navit/navit/maptool/maptool.h
===================================================================
--- trunk/navit/navit/maptool/maptool.h 2013-03-03 06:54:09 UTC (rev 5396)
+++ trunk/navit/navit/maptool/maptool.h 2013-03-04 19:31:34 UTC (rev 5397)
@@ -188,6 +188,10 @@
GList *geom_poly_segments_sort(GList *in, enum geom_poly_segment_type type);
struct geom_poly_segment *item_bin_to_poly_segment(struct item_bin *ib, int type);
int geom_poly_segments_point_inside(GList *in, struct coord *c);
+int geom_clip_line_code(struct coord *p1, struct coord *p2, struct rect *r);
+int geom_is_inside(struct coord *p, struct rect *r, int edge);
+void geom_poly_intersection(struct coord *p1, struct coord *p2, struct rect *r, int edge, struct coord *ret);
+
void clip_line(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out);
void clip_polygon(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2013-03-03 06:54:21
|
Revision: 5396
http://navit.svn.sourceforge.net/navit/?rev=5396&view=rev
Author: mdankov
Date: 2013-03-03 06:54:09 +0000 (Sun, 03 Mar 2013)
Log Message:
-----------
Add:maptool:Extend experimental feature by including more town boundaries defined as multipolygons.
Modified Paths:
--------------
trunk/navit/navit/maptool/osm.c
Modified: trunk/navit/navit/maptool/osm.c
===================================================================
--- trunk/navit/navit/maptool/osm.c 2013-02-28 19:58:59 UTC (rev 5395)
+++ trunk/navit/navit/maptool/osm.c 2013-03-03 06:54:09 UTC (rev 5396)
@@ -1471,6 +1471,7 @@
char iso_code[BUFFER_SIZE];
int admin_level;
int boundary;
+int place;
void
osm_add_relation(osmid id)
@@ -1482,6 +1483,7 @@
iso_code[0]='\0';
admin_level=-1;
boundary=0;
+ place=0;
item_bin_init(item_bin, type_none);
item_bin_add_attr_longlong(item_bin, attr_osm_relationid, current_id);
}
@@ -1527,7 +1529,7 @@
osm_end_relation(struct maptool_osm *osm)
{
in_relation=0;
- if ((!strcmp(relation_type, "multipolygon") || !strcmp(relation_type, "boundary")) && boundary) {
+ if ((!strcmp(relation_type, "multipolygon") || !strcmp(relation_type, "boundary")) && (boundary || (place&&experimental))) {
#if 0
if (admin_level == 2) {
FILE *f;
@@ -1587,6 +1589,7 @@
} else if (!strcmp(k,"ISO3166-1")) {
strcpy(iso_code, v);
} else if(experimental && !strcmp(k,"place") && item_bin->type==type_none) {
+ place=1;
if (!strcmp(v,"city")) {
item_bin->type=type_poly_place6;
} else if (!strcmp(v,"town")) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2013-02-28 19:59:05
|
Revision: 5395
http://navit.svn.sourceforge.net/navit/?rev=5395&view=rev
Author: mdankov
Date: 2013-02-28 19:58:59 +0000 (Thu, 28 Feb 2013)
Log Message:
-----------
Add:maptool:Experimental feature to convert place=* relations to poly_place* items to improve address search.
Modified Paths:
--------------
trunk/navit/navit/maptool/maptool.c
trunk/navit/navit/maptool/osm.c
Modified: trunk/navit/navit/maptool/maptool.c
===================================================================
--- trunk/navit/navit/maptool/maptool.c 2013-02-26 17:37:01 UTC (rev 5394)
+++ trunk/navit/navit/maptool/maptool.c 2013-02-28 19:58:59 UTC (rev 5395)
@@ -786,8 +786,8 @@
char *suffixes[]={""};
#endif
char *suffix=suffixes[0];
- char *filenames[10];
- char *referencenames[10];
+ char *filenames[20];
+ char *referencenames[20];
int filename_count=0;
int suffix_count=sizeof(suffixes)/sizeof(char *);
@@ -832,7 +832,7 @@
exit(0);
}
}
-#if 1
+#if 0
if (experimental) {
fprintf(stderr,"No experimental features available\n");
exit(0);
@@ -935,6 +935,10 @@
filenames[filename_count]="way2poi_result";
referencenames[filename_count++]=NULL;
}
+ if(experimental) {
+ filenames[filename_count]="towns_poly";
+ referencenames[filename_count++]=NULL;
+ }
for (i = suffix_start ; i < suffix_count ; i++) {
suffix=suffixes[i];
if (start_phase(&p,"generating tiles")) {
Modified: trunk/navit/navit/maptool/osm.c
===================================================================
--- trunk/navit/navit/maptool/osm.c 2013-02-26 17:37:01 UTC (rev 5394)
+++ trunk/navit/navit/maptool/osm.c 2013-02-28 19:58:59 UTC (rev 5395)
@@ -1586,6 +1586,20 @@
}
} else if (!strcmp(k,"ISO3166-1")) {
strcpy(iso_code, v);
+ } else if(experimental && !strcmp(k,"place") && item_bin->type==type_none) {
+ if (!strcmp(v,"city")) {
+ item_bin->type=type_poly_place6;
+ } else if (!strcmp(v,"town")) {
+ item_bin->type=type_poly_place5;
+ } else if (!strcmp(v,"village")) {
+ item_bin->type=type_poly_place3;
+ } else if (!strcmp(v,"hamlet")) {
+ item_bin->type=type_poly_place2;
+ } else if (!strcmp(v,"isolated_dwelling")) {
+ item_bin->type=type_poly_place2;
+ } else if (!strcmp(v,"locality")) {
+ item_bin->type=type_poly_place2;
+ }
}
if (add_tag) {
char *tag;
@@ -1905,6 +1919,36 @@
return NULL;
}
+static void
+osm_town_relations_to_poly(GList *boundaries, FILE *towns_poly)
+{
+ while(boundaries) {
+ struct boundary *b=boundaries->data;
+ if(item_is_poly_place(*b->ib)) {
+ GList *s=b->sorted_segments;
+ while(s) {
+ struct geom_poly_segment *seg=s->data;
+ if(seg->type==geom_poly_segment_type_way_outer && coord_is_equal(*seg->first,*seg->last)) {
+ struct item_bin *ib=init_item(b->ib->type);
+ void *a;
+ item_bin_add_coord(ib, seg->first, seg->last-seg->first+1);
+ a=osm_tag_value(b->ib, "name");
+ if(a)
+ item_bin_add_attr_string(ib,attr_label,a);
+ a=osm_tag_value(b->ib, "osm_relationid");
+ if(a)
+ item_bin_add_attr_longlong(ib,attr_osm_relationid,atol(a));
+ item_bin_write(ib, towns_poly);
+ }
+ s=g_list_next(s);
+ }
+ }
+ osm_town_relations_to_poly(b->children, towns_poly);
+ boundaries=g_list_next(boundaries);
+ }
+}
+
+
void
osm_process_towns(FILE *in, FILE *boundaries, FILE *ways)
{
@@ -1988,6 +2032,13 @@
}
}
}
+
+ if(experimental) {
+ FILE *f=tempfile("","towns_poly",1);
+ osm_town_relations_to_poly(bl, f);
+ fclose(f);
+ }
+
g_hash_table_destroy(town_hash);
profile(0, "Finished processing towns\n");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mar...@us...> - 2013-02-26 17:37:09
|
Revision: 5394
http://navit.svn.sourceforge.net/navit/?rev=5394&view=rev
Author: martin-s
Date: 2013-02-26 17:37:01 +0000 (Tue, 26 Feb 2013)
Log Message:
-----------
Fix:maptool:Fixed broken coastline generator
Modified Paths:
--------------
trunk/navit/navit/maptool/coastline.c
Modified: trunk/navit/navit/maptool/coastline.c
===================================================================
--- trunk/navit/navit/maptool/coastline.c 2013-02-26 08:53:43 UTC (rev 5393)
+++ trunk/navit/navit/maptool/coastline.c 2013-02-26 17:37:01 UTC (rev 5394)
@@ -145,6 +145,7 @@
struct item_bin_sink_func *sink;
GHashTable *tile_edges;
int level;
+ GList *k,*v;
};
static GList *
@@ -399,9 +400,6 @@
struct item_bin_sink *out=data->sink->priv_data[1];
int edges=ct->edges;
int debug=0;
-
- if (len != data->level)
- return;
#if 0
if (!strncmp(tile,"bcacccaadbdcd",10))
debug=1;
@@ -493,8 +491,6 @@
#endif
if (debug)
fprintf(stderr,"len of %s %d vs %d\n",tile,len,data->level);
- if (len != data->level)
- return;
if (debug)
@@ -528,6 +524,35 @@
g_hash_table_insert(data->tile_edges, g_strdup(tile2), cn);
}
+static void
+foreach_tile_func(gpointer key, gpointer value, gpointer user_data)
+{
+ struct coastline_tile_data *data=user_data;
+ if (strlen((char *)key) == data->level) {
+ data->k=g_list_prepend(data->k, key);
+ data->v=g_list_prepend(data->v, value);
+ }
+}
+
+static void
+foreach_tile(struct coastline_tile_data *data, void(*func)(char *, struct coastline_tile *, struct coastline_tile_data *))
+{
+ GList *k,*v;
+ data->k=NULL;
+ data->v=NULL;
+
+ g_hash_table_foreach(data->tile_edges, foreach_tile_func, data);
+ k=data->k;
+ v=data->v;
+ while (k) {
+ func(k->data,v->data,data);
+ k=g_list_next(k);
+ v=g_list_next(v);
+ }
+ g_list_free(data->k);
+ g_list_free(data->v);
+}
+
static int
tile_collector_finish(struct item_bin_sink_func *tile_collector)
{
@@ -538,28 +563,30 @@
data.tile_edges=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
hash=tile_collector->priv_data[0];
fprintf(stderr,"tile_collector_finish\n");
+#if 1
g_hash_table_foreach(hash, (GHFunc) tile_collector_process_tile, &data);
+#endif
fprintf(stderr,"tile_collector_finish foreach done\n");
g_hash_table_destroy(hash);
fprintf(stderr,"tile_collector_finish destroy done\n");
for (i = 14 ; i > 0 ; i--) {
fprintf(stderr,"Level=%d\n",i);
data.level=i;
- g_hash_table_foreach(data.tile_edges, (GHFunc) tile_collector_add_siblings, &data);
+ foreach_tile(&data, tile_collector_add_siblings);
fprintf(stderr,"*");
- g_hash_table_foreach(data.tile_edges, (GHFunc) tile_collector_add_siblings, &data);
+ foreach_tile(&data, tile_collector_add_siblings);
fprintf(stderr,"*");
- g_hash_table_foreach(data.tile_edges, (GHFunc) tile_collector_add_siblings, &data);
+ foreach_tile(&data, tile_collector_add_siblings);
fprintf(stderr,"*");
- g_hash_table_foreach(data.tile_edges, (GHFunc) tile_collector_add_siblings, &data);
+ foreach_tile(&data, tile_collector_add_siblings);
fprintf(stderr,"*");
- g_hash_table_foreach(data.tile_edges, (GHFunc) tile_collector_add_siblings2, &data);
+ foreach_tile(&data, tile_collector_add_siblings2);
fprintf(stderr,"*\n");
- g_hash_table_foreach(data.tile_edges, (GHFunc) tile_collector_add_siblings2, &data);
+ foreach_tile(&data, tile_collector_add_siblings2);
fprintf(stderr,"*\n");
- g_hash_table_foreach(data.tile_edges, (GHFunc) tile_collector_add_siblings2, &data);
+ foreach_tile(&data, tile_collector_add_siblings2);
fprintf(stderr,"*\n");
- g_hash_table_foreach(data.tile_edges, (GHFunc) tile_collector_add_siblings2, &data);
+ foreach_tile(&data, tile_collector_add_siblings2);
fprintf(stderr,"*\n");
}
#if 0
@@ -627,7 +654,7 @@
void
process_coastlines(FILE *in, FILE *out)
{
- struct item_bin_sink *reader=file_reader_new(in,1000000,0);
+ struct item_bin_sink *reader=file_reader_new(in,-1,0);
struct item_bin_sink_func *file_writer=file_writer_new(out);
struct item_bin_sink *result=item_bin_sink_new();
struct item_bin_sink_func *coastline_processor=coastline_processor_new(result);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mar...@us...> - 2013-02-26 08:53:50
|
Revision: 5393
http://navit.svn.sourceforge.net/navit/?rev=5393&view=rev
Author: martin-s
Date: 2013-02-26 08:53:43 +0000 (Tue, 26 Feb 2013)
Log Message:
-----------
Add:Core:Possibility to configure cache size
Modified Paths:
--------------
trunk/navit/navit/attr_def.h
trunk/navit/navit/cache.c
trunk/navit/navit/cache.h
trunk/navit/navit/config_.c
trunk/navit/navit/file.c
trunk/navit/navit/file.h
Modified: trunk/navit/navit/attr_def.h
===================================================================
--- trunk/navit/navit/attr_def.h 2013-02-23 21:57:01 UTC (rev 5392)
+++ trunk/navit/navit/attr_def.h 2013-02-26 08:53:43 UTC (rev 5393)
@@ -174,6 +174,7 @@
ATTR(street_count)
ATTR(min_dist)
ATTR(max_dist)
+ATTR(cache_size)
ATTR2(0x00027500,type_rel_abs_begin)
/* These attributes are int that can either hold relative *
* or absolute values. A relative value is indicated by *
Modified: trunk/navit/navit/cache.c
===================================================================
--- trunk/navit/navit/cache.c 2013-02-23 21:57:01 UTC (rev 5392)
+++ trunk/navit/navit/cache.c 2013-02-26 08:53:43 UTC (rev 5393)
@@ -113,6 +113,12 @@
return cache;
}
+void
+cache_resize(struct cache *cache, int size)
+{
+ cache->size=size;
+}
+
static void
cache_insert_mru(struct cache *cache, struct cache_entry_list *list, struct cache_entry *entry)
{
Modified: trunk/navit/navit/cache.h
===================================================================
--- trunk/navit/navit/cache.h 2013-02-23 21:57:01 UTC (rev 5392)
+++ trunk/navit/navit/cache.h 2013-02-26 08:53:43 UTC (rev 5393)
@@ -2,6 +2,7 @@
struct cache;
/* prototypes */
struct cache *cache_new(int id_size, int size);
+void cache_resize(struct cache *cache, int size);
void *cache_entry_new(struct cache *cache, void *id, int size);
void cache_entry_destroy(struct cache *cache, void *data);
void *cache_lookup(struct cache *cache, void *id);
Modified: trunk/navit/navit/config_.c
===================================================================
--- trunk/navit/navit/config_.c 2013-02-23 21:57:01 UTC (rev 5392)
+++ trunk/navit/navit/config_.c 2013-02-26 08:53:43 UTC (rev 5393)
@@ -26,6 +26,7 @@
#include "callback.h"
#include "navit.h"
#include "config_.h"
+#include "file.h"
#ifdef HAVE_API_WIN32_CE
#include "libc.h"
#endif
@@ -92,6 +93,8 @@
case attr_language:
setenv("LANG",attr->u.str,1);
return 1;
+ case attr_cache_size:
+ return file_set_cache_size(attr->u.num);
default:
return 0;
}
Modified: trunk/navit/navit/file.c
===================================================================
--- trunk/navit/navit/file.c 2013-02-23 21:57:01 UTC (rev 5392)
+++ trunk/navit/navit/file.c 2013-02-26 08:53:43 UTC (rev 5393)
@@ -929,6 +929,17 @@
return GINT_TO_POINTER(file->fd);
}
+int
+file_set_cache_size(int cache_size)
+{
+#ifdef CACHE_SIZE
+ cache_resize(file_cache, cache_size);
+ return 1;
+#else
+ return 0;
+#endif
+}
+
void
file_init(void)
{
Modified: trunk/navit/navit/file.h
===================================================================
--- trunk/navit/navit/file.h 2013-02-23 21:57:01 UTC (rev 5392)
+++ trunk/navit/navit/file.h 2013-02-26 08:53:43 UTC (rev 5393)
@@ -94,6 +94,7 @@
int file_get_param(struct file *file, struct param_list *param, int count);
int file_version(struct file *file, int byname);
void *file_get_os_handle(struct file *file);
+int file_set_cache_size(int cache_size);
void file_init(void);
int file_is_reg(char *name);
void file_data_remove(struct file *file, unsigned char *data);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2013-02-23 21:57:10
|
Revision: 5392
http://navit.svn.sourceforge.net/navit/?rev=5392&view=rev
Author: mdankov
Date: 2013-02-23 21:57:01 +0000 (Sat, 23 Feb 2013)
Log Message:
-----------
Add:maptool:Support addr:suburb tag by converting it to attr_district on streets and houses.
Modified Paths:
--------------
trunk/navit/navit/maptool/osm.c
Modified: trunk/navit/navit/maptool/osm.c
===================================================================
--- trunk/navit/navit/maptool/osm.c 2013-02-23 21:52:27 UTC (rev 5391)
+++ trunk/navit/navit/maptool/osm.c 2013-02-23 21:57:01 UTC (rev 5392)
@@ -94,6 +94,7 @@
attr_string_fax,
attr_string_email,
attr_string_url,
+ attr_string_district_name,
attr_string_street_name,
attr_string_street_name_systematic,
attr_string_house_number,
@@ -1096,6 +1097,10 @@
attr_strings_save(attr_string_email, v);
level=5;
}
+ if (! strcmp(k,"addr:suburb")) {
+ attr_strings_save(attr_string_district_name, v);
+ level=5;
+ }
if (! strcmp(k,"addr:housenumber")) {
attr_strings_save(attr_string_house_number, v);
level=5;
@@ -1675,6 +1680,7 @@
add_flags=1;
}
item_bin_add_attr_string(item_bin, def_flags ? attr_street_name : attr_label, attr_strings[attr_string_label]);
+ item_bin_add_attr_string(item_bin, attr_district_name, attr_strings[attr_string_district_name]);
item_bin_add_attr_string(item_bin, attr_street_name_systematic, attr_strings[attr_string_street_name_systematic]);
item_bin_add_attr_longlong(item_bin, attr_osm_wayid, osmid_attr_value);
if (debug_attr_buffer[0])
@@ -1697,6 +1703,7 @@
item_bin_add_coord(item_bin, coord_buffer, coord_count);
item_bin_add_attr_string(item_bin, attr_label, attr_strings[attr_string_label]);
item_bin_add_attr_string(item_bin, attr_house_number, attr_strings[attr_string_house_number]);
+ item_bin_add_attr_string(item_bin, attr_district_name, attr_strings[attr_string_district_name]);
item_bin_add_attr_string(item_bin, attr_street_name, attr_strings[attr_string_street_name]);
item_bin_add_attr_string(item_bin, attr_phone, attr_strings[attr_string_phone]);
item_bin_add_attr_string(item_bin, attr_fax, attr_strings[attr_string_fax]);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2013-02-23 21:52:37
|
Revision: 5391
http://navit.svn.sourceforge.net/navit/?rev=5391&view=rev
Author: mdankov
Date: 2013-02-23 21:52:27 +0000 (Sat, 23 Feb 2013)
Log Message:
-----------
Add:maptool:admin_level osm tag to navit attrs state/county/municipality conversion for Spain, Ukraine, United Kingdom, USA.
Modified Paths:
--------------
trunk/navit/navit/maptool/osm.c
Modified: trunk/navit/navit/maptool/osm.c
===================================================================
--- trunk/navit/navit/maptool/osm.c 2013-02-22 23:13:46 UTC (rev 5390)
+++ trunk/navit/navit/maptool/osm.c 2013-02-23 21:52:27 UTC (rev 5391)
@@ -333,7 +333,7 @@
{ 706,"Somalia"},
{ 710,"South Africa"},
{ 716,"Zimbabwe"},
- { 724,"Spain,Espana,España,Reino de Espana,Reino de España"},
+ { 724,"Spain,Espana,España,Reino de Espana,Reino de España","345scm"},
{ 728,"South Sudan"},
{ 732,"Western Sahara"},
{ 736,"Sudan"},
@@ -356,15 +356,15 @@
{ 796,"Turks and Caicos Islands"},
{ 798,"Tuvalu"},
{ 800,"Uganda"},
- { 804,"Ukraine"},
+ { 804,"Ukraine","3s5c78"},
{ 807,"Macedonia,Македонија"},
{ 818,"Egypt"},
- { 826,"United Kingdom,UK"},
+ { 826,"United Kingdom,UK","3s5c7m"},
{ 831,"Guernsey"},
{ 832,"Jersey"},
{ 833,"Isle of Man"},
{ 834,"Tanzania, United Republic of"},
- { 840,"USA"},
+ { 840,"USA","3s5c7m"},
{ 850,"Virgin Islands, U.S."},
{ 854,"Burkina Faso"},
{ 858,"Uruguay"},
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sl...@us...> - 2013-02-22 23:13:55
|
Revision: 5390
http://navit.svn.sourceforge.net/navit/?rev=5390&view=rev
Author: sleske
Date: 2013-02-22 23:13:46 +0000 (Fri, 22 Feb 2013)
Log Message:
-----------
Fix:core:Remove dead code.
Modified Paths:
--------------
trunk/navit/navit/transform.c
Modified: trunk/navit/navit/transform.c
===================================================================
--- trunk/navit/navit/transform.c 2013-02-21 20:55:56 UTC (rev 5389)
+++ trunk/navit/navit/transform.c 2013-02-22 23:13:46 UTC (rev 5390)
@@ -482,19 +482,8 @@
dbg(1,"zc=%d\n", zc);
dbg(1,"xcn %d ycn %d\n", xcn, ycn);
dbg(1,"%d,%d %d\n",xc,yc,zc);
-#if 0
- dbg(0,"%d/%d=%d %d/%d=%d\n",xcn,xc,xcn/xc,ycn,yc,ycn/yc);
-#endif
-#if 1
xc=(long long)xcn*t->xscale/zc;
yc=(long long)ycn*t->yscale/zc;
-#else
- xc=xcn/(1000+zc);
- yc=ycn/(1000+zc);
-#endif
-#if 0
- dbg(1,"%d,%d %d\n",xc,yc,zc);
-#endif
} else {
xc=xcn;
yc=ycn;
@@ -826,22 +815,7 @@
transform_set_yaw(t, yaw);
}
-#if 0
-
void
-transform_setup_source_rect_limit(struct transformation *t, struct coord *center, int limit)
-{
- t->center=*center;
- t->scale=1;
- t->angle=0;
- t->r.lu.x=center->x-limit;
- t->r.rl.x=center->x+limit;
- t->r.rl.y=center->y-limit;
- t->r.lu.y=center->y+limit;
-}
-#endif
-
-void
transform_setup_source_rect(struct transformation *t)
{
int i;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2013-02-21 20:56:07
|
Revision: 5389
http://navit.svn.sourceforge.net/navit/?rev=5389&view=rev
Author: mdankov
Date: 2013-02-21 20:55:56 +0000 (Thu, 21 Feb 2013)
Log Message:
-----------
Add:maptool:Move to mainstream all experimental features: Spain town search by country boundary; skip district names from Russian Fedeal cities.
Modified Paths:
--------------
trunk/navit/navit/maptool/boundaries.c
trunk/navit/navit/maptool/maptool.c
trunk/navit/navit/maptool/osm.c
Modified: trunk/navit/navit/maptool/boundaries.c
===================================================================
--- trunk/navit/navit/maptool/boundaries.c 2013-02-20 21:17:49 UTC (rev 5388)
+++ trunk/navit/navit/maptool/boundaries.c 2013-02-21 20:55:56 UTC (rev 5389)
@@ -82,8 +82,7 @@
if(!iso)
iso=osm_tag_value(ib, "iso3166-1:alpha2");
- /* disable spain for now since it creates a too large index */
- if (admin_level && !strcmp(admin_level, "2") && (!iso || experimental || strcasecmp(iso,"es"))) {
+ if (admin_level && !strcmp(admin_level, "2")) {
if (iso) {
struct country_table *country=country_from_iso2(iso);
if (!country)
Modified: trunk/navit/navit/maptool/maptool.c
===================================================================
--- trunk/navit/navit/maptool/maptool.c 2013-02-20 21:17:49 UTC (rev 5388)
+++ trunk/navit/navit/maptool/maptool.c 2013-02-21 20:55:56 UTC (rev 5389)
@@ -832,7 +832,7 @@
exit(0);
}
}
-#if 0
+#if 1
if (experimental) {
fprintf(stderr,"No experimental features available\n");
exit(0);
Modified: trunk/navit/navit/maptool/osm.c
===================================================================
--- trunk/navit/navit/maptool/osm.c 2013-02-20 21:17:49 UTC (rev 5388)
+++ trunk/navit/navit/maptool/osm.c 2013-02-21 20:55:56 UTC (rev 5389)
@@ -1887,7 +1887,7 @@
}
/* Administrative centres are not to be contained in their own districts. */
- if(experimental && max_adm_level>0)
+ if(max_adm_level>0)
for(a=end-1;a>max_adm_level && a>2;a--)
attrs[a-2].type=type_none;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2013-02-20 21:17:55
|
Revision: 5388
http://navit.svn.sourceforge.net/navit/?rev=5388&view=rev
Author: mdankov
Date: 2013-02-20 21:17:49 +0000 (Wed, 20 Feb 2013)
Log Message:
-----------
Fix:gui_internal:Fix regression of svn5341, include item labels in filtered POI list.
Modified Paths:
--------------
trunk/navit/navit/gui/internal/gui_internal_poi.c
Modified: trunk/navit/navit/gui/internal/gui_internal_poi.c
===================================================================
--- trunk/navit/navit/gui/internal/gui_internal_poi.c 2013-02-20 21:09:13 UTC (rev 5387)
+++ trunk/navit/navit/gui/internal/gui_internal_poi.c 2013-02-20 21:17:49 UTC (rev 5388)
@@ -595,7 +595,7 @@
struct item_data *data;
struct attr attr;
char *label;
-
+ item_attr_rewind(item);
if (item->type==type_house_number) {
label=gui_internal_compose_item_address_string(item);
} else if (item_attr_get(item, attr_label, &attr)) {
@@ -674,7 +674,7 @@
gui_internal_widget_append(row,wi);
row->datai=data->dist;
gui_internal_widget_prepend(wtable,row);
- free(data->label);
+ g_free(data->label);
}
fh_deleteheap(fh);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2013-02-20 21:09:21
|
Revision: 5387
http://navit.svn.sourceforge.net/navit/?rev=5387&view=rev
Author: mdankov
Date: 2013-02-20 21:09:13 +0000 (Wed, 20 Feb 2013)
Log Message:
-----------
Add:core:Implement coord and attr rewind functions for navigation and tracking maps.
Modified Paths:
--------------
trunk/navit/navit/navigation.c
trunk/navit/navit/track.c
Modified: trunk/navit/navit/navigation.c
===================================================================
--- trunk/navit/navit/navigation.c 2013-02-19 21:14:38 UTC (rev 5386)
+++ trunk/navit/navit/navigation.c 2013-02-20 21:09:13 UTC (rev 5387)
@@ -2004,6 +2004,13 @@
return 1;
}
+static void
+navigation_map_item_coord_rewind(void *priv_data)
+{
+ struct map_rect_priv *this=priv_data;
+ this->ccount=0;
+}
+
static int
navigation_map_item_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
{
@@ -2167,10 +2174,18 @@
}
}
+static void
+navigation_map_item_attr_rewind(void *priv_data)
+{
+ struct map_rect_priv *priv = priv_data;
+ priv->debug_idx=0;
+ priv->attr_next=attr_navigation_short;
+}
+
static struct item_methods navigation_map_item_methods = {
- NULL,
+ navigation_map_item_coord_rewind,
navigation_map_item_coord_get,
- NULL,
+ navigation_map_item_attr_rewind,
navigation_map_item_attr_get,
};
@@ -2302,9 +2317,8 @@
}
}
}
- priv->ccount=0;
- priv->debug_idx=0;
- priv->attr_next=attr_navigation_short;
+ navigation_map_item_coord_rewind(priv);
+ navigation_map_item_attr_rewind(priv);
ret->id_lo=priv->itm->dest_count;
dbg(1,"type=%d\n", ret->type);
Modified: trunk/navit/navit/track.c
===================================================================
--- trunk/navit/navit/track.c 2013-02-19 21:14:38 UTC (rev 5386)
+++ trunk/navit/navit/track.c 2013-02-20 21:09:13 UTC (rev 5387)
@@ -968,6 +968,13 @@
char *str;
};
+static void
+tracking_map_item_coord_rewind(void *priv_data)
+{
+ struct map_rect_priv *this=priv_data;
+ this->ccount=0;
+}
+
static int
tracking_map_item_coord_get(void *priv_data, struct coord *c, int count)
{
@@ -992,6 +999,14 @@
return ret;
}
+static void
+tracking_map_item_attr_rewind(void *priv_data)
+{
+ struct map_rect_priv *this_=priv_data;
+ this_->debug_idx=0;
+ this_->attr_next=attr_debug;
+}
+
static int
tracking_map_item_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
{
@@ -1069,9 +1084,9 @@
}
static struct item_methods tracking_map_item_methods = {
- NULL,
+ tracking_map_item_coord_rewind,
tracking_map_item_coord_get,
- NULL,
+ tracking_map_item_attr_rewind,
tracking_map_item_attr_get,
};
@@ -1154,9 +1169,8 @@
else
priv->item.type=type_tracking_0;
dbg(1,"item %d %d points\n", priv->coord, priv->curr->street->count);
- priv->ccount=0;
- priv->attr_next=attr_debug;
- priv->debug_idx=0;
+ tracking_map_item_coord_rewind(priv);
+ tracking_map_item_attr_rewind(priv);
return ret;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2013-02-19 21:14:44
|
Revision: 5386
http://navit.svn.sourceforge.net/navit/?rev=5386&view=rev
Author: mdankov
Date: 2013-02-19 21:14:38 +0000 (Tue, 19 Feb 2013)
Log Message:
-----------
Fix:maptool:Properly put city districts (place=suburb) into the index.
Modified Paths:
--------------
trunk/navit/navit/maptool/osm.c
Modified: trunk/navit/navit/maptool/osm.c
===================================================================
--- trunk/navit/navit/maptool/osm.c 2013-02-18 12:14:23 UTC (rev 5385)
+++ trunk/navit/navit/maptool/osm.c 2013-02-19 21:14:38 UTC (rev 5386)
@@ -1761,7 +1761,7 @@
item_bin_add_attr_longlong(item_bin, attr_osm_nodeid, osmid_attr_value);
item_bin_add_attr_string(item_bin, attr_town_postal, postal);
item_bin_add_attr_string(item_bin, attr_county_name, attr_strings[attr_string_county_name]);
- item_bin_add_attr_string(item_bin, attr_town_name, attr_strings[attr_string_label]);
+ item_bin_add_attr_string(item_bin, item_is_district(*item_bin)?attr_district_name:attr_town_name, attr_strings[attr_string_label]);
item_bin_write(item_bin, osm->towns);
}
}
@@ -1974,7 +1974,10 @@
if (attrs[i].type != attr_none)
item_bin_add_attr(ib, &attrs[i]);
}
- item_bin_write_match(ib, attr_town_name, attr_town_name_match, 5, result->file);
+ if(item_bin_get_attr(ib, attr_district_name, NULL))
+ item_bin_write_match(ib, attr_district_name, attr_district_name_match, 5, result->file);
+ else
+ item_bin_write_match(ib, attr_town_name, attr_town_name_match, 5, result->file);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mar...@us...> - 2013-02-18 12:14:30
|
Revision: 5385
http://navit.svn.sourceforge.net/navit/?rev=5385&view=rev
Author: martin-s
Date: 2013-02-18 12:14:23 +0000 (Mon, 18 Feb 2013)
Log Message:
-----------
Fix:gui_internal:C standard
Modified Paths:
--------------
trunk/navit/navit/gui/internal/gui_internal_search.c
Modified: trunk/navit/navit/gui/internal/gui_internal_search.c
===================================================================
--- trunk/navit/navit/gui/internal/gui_internal_search.c 2013-02-17 21:07:58 UTC (rev 5384)
+++ trunk/navit/navit/gui/internal/gui_internal_search.c 2013-02-18 12:14:23 UTC (rev 5385)
@@ -303,9 +303,9 @@
wr->datai=2048;
} else if(name) {
int i;
- wr->datai=1024;
char *folded_name=linguistics_casefold(name);
char *folded_query=linguistics_casefold(wi->text);
+ wr->datai=1024;
for(i=0;wi && i<3 ;i++) {
char *exp=linguistics_expand_special(folded_name,i);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2013-02-17 21:08:05
|
Revision: 5384
http://navit.svn.sourceforge.net/navit/?rev=5384&view=rev
Author: mdankov
Date: 2013-02-17 21:07:58 +0000 (Sun, 17 Feb 2013)
Log Message:
-----------
Fix:maptool:Make expiremental feature to skip extra administrative subdivisions (svn 5380) work.
Modified Paths:
--------------
trunk/navit/navit/maptool/boundaries.c
trunk/navit/navit/maptool/osm.c
Modified: trunk/navit/navit/maptool/boundaries.c
===================================================================
--- trunk/navit/navit/maptool/boundaries.c 2013-02-17 19:35:31 UTC (rev 5383)
+++ trunk/navit/navit/maptool/boundaries.c 2013-02-17 21:07:58 UTC (rev 5384)
@@ -108,9 +108,9 @@
rolestr=member+read;
if(member_type==1) {
- if(!strcmp(rolestr,"admin_centre") || !strcmp(rolestr,"admin_center"))
- boundary->admin_centre=osm_id;
- }
+ if(!strcmp(rolestr,"admin_centre") || !strcmp(rolestr,"admin_center"))
+ boundary->admin_centre=osm_id;
+ }
if(member_type==2) {
enum geom_poly_segment_type role;
if (!strcmp(rolestr,"outer") || !strcmp(rolestr,"exclave"))
Modified: trunk/navit/navit/maptool/osm.c
===================================================================
--- trunk/navit/navit/maptool/osm.c 2013-02-17 19:35:31 UTC (rev 5383)
+++ trunk/navit/navit/maptool/osm.c 2013-02-17 21:07:58 UTC (rev 5384)
@@ -1837,15 +1837,14 @@
if (match) {
if (match && match->country && match->country->admin_levels) {
- char *nodeid=item_bin_get_attr(ib, attr_osm_nodeid, NULL);
- long long node_id;
+ long long *nodeid=item_bin_get_attr(ib, attr_osm_nodeid, NULL);
+ long long node_id=0;
int end=strlen(match->country->admin_levels)+3;
int a;
- int max_adm_level=end;
+ int max_adm_level=0;
if(nodeid)
- if(sscanf(nodeid,LONGLONG_FMT,&node_id)<1)
- node_id=0;
+ node_id=*nodeid;
l=matches;
while (l) {
@@ -1889,7 +1888,7 @@
/* Administrative centres are not to be contained in their own districts. */
if(experimental && max_adm_level>0)
- for(a=end-1;a>max_adm_level;a--)
+ for(a=end-1;a>max_adm_level && a>2;a--)
attrs[a-2].type=type_none;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2013-02-17 19:35:37
|
Revision: 5383
http://navit.svn.sourceforge.net/navit/?rev=5383&view=rev
Author: mdankov
Date: 2013-02-17 19:35:31 +0000 (Sun, 17 Feb 2013)
Log Message:
-----------
Fix:maptool:Really remove duplicate of attribute used as key (redo svn5372).
Modified Paths:
--------------
trunk/navit/navit/maptool/itembin.c
Modified: trunk/navit/navit/maptool/itembin.c
===================================================================
--- trunk/navit/navit/maptool/itembin.c 2013-02-17 19:02:24 UTC (rev 5382)
+++ trunk/navit/navit/maptool/itembin.c 2013-02-17 19:35:31 UTC (rev 5383)
@@ -473,10 +473,12 @@
item_bin_write_match(struct item_bin *ib, enum attr_type type, enum attr_type match, int maxdepth, FILE *out)
{
char *word=item_bin_get_attr(ib, type, NULL);
- int i,words=0,len=ib->len;
+ int i,words=0,len;
char tilename[32]="";
+
if (!word)
return;
+
if(maxdepth && ib->clen>0) {
struct rect r;
struct coord *c=(struct coord *)(ib+1);
@@ -489,14 +491,12 @@
/* insert attr_tile_name attribute before the attribute used as alphabetical key (of type type) */
if(maxdepth) {
- struct attr_bin *a=item_bin_get_attr_bin(ib, type, NULL);
- char *s=g_strdup((char*)(a+1));
- item_bin_remove_attr(ib,a);
item_bin_add_attr_string(ib, attr_tile_name, tilename);
- item_bin_add_attr_string(ib, type, s);
- g_free(s);
- len=ib->len;
+ item_bin_add_attr_string(ib, type, word);
+ item_bin_remove_attr(ib,word);
+ word=item_bin_get_attr(ib, type, NULL);
}
+ len=ib->len;
do {
if (linguistics_search(word)) {
for (i = 0 ; i < 3 ; i++) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2013-02-17 19:02:36
|
Revision: 5382
http://navit.svn.sourceforge.net/navit/?rev=5382&view=rev
Author: mdankov
Date: 2013-02-17 19:02:24 +0000 (Sun, 17 Feb 2013)
Log Message:
-----------
Add:gui_internal:Move most relevant results in Town search to the top of the list.
Modified Paths:
--------------
trunk/navit/navit/gui/internal/gui_internal_search.c
Modified: trunk/navit/navit/gui/internal/gui_internal_search.c
===================================================================
--- trunk/navit/navit/gui/internal/gui_internal_search.c 2013-02-17 11:22:28 UTC (rev 5381)
+++ trunk/navit/navit/gui/internal/gui_internal_search.c 2013-02-17 19:02:24 UTC (rev 5382)
@@ -12,6 +12,7 @@
#include "search.h"
#include "country.h"
#include "track.h"
+#include "linguistics.h"
#include "gui_internal.h"
#include "gui_internal_widget.h"
#include "gui_internal_priv.h"
@@ -85,6 +86,7 @@
sa=removecase(a->text);
sb=removecase(b->text);
r=strcmp(sa,sb);
+ dbg(1,"%s %s %d\n",sa,sb,r);
g_free(sa);
g_free(sb);
return r;
@@ -194,7 +196,7 @@
GList *l;
static char possible_keys[256]="";
struct widget *wi=NULL;
- struct widget *wr;
+ struct widget *wr, *wb;
res=search_list_get_result(this->sl);
if (res) {
@@ -288,59 +290,77 @@
text=g_strdup_printf("%s %s", res->street->name, name);
text2=town_str(res, 3, 0);
}
+
dbg(1,"res->country->flag=%s\n", res->country->flag);
wr=gui_internal_widget_table_row_new(this, gravity_left|orientation_horizontal|flags_fill);
- if (!text2) {
- wr->text=g_strdup(text);
- gui_internal_widget_insert_sorted(search_list, wr, gui_internal_search_cmp);
- gui_internal_widget_append(wr,
- wc=gui_internal_button_new_with_callback(this, text,
- image_new_xs(this, res->country->flag),
- gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_position, param));
- } else {
- struct widget *wb;
- wr->text=g_strdup_printf("%s %s",text,text2);
+ if (!text2)
+ wr->text=g_strdup(text);
+ else
+ wr->text=g_strdup_printf("%s %s",name,text2);
+
+ if (! strcmp(wm_name,"House number") && !res->street->name) {
+ wr->datai=2048;
+ } else if(name) {
+ int i;
+ wr->datai=1024;
+ char *folded_name=linguistics_casefold(name);
+ char *folded_query=linguistics_casefold(wi->text);
- if (! strcmp(wm_name,"House number") && !res->street->name) {
- wr->datai=1000;
- } else if(name) {
- if(!wi)
- dbg(0,"search text widget is NULL\n");
- if(wi && strlen(name)==strlen(wi->text)) {
- dbg(1,"xact %s %s\n",name, wi->text);
- wr->datai=-1000;
- } else {
- dbg(1,"not xact %s %s\n",name, wi->text);
- wr->datai=0;
+ for(i=0;wi && i<3 ;i++) {
+ char *exp=linguistics_expand_special(folded_name,i);
+ char *p;
+ if(!exp)
+ continue;
+ if(!strcmp(exp,folded_query)) {
+ dbg(1,"exact match for the whole string %s\n", exp);
+ wr->datai=0;
+ g_free(exp);
+ break;
+ }
+ if((p=strstr(exp,folded_query))!=NULL) {
+ p+=strlen(folded_query);
+ if(!*p||strchr(" -/()",*p)) {
+ dbg(1,"exact matching word found inside string %s\n",exp);
+ wr->datai=512;
}
}
- gui_internal_widget_insert_sorted(search_list, wr, gui_internal_search_cmp);
-
- wc=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(wr, wc);
+ g_free(exp);
+ }
+ g_free(folded_name);
+ g_free(folded_query);
+ }
+ gui_internal_widget_insert_sorted(search_list, wr, gui_internal_search_cmp);
+ if(text2) {
+ wc=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(wr, wc);
gui_internal_widget_append(wc, gui_internal_image_new(this, image_new_xs(this, res->country->flag)));
- wb=gui_internal_box_new(this, gravity_left_center|orientation_vertical|flags_fill);
- gui_internal_widget_append(wc, wb);
- gui_internal_widget_append(wb, gui_internal_label_new(this, text));
- gui_internal_widget_append(wb, gui_internal_label_font_new(this, text2, 1));
- wc->func=gui_internal_cmd_position;
- wc->data=param;
- wc->state |= STATE_SENSITIVE;
- wc->speech=g_strdup(text);
- }
- wc->name=g_strdup(name);
- if (res->c)
- wc->c=*res->c;
- wc->selection_id=res->id;
- if (item)
- wc->item=*item;
- gui_internal_widget_pack(this, search_list);
- l=g_list_last(this->root.children);
- graphics_draw_mode(this->gra, draw_mode_begin);
- gui_internal_widget_render(this, l->data);
- graphics_draw_mode(this->gra, draw_mode_end);
+ wb=gui_internal_box_new(this, gravity_left_center|orientation_vertical|flags_fill);
+ gui_internal_widget_append(wc, wb);
+ gui_internal_widget_append(wb, gui_internal_label_new(this, text));
+ gui_internal_widget_append(wb, gui_internal_label_font_new(this, text2, 1));
+ wc->func=gui_internal_cmd_position;
+ wc->data=param;
+ wc->state |= STATE_SENSITIVE;
+ wc->speech=g_strdup(text);
+ } else {
+ gui_internal_widget_append(wr,
+ wc=gui_internal_button_new_with_callback(this, text,
+ image_new_xs(this, res->country->flag),
+ gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_position, param));
+ }
+ wc->name=g_strdup(name);
+ if (res->c)
+ wc->c=*res->c;
+ wc->selection_id=res->id;
+ if (item)
+ wc->item=*item;
+ gui_internal_widget_pack(this, search_list);
+ l=g_list_last(this->root.children);
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ gui_internal_widget_render(this, l->data);
+ graphics_draw_mode(this->gra, draw_mode_end);
g_free(text);
g_free(text2);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mar...@us...> - 2013-02-17 11:22:39
|
Revision: 5381
http://navit.svn.sourceforge.net/navit/?rev=5381&view=rev
Author: martin-s
Date: 2013-02-17 11:22:28 +0000 (Sun, 17 Feb 2013)
Log Message:
-----------
Add:binding_python:Implement missing function
Modified Paths:
--------------
trunk/navit/navit/binding/python/navit.c
Modified: trunk/navit/navit/binding/python/navit.c
===================================================================
--- trunk/navit/navit/binding/python/navit.c 2013-02-16 22:41:22 UTC (rev 5380)
+++ trunk/navit/navit/binding/python/navit.c 2013-02-17 11:22:28 UTC (rev 5381)
@@ -27,6 +27,16 @@
} navitObject;
static PyObject *
+navit_set_attr_py(navitObject *self, PyObject *args)
+{
+ PyObject *attr;
+ if (!PyArg_ParseTuple(args, "O!", &attr_Type, &attr))
+ return NULL;
+ navit_set_attr(self->navit, attr_py_get(attr));
+ Py_RETURN_NONE;
+}
+
+static PyObject *
navit_get_attr_py(navitObject *self, PyObject *args)
{
char *name;
@@ -87,6 +97,7 @@
static PyMethodDef navit_methods[] = {
+ {"set_attr", (PyCFunction) navit_set_attr_py, METH_VARARGS },
{"get_attr", (PyCFunction) navit_get_attr_py, METH_VARARGS },
{"set_center", (PyCFunction) navit_set_center_py, METH_VARARGS },
{"set_destination", (PyCFunction) navit_set_destination_py, METH_VARARGS },
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|