/[zanavi_public1]/navit/navit/mvt_tiles_full_zvt.h
ZANavi

Diff of /navit/navit/mvt_tiles_full_zvt.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 50 Revision 51
33 33
34/* 34/*
35==================================================================== 35====================================================================
36*/ 36*/
37 37
38typedef unsigned char uint8_t;
39typedef unsigned int uint32_t;
40
41
38struct __attribute__((__packed__)) zvt_header 42struct __attribute__((__packed__)) zvt_header
39{ 43{
40 uint8_t signature[3]; 44 uint8_t signature[3];
41 unsigned char zoom; 45 unsigned char zoom;
42}; 46};
43 47
44 48
45struct __attribute__((__packed__)) wkb_header 49struct wkb_header
46{ 50{
47 // uint8_t is_little_endian; // 0 or 1 51 // uint8_t is_little_endian; // 0 or 1
48 uint8_t type; 52 uint8_t type;
49}; 53};
50 54
58{ 62{
59 int x; 63 int x;
60 int y; 64 int y;
61}; 65};
62 66
67void loop_mapnik_tiles(double lat_lt, double lon_lt, double lat_cn, double lon_cn, double lat_rb, double lon_rb, int mapnik_zoom, const char* basedir, struct displaylist *display_list);
68void get_mapnik_tilenumber(struct mapnik_tile *mt, double lat, double lon, int mapnik_zoom);
69void get_mapniktile_2_geo(int tile_x, int tile_y, int zoom, struct coord_geo *g);
70void draw_water_tile_new(int mapnik_zoom, int tile_x, int tile_y, struct displaylist *display_list);
71
72
63 73
64/* 74/*
65==================================================================== 75====================================================================
66*/ 76*/
67 77
68#ifdef _MVT_LITTLEENDIAN_ 78#ifdef _MVT_LITTLEENDIAN_
79
80#if 0
69uint32_t swap_endian32(uint32_t num) 81uint32_t swap_endian32(uint32_t num)
70{ 82{
71 return ((num>>24)&0xff) | // move byte 3 to byte 0 83 return ((num>>24)&0xff) | // move byte 3 to byte 0
72 ((num<<8)&0xff0000) | // move byte 1 to byte 2 84 ((num<<8)&0xff0000) | // move byte 1 to byte 2
73 ((num>>8)&0xff00) | // move byte 2 to byte 1 85 ((num>>8)&0xff00) | // move byte 2 to byte 1
85 | (((x) & 0x0000000000ff0000ull) << 24) 97 | (((x) & 0x0000000000ff0000ull) << 24)
86 | (((x) & 0x000000000000ff00ull) << 40) 98 | (((x) & 0x000000000000ff00ull) << 40)
87 | (((x) & 0x00000000000000ffull) << 56)); 99 | (((x) & 0x00000000000000ffull) << 56));
88} 100}
89 101
102#endif
103
90#else 104#else
91#define swap_endian32(x) x 105#define swap_endian32(x) x
92#define swap_endian64(x) x 106#define swap_endian64(x) x
93#endif 107#endif
94 108
99// for zlib ------------ 113// for zlib ------------
100 114
101const char *wkb_feature_type[] = 115const char *wkb_feature_type[] =
102{ 116{
103"Geometry", // 0 117"Geometry", // 0
104"Point", 118"Point", // 1
105"LineString", 119"LineString",
106"Polygon", // 3 120"Polygon", // 3
107"MultiPoint", 121"MultiPoint", // 4
108"MultiLineString", 122"MultiLineString",
109"MultiPolygon", // 6 123"MultiPolygon", // 6
110"GeometryCollection", 124"GeometryCollection", // 7
111"CircularString", 125"CircularString",
112"CompoundCurve", 126"CompoundCurve",
113"CurvePolygon", // 10 127"CurvePolygon", // 10
114"MultiCurve", // 11 128"MultiCurve", // 11
115"MultiSurface", 129"MultiSurface",
150} 164}
151 165
152void get_mapniktile_2_geo(int tile_x, int tile_y, int zoom, struct coord_geo *g) 166void get_mapniktile_2_geo(int tile_x, int tile_y, int zoom, struct coord_geo *g)
153{ 167{
154 float n; 168 float n;
155 double lat; 169 // double lat;
156 double lon; 170 // double lon;
157 n = pow(2, zoom); 171 n = pow(2, zoom);
158 g->lng = tile_x / n * 360.0 - 180.0; 172 g->lng = tile_x / n * 360.0 - 180.0;
159 g->lat = MVT_RAD_TO_DEG * ( atan( sinh( MVT_M_PI * ( 1 - 2 * tile_y / n )))); 173 g->lat = MVT_RAD_TO_DEG * ( atan( sinh( MVT_M_PI * ( 1 - 2 * tile_y / n ))));
160} 174}
161 175
202 transform_from_geo(projection_mg, &g_temp, c_temp); 216 transform_from_geo(projection_mg, &g_temp, c_temp);
203 217
204 count = transform(global_navit->trans, projection_mg, c_ring, p_ring, count, 0, 0, NULL); 218 count = transform(global_navit->trans, projection_mg, c_ring, p_ring, count, 0, 0, NULL);
205 gra->meth.draw_polygon(gra->priv, gra->gc[0]->priv, p_ring, count); 219 gra->meth.draw_polygon(gra->priv, gra->gc[0]->priv, p_ring, count);
206 220
207
208} 221}
209 222
210 223
224
225
226
227// vXolatile
228// __aXttribute__((optimize("O0")))
229
230void dummy_sub_against_crash(volatile uint32_t *x, volatile int *a)
231{
232 *a = (int)*x;
233}
234
235
211void decode_mvt_tile(const char* basedir, FILE *mapfile, uint32_t compr_tilesize, int mapnik_zoom, int tile_x, int tile_y, struct displaylist *display_list) 236void decode_mvt_tile(const char* basedir, FILE *mapfile, uint32_t compr_tilesize, int mapnik_zoom, int tile_x, int tile_y, struct displaylist *display_list)
212{ 237{
213 238
214 // dbg(0,"decode_mvt_tile:--ENTER--\n"); 239 dbg(0,"decode_mvt_tile:--ENTER--(tilex=%d,tiley=%d)\n", tile_x, tile_y);
215 240
216 struct wkb_header *buffer_wkb_header = NULL; 241 struct wkb_header *buffer_wkb_header = NULL;
217 void *buffer_compressed = NULL; 242 volatile char *buffer_compressed = NULL;
243 volatile char *buffer_uncpr = NULL;
218 Bytef *buffer_uncpr = NULL; 244 // Bytef *buffer_uncpr = NULL;
245
219 uLongf buffer_uncpr_len = -1; 246 uLongf buffer_uncpr_len = -1;
220 unsigned long buffer_uncpr_end = -1; 247 // unsigned long buffer_uncpr_end = -1;
221 int res = -1; 248 int res = -1;
222 uint32_t *feature_count = NULL; 249 uint32_t *feature_count = NULL;
223 // uint32_t *feature_len = NULL; 250 // uint32_t *feature_len = NULL;
224 uint32_t numrings = -1; 251 uint32_t numrings = -1;
225 uint32_t numpolys = -1; 252 // uint32_t numpolys = -1;
253
254 volatile char *buffer_uncpr_pos = NULL;
255 // void *buffer_uncpr_pos_save = NULL;
226 Bytef *buffer_uncpr_pos = NULL; 256 // Bytef *buffer_uncpr_pos = NULL;
227 Bytef *buffer_uncpr_pos_save = NULL; 257 // Bytef *buffer_uncpr_pos_save = NULL;
258
228 int i = -1; 259 int i = -1;
229 int j = -1; 260 int j = -1;
230 int k = -1; 261 int k = -1;
231 int l = -1; 262 int l = -1;
232 int num_coords = 0; 263 int num_coords = 0;
233 uint32_t *n = NULL; 264 uint32_t *n = NULL;
234 double lat = 0; 265 // double lat = 0;
235 uint64_t *lat_p = NULL; 266 // uint64_t *lat_p = NULL;
236 double lon = 0; 267 // double lon = 0;
237 uint64_t *lon_p = NULL; 268 // uint64_t *lon_p = NULL;
238 struct wkb_point *point1 = NULL; 269 volatile struct wkb_point *point1 = NULL;
239 struct coord point2; 270 // struct coord point2;
240 271
241
242 {
243 {
244 272
245 // -------------- GFX ----------------- 273 // -------------- GFX -----------------
246 // -------------- GFX ----------------- 274 // -------------- GFX -----------------
247 // -------------- GFX ----------------- 275 // -------------- GFX -----------------
248 struct point *p_ring = malloc(sizeof(struct point) * 20000); // 20000 points in 1 polygon max ?! 276 volatile struct point *p_ring = g_malloc0(sizeof(struct point) * 20000); // 20000 points in 1 polygon max ?!
249 struct coord *c_ring = malloc(sizeof(struct coord) * 20000); // 20000 coords in 1 polygon max ?! 277 volatile struct coord *c_ring = g_malloc0(sizeof(struct coord) * 20000); // 20000 coords in 1 polygon max ?!
250 struct coord *c_temp = c_ring; 278 volatile struct coord *c_temp = c_ring;
251 struct coord_geo g_temp; 279 // struct coord_geo g_temp;
252 struct graphics *gra = display_list->dc.gra; 280 struct graphics *gra = display_list->dc.gra;
253 // struct graphics_gc *gc = display_list->dc.gc; 281 // struct graphics_gc *gc = display_list->dc.gc;
254 struct color custom_color; 282 struct color custom_color;
255 int count = 0; 283 int count = 0;
256 284
261 289
262 // -------------- GFX ----------------- 290 // -------------- GFX -----------------
263 // -------------- GFX ----------------- 291 // -------------- GFX -----------------
264 // -------------- GFX ----------------- 292 // -------------- GFX -----------------
265 293
266 // dbg(0, "compressed len:%ld\n", (long)compr_tilesize); 294 dbg(0, "compressed len:%ld\n", (long)compr_tilesize);
267 // fprintf(stderr, "0x%08x\n", compr_tilesize); 295 // fprintf(stderr, "0x%08x\n", compr_tilesize);
268 296
269 buffer_compressed = malloc((size_t)compr_tilesize); 297 buffer_compressed = g_malloc0((size_t)compr_tilesize);
270 fread(buffer_compressed, compr_tilesize, 1, mapfile); 298 fread(buffer_compressed, compr_tilesize, 1, mapfile);
271 299
272 buffer_uncpr_len = compr_tilesize * 20; 300 buffer_uncpr_len = compr_tilesize * 20;
273 buffer_uncpr_end = buffer_uncpr + buffer_uncpr_len; 301 // buffer_uncpr_end = buffer_uncpr + buffer_uncpr_len;
274 buffer_uncpr = malloc((size_t)buffer_uncpr_len); 302 buffer_uncpr = g_malloc0((size_t)buffer_uncpr_len);
275 303
304 // int uncompress(Bytef * dest, uLongf * destLen, const Bytef * source, uLong sourceLen);
276 res = uncompress(buffer_uncpr, &buffer_uncpr_len, buffer_compressed, compr_tilesize); 305 res = uncompress((Bytef *)buffer_uncpr, &buffer_uncpr_len, (const Bytef *)buffer_compressed, compr_tilesize);
306
307 // use different buffer ----------
308 char *buffer_uncpr_2 = g_malloc0((size_t)buffer_uncpr_len);
309 memcpy(buffer_uncpr_2, buffer_uncpr, (size_t)buffer_uncpr_len);
310 g_free(buffer_uncpr);
311 buffer_uncpr = buffer_uncpr_2;
312 // use different buffer ----------
313
277 314
278 if (res == Z_BUF_ERROR) 315 if (res == Z_BUF_ERROR)
279 { 316 {
280 dbg(0, "res=Z_BUF_ERROR\n"); 317 dbg(0, "res=Z_BUF_ERROR\n");
281 } 318 }
291 { 328 {
292 dbg(0, "res=Z_DATA_ERROR\n"); 329 dbg(0, "res=Z_DATA_ERROR\n");
293 } 330 }
294 else 331 else
295 { 332 {
296 // dbg(0, "res=%d\n", res); 333 dbg(0, "res=%d\n", res);
297 334
298 // dbg(0, "un-compressed len:%ld\n", (long)buffer_uncpr_len); 335 dbg(0, "un-compressed len:%ld\n", (long)buffer_uncpr_len);
299 336
300 // dbg(0, "001\n"); 337 // dbg(0, "001\n");
301 buffer_uncpr_pos = buffer_uncpr; 338 buffer_uncpr_pos = buffer_uncpr;
302 buffer_uncpr_pos = buffer_uncpr_pos + 1; // skip to count 339 buffer_uncpr_pos = buffer_uncpr_pos + 1; // skip to count
303 // dbg(0, "002\n"); 340 // dbg(0, "002\n");
341 // feature_count = (uint32_t *)buffer_uncpr_pos;
304 feature_count = (void *)buffer_uncpr_pos; 342 feature_count = (void *)buffer_uncpr_pos;
305 // dbg(0, "003\n"); 343 // dbg(0, "003\n");
306 // ZZZ // *feature_count = swap_endian32(*feature_count); 344 // ZZZ // *feature_count = swap_endian32(*feature_count);
307 // dbg(0, "buffer_uncpr_pos=%p\n", buffer_uncpr_pos); 345 // dbg(0, "buffer_uncpr_pos=%p\n", buffer_uncpr_pos);
308 // dbg(0, "feature_count=%p\n", feature_count); 346 // dbg(0, "feature_count=%p\n", feature_count);
309 // dbg(0, "0x%08x\n", *feature_count); 347 // dbg(0, "0x%08x\n", *feature_count);
310 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t); 348 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
311 // dbg(0, "004\n"); 349 // dbg(0, "004\n");
312 // dbg(0, "geometry_count:%d\n", (int)*feature_count); 350 dbg(0, "geometry_count:%d\n", (int)*feature_count);
313 // dbg(0, "005\n"); 351 // dbg(0, "005\n");
314 // fprintf(stderr, "sizeof feature_count:%d\n", sizeof(uint32_t)); 352 // fprintf(stderr, "sizeof feature_count:%d\n", sizeof(uint32_t));
315 353
316 int ff_count = (int)*feature_count; 354 int ff_count = (int)(*feature_count);
317 355
318 // loop through geometries 356 // loop through geometries
319 for(i=0;i<ff_count;i++) 357 for(i=0;i<ff_count;i++)
320 { 358 {
321 // dbg(0, "feature#:%d\n", i); 359 dbg(0, "feature#:%d\n", i);
322 360
323/* 361/*
324 feature_len = (void *)buffer_uncpr_pos; 362 feature_len = (void *)buffer_uncpr_pos;
325 // ZZZ // *feature_len = swap_endian32(*feature_len); 363 // ZZZ // *feature_len = swap_endian32(*feature_len);
326 fprintf(stderr, "0x%08x\n", *feature_len); 364 fprintf(stderr, "0x%08x\n", *feature_len);
327 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t); 365 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
328 // dbg(0, " feature_len:%d\n", (int)*feature_len); 366 dbg(0, " feature_len:%d\n", (int)*feature_len);
329*/ 367*/
330 368
331 369
332 // ======================= 370 // =======================
333 buffer_uncpr_pos_save = buffer_uncpr_pos; // save position 371 // buffer_uncpr_pos_save = (void *)buffer_uncpr_pos; // save position
334 // ======================= 372 // =======================
335 373
336 374
337 // dbg(0, "006\n"); 375 // dbg(0, "006\n");
338 buffer_wkb_header = (void *)buffer_uncpr_pos; 376 buffer_wkb_header = (struct wkb_header *)buffer_uncpr_pos;
339 // dbg(0, " is_little_endian:%d\n", (int)buffer_wkb_header->is_little_endian); 377 // dbg(0, " is_little_endian:%d\n", (int)buffer_wkb_header->is_little_endian);
340 // fprintf(stderr, " 0x%08x\n", (Bytef)buffer_wkb_header->is_little_endian); 378 // fprintf(stderr, " 0x%08x\n", (Bytef)buffer_wkb_header->is_little_endian);
341 379
380
381 // dbg(0, "bupp:001:buffer_uncpr_pos=%p so=%d\n", buffer_uncpr_pos, sizeof(struct wkb_header));
342 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(struct wkb_header); 382 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(struct wkb_header);
383 // dbg(0, "bupp:002:buffer_uncpr_pos=%p\n", buffer_uncpr_pos);
343 384
344 // dbg(0, " feature type:%d\n", (int)buffer_wkb_header->type); 385 dbg(0, " feature type:%d\n", (int)buffer_wkb_header->type);
345 // dbg(0, " feature type:%s\n", wkb_feature_type[(int)buffer_wkb_header->type]); 386 // dbg(0, " feature type:%s\n", wkb_feature_type[(int)buffer_wkb_header->type]);
346 387
347 388
348 if (buffer_wkb_header->type == 3) 389 if (buffer_wkb_header->type == 3)
349 { 390 {
350 // Polygon -------------------------------------------- 391 // Polygon --------------------------------------------
351 // Polygon -------------------------------------------- 392 // Polygon --------------------------------------------
352 // Polygon -------------------------------------------- 393 // Polygon --------------------------------------------
394 // n = (uint32_t *)buffer_uncpr_pos;
353 n = (void *)buffer_uncpr_pos; 395 n = (void *)buffer_uncpr_pos;
354 numrings = *n; 396 numrings = *n;
397
398 // dbg(0, " xxxxx\n");
399 // dbg(0, " xxxxx\n");
400
355 // dbg(0, " numRings:%d\n", (int)*n); 401 dbg(0, " numRings(1):%d\n", (int)*n);
402
403 // dbg(0, " xxxxx\n");
404 // dbg(0, " xxxxx\n");
405 // dbg(0, " xxxxx\n");
406
407 // dbg(0, "bupp:003a:so=%d\n", sizeof(uint32_t));
408 // dbg(0, "bupp:003b:buffer_uncpr_pos=%p so=%d\n", buffer_uncpr_pos, sizeof(uint32_t));
356 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t); 409 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
410 // dbg(0, "bupp:004:buffer_uncpr_pos=%p\n", buffer_uncpr_pos);
357 411
358 412
413
414 // dbg(0, "006aa.001\n");
359 415
360 416
361 // -------------- GFX ----------------- 417 // -------------- GFX -----------------
362 // -------------- GFX ----------------- 418 // -------------- GFX -----------------
363 // -------------- GFX ----------------- 419 // -------------- GFX -----------------
369 custom_color.g = 200 << 8; 425 custom_color.g = 200 << 8;
370 custom_color.b = 234 << 8; 426 custom_color.b = 234 << 8;
371 427
372 custom_color.a = 0xffff; 428 custom_color.a = 0xffff;
373 429
430 // dbg(0, "006aa.002\n");
431
374 // graphics_gc_set_foreground(gra->gc[0], &custom_color); 432 // graphics_gc_set_foreground(gra->gc[0], &custom_color);
375 gra->gc[0]->meth.gc_set_foreground(gra->gc[0]->priv, &custom_color); 433 gra->gc[0]->meth.gc_set_foreground(gra->gc[0]->priv, &custom_color);
376 // -------------- GFX ----------------- 434 // -------------- GFX -----------------
377 // -------------- GFX ----------------- 435 // -------------- GFX -----------------
378 // -------------- GFX ----------------- 436 // -------------- GFX -----------------
379 437
380 438
439 // dbg(0, "006aa.003\n");
381 440
382 for(k=0;k<numrings;k++) 441 for(k=0;k<numrings;k++)
383 { 442 {
384 443
444 // dbg(0, "006aa.004:%d\n", k);
445
446
447 // n = (uint32_t *)buffer_uncpr_pos;
385 n = (void *)buffer_uncpr_pos; 448 n = (void *)buffer_uncpr_pos;
449 // dbg(0, "006aa.005\n");
386 num_coords = (int)*n; 450 num_coords = (int)(*n);
451 // dbg(0, "006aa.006\n");
387 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t); 452 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
453 // dbg(0, "006aa.007\n");
388 454
389 455
390 // -------------- GFX ----------------- 456 // -------------- GFX -----------------
391 // -------------- GFX ----------------- 457 // -------------- GFX -----------------
392 // -------------- GFX ----------------- 458 // -------------- GFX -----------------
393 count = 0; 459 count = 0;
460 // dbg(0, "006aa.008\n");
394 c_temp = c_ring; 461 c_temp = c_ring;
462 // dbg(0, "006aa.009\n");
395 // -------------- GFX ----------------- 463 // -------------- GFX -----------------
396 // -------------- GFX ----------------- 464 // -------------- GFX -----------------
397 // -------------- GFX ----------------- 465 // -------------- GFX -----------------
398 466
399 467
400 // dbg(0, " num of coords:%d\n", num_coords); 468 dbg(0, " num of coords:%d\n", num_coords);
401 469
402 for(j=0;j<num_coords;j++) 470 for(j=0;j<num_coords;j++)
403 { 471 {
404 // fprintf(stderr, " size of double:%d\n", sizeof(lat)); 472 // fprintf(stderr, " size of double:%d\n", sizeof(lat));
405 473
452 520
453 // Polygon -------------------------------------------- 521 // Polygon --------------------------------------------
454 // Polygon -------------------------------------------- 522 // Polygon --------------------------------------------
455 // Polygon -------------------------------------------- 523 // Polygon --------------------------------------------
456 } 524 }
525 else if (buffer_wkb_header->type == 7)
526 {
527 // GeometryCollection ---------------------------------
528 // GeometryCollection ---------------------------------
529 // GeometryCollection ---------------------------------
530
531
532 // inside:
533 // Point:1 --> *ignore*
534 // Polygon:3 --> process
535
536 int numgeoms; dummy_sub_against_crash((void *) buffer_uncpr_pos, &numgeoms);
537
538 dbg(0, " numgeoms:%d\n", numgeoms);
539 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
540
541
542 int ge;
543 for(ge=0;ge<numgeoms;ge++)
544 {
545 dbg(0, " geom#:%d\n", ge);
546
547 struct wkb_header *buffer_wkb_header = NULL;
548 buffer_wkb_header = (struct wkb_header *)buffer_uncpr_pos;
549 dbg(0, " geom type:%d\n", (int)buffer_wkb_header->type);
550
551 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(struct wkb_header);
552
553 if (buffer_wkb_header->type == 3)
554 {
555 // Polygon --------------------------------------------
556 // Polygon --------------------------------------------
557 // Polygon --------------------------------------------
558 // n = (uint32_t *)buffer_uncpr_pos;
559 n = (void *)buffer_uncpr_pos;
560 numrings = *n;
561
562 // dbg(0, " xxxxx\n");
563 // dbg(0, " xxxxx\n");
564
565 dbg(0, " numRings(1):%d\n", (int)*n);
566
567 // dbg(0, " xxxxx\n");
568 // dbg(0, " xxxxx\n");
569 // dbg(0, " xxxxx\n");
570
571 // dbg(0, "bupp:003a:so=%d\n", sizeof(uint32_t));
572 // dbg(0, "bupp:003b:buffer_uncpr_pos=%p so=%d\n", buffer_uncpr_pos, sizeof(uint32_t));
573 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
574 // dbg(0, "bupp:004:buffer_uncpr_pos=%p\n", buffer_uncpr_pos);
575
576
577
578 // dbg(0, "006aa.001\n");
579
580
581 // -------------- GFX -----------------
582 // -------------- GFX -----------------
583 // -------------- GFX -----------------
584 count = 0;
585
586 // water color: #82c8ea
587 // 130, 200, 234
588 custom_color.r = 130 << 8;
589 custom_color.g = 200 << 8;
590 custom_color.b = 234 << 8;
591
592 custom_color.a = 0xffff;
593
594 // dbg(0, "006aa.002\n");
595
596 // graphics_gc_set_foreground(gra->gc[0], &custom_color);
597 gra->gc[0]->meth.gc_set_foreground(gra->gc[0]->priv, &custom_color);
598 // -------------- GFX -----------------
599 // -------------- GFX -----------------
600 // -------------- GFX -----------------
601
602
603 // dbg(0, "006aa.003\n");
604
605 for(k=0;k<numrings;k++)
606 {
607
608 // dbg(0, "006aa.004:%d\n", k);
609
610
611 // n = (uint32_t *)buffer_uncpr_pos;
612 n = (void *)buffer_uncpr_pos;
613 // dbg(0, "006aa.005\n");
614 num_coords = (int)(*n);
615 // dbg(0, "006aa.006\n");
616 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
617 // dbg(0, "006aa.007\n");
618
619
620 // -------------- GFX -----------------
621 // -------------- GFX -----------------
622 // -------------- GFX -----------------
623 count = 0;
624 // dbg(0, "006aa.008\n");
625 c_temp = c_ring;
626 // dbg(0, "006aa.009\n");
627 // -------------- GFX -----------------
628 // -------------- GFX -----------------
629 // -------------- GFX -----------------
630
631
632 dbg(0, " num of coords:%d\n", num_coords);
633
634 for(j=0;j<num_coords;j++)
635 {
636 // fprintf(stderr, " size of double:%d\n", sizeof(lat));
637
638 point1 = (void *)buffer_uncpr_pos;
639 c_temp->x = point1->x;
640 c_temp->y = point1->y;
641 // ** // mvt_merc2lonlat(&point2);
642 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(struct wkb_point);
643
644 // dbg(0, " lat,lon [%d] %lf %lf\n", j, point2.x, point2.y);
645 //fprintf(stderr, "%016llx\n", (long long unsigned int)point1->x);
646 //mvt_print_binary_64((uint32_t)point1->x);
647 //fprintf(stderr, "%016llx\n", (long long unsigned int)point1->y);
648 //mvt_print_binary_64((uint32_t)point1->y);
649
650 // -------------- GFX -----------------
651 // -------------- GFX -----------------
652 // -------------- GFX -----------------
653 // ** // g_temp.lat = point2.y;
654 // ** // g_temp.lng = point2.x;
655 // ** // transform_from_geo(projection_mg, &g_temp, c_temp);
656 count++;
657 c_temp++;
658 // -------------- GFX -----------------
659 // -------------- GFX -----------------
660 // -------------- GFX -----------------
661
662
663 }
664
665
666 // -------------- GFX -----------------
667 // -------------- GFX -----------------
668 // -------------- GFX -----------------
669 if (count > 0)
670 {
671 count = transform(global_navit->trans, projection_mg, c_ring, p_ring, count, 0, 0, NULL);
672
673 //Z//graphics_draw_polygon_clipped(gra, display_list->dc.gc, p_ring, count);
674 gra->meth.draw_polygon(gra->priv, gra->gc[0]->priv, p_ring, count);
675 //Z//gra->meth.draw_polygon(gra, display_list->dc.gc, p_ring, count);
676 }
677 // -------------- GFX -----------------
678 // -------------- GFX -----------------
679 // -------------- GFX -----------------
680
681
682
683 }
684
685 // Polygon --------------------------------------------
686 // Polygon --------------------------------------------
687 // Polygon --------------------------------------------
688 }
689 else if (buffer_wkb_header->type == 1)
690 {
691 // Point -> *ignore* (skip over)
692 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t); // dummy value
693 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(struct wkb_point); // coordinate
694 }
695
696 }
697
698 // GeometryCollection ---------------------------------
699 // GeometryCollection ---------------------------------
700 // GeometryCollection ---------------------------------
701 }
702 else if (buffer_wkb_header->type == 4)
703 {
704 // Multipoint -----------------------------------------
705 // Multipoint -----------------------------------------
706 // Multipoint -----------------------------------------
707
708 // *ignore*
709
710 int num_m_points; dummy_sub_against_crash((void *) buffer_uncpr_pos, &num_m_points);
711 dbg(0, " num_m_points:%d\n", num_m_points);
712 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
713
714 int l1;
715 for(l1=0;l1<num_m_points;l1++)
716 {
717 dbg(0, " point#:%d\n", l1);
718 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(struct wkb_point); // coordinate
719 }
720
721 // Multipoint -----------------------------------------
722 // Multipoint -----------------------------------------
723 // Multipoint -----------------------------------------
724 }
457 else if (buffer_wkb_header->type == 6) 725 else if (buffer_wkb_header->type == 6)
458 { 726 {
459 // MultiPolygon 727 // MultiPolygon ---------------------------------------
728 // MultiPolygon ---------------------------------------
729 // MultiPolygon ---------------------------------------
730
460 n = (void *)buffer_uncpr_pos; 731 // n = (void *)buffer_uncpr_pos;
461 numpolys = *n; 732 // numpolys = *n;
733
734 int numpolys; dummy_sub_against_crash((void *) buffer_uncpr_pos, &numpolys);
735
462 // dbg(0, " numpolys:%d\n", (int)*n); 736 dbg(0, " numpolys:%d\n", numpolys);
463 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t); 737 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
464 738
465 739
466 // -------------- GFX ----------------- 740 // -------------- GFX -----------------
467 // -------------- GFX ----------------- 741 // -------------- GFX -----------------
484 // -------------- GFX ----------------- 758 // -------------- GFX -----------------
485 759
486 for(l=0;l<numpolys;l++) 760 for(l=0;l<numpolys;l++)
487 { 761 {
488 762
489 // dbg(0, " poly#:%d\n", l); 763 dbg(0, " poly#:%d\n", l);
490 764
491 buffer_wkb_header = (void *)buffer_uncpr_pos; 765 // *unused* // buffer_wkb_header = (void *)buffer_uncpr_pos;
766
492 // dbg(0, " is_little_endian:%d\n", (int)buffer_wkb_header->is_little_endian); 767 // dbg(0, " is_little_endian:%d\n", (int)buffer_wkb_header->is_little_endian);
493 // fprintf(stderr, " 0x%08x\n", (Bytef)buffer_wkb_header->is_little_endian); 768 // fprintf(stderr, " 0x%08x\n", (Bytef)buffer_wkb_header->is_little_endian);
494 769
495 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(struct wkb_header); 770 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(struct wkb_header);
496 771
497 // Polygon -------------------------------------------- 772 // Polygon --------------------------------------------
498 // Polygon -------------------------------------------- 773 // Polygon --------------------------------------------
499 // Polygon -------------------------------------------- 774 // Polygon --------------------------------------------
775
776 // uint32_t *n3 = NULL;
500 n = (void *)buffer_uncpr_pos; 777 // n3 = (void *)buffer_uncpr_pos;
501 numrings = *n; 778 // numrings = (int) *n3;
779
780 int numrings; dummy_sub_against_crash((void *) buffer_uncpr_pos, &numrings);
781
502 // dbg(0, " numRings:%d\n", (int)*n); 782 dbg(0, " numRings(2):%d\n", numrings);
783 // dbg(0, "0077aa.001\n");
503 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t); 784 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
785 // dbg(0, "0077aa.002 %p\n", buffer_uncpr_pos);
786
787 // dbg(0, "xxaa\n");
504 788
505 for(k=0;k<numrings;k++) 789 for(k=0;k<numrings;k++)
506 { 790 {
507 791
792 // dbg(0, "0077aa.003 %d\n", k);
793
508 // -------------- GFX ----------------- 794 // -------------- GFX -----------------
509 // -------------- GFX ----------------- 795 // -------------- GFX -----------------
510 // -------------- GFX ----------------- 796 // -------------- GFX -----------------
511 count = 0; 797 count = 0;
512 c_temp = c_ring; 798 c_temp = c_ring;
799
800 // dbg(0, "0077aa.004\n");
513 801
514 if (k == 0) 802 if (k == 0)
515 { 803 {
516 // water color: #82c8ea 804 // water color: #82c8ea
517 // 130, 200, 234 805 // 130, 200, 234
522 // graphics_gc_set_foreground(gra->gc[0], &custom_color); 810 // graphics_gc_set_foreground(gra->gc[0], &custom_color);
523 gra->gc[0]->meth.gc_set_foreground(gra->gc[0]->priv, &custom_color); 811 gra->gc[0]->meth.gc_set_foreground(gra->gc[0]->priv, &custom_color);
524 } 812 }
525 else 813 else
526 { 814 {
815 if (global_night_mode == 1)
816 {
817 // bg color: #666666
818 // 102, 102, 102
819 custom_color.r = 102 << 8;
820 custom_color.g = 102 << 8;
821 custom_color.b = 102 << 8;
822 }
823 else
824 {
527 // bg color: #fef9ee 825 // bg color: #fef9ee
528 // 254, 249, 238 826 // 254, 249, 238
529 custom_color.r = 254 << 8; 827 custom_color.r = 254 << 8;
530 custom_color.g = 249 << 8; 828 custom_color.g = 249 << 8;
531 custom_color.b = 238 << 8; 829 custom_color.b = 238 << 8;
830 }
532 831
533 // graphics_gc_set_foreground(gra->gc[0], &custom_color); 832 // graphics_gc_set_foreground(gra->gc[0], &custom_color);
534 gra->gc[0]->meth.gc_set_foreground(gra->gc[0]->priv, &custom_color); 833 gra->gc[0]->meth.gc_set_foreground(gra->gc[0]->priv, &custom_color);
535 834
536 } 835 }
537 // -------------- GFX ----------------- 836 // -------------- GFX -----------------
538 // -------------- GFX ----------------- 837 // -------------- GFX -----------------
539 // -------------- GFX ----------------- 838 // -------------- GFX -----------------
540 839
840 // dbg(0, "0077aa.006 %p\n", buffer_uncpr_pos);
841 // uint32_t *n2 = NULL;
541 n = (void *)buffer_uncpr_pos; 842 // n2 = buffer_uncpr_pos;
843
844// #define X_DEBUG_BUILD_ 222
845
846 // dbg(0, "0077aa.007 %p\n", buffer_uncpr_pos);
847 // dbg(0, "0077aa.007a %d\n", *n2);
848
849
850 int num_coords; dummy_sub_against_crash((void *) buffer_uncpr_pos, &num_coords);
851 // int num_coords = 2;
852
542 num_coords = (int)*n; 853 // num_coords = (int)*n2;
854
855 // dbg(0, "0077aa.008 num_coords=%d\n", num_coords);
856
543 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t); 857 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
544 858
859 // dbg(0, "0077aa.009 %p\n", buffer_uncpr_pos);
860
545 // dbg(0, " num of coords:%d\n", num_coords); 861 dbg(0, " num of coords:%d\n", num_coords);
546 862
547 for(j=0;j<num_coords;j++) 863 for(j=0;j<num_coords;j++)
548 { 864 {
549 // fprintf(stderr, " size of double:%d\n", sizeof(lat)); 865 // fprintf(stderr, " size of double:%d\n", sizeof(lat));
550 866
551 point1 = (void *)buffer_uncpr_pos; 867 point1 = (void *)buffer_uncpr_pos;
552 c_temp->x = point1->x; 868 c_temp->x = point1->x;
553 c_temp->y = point1->y; 869 c_temp->y = point1->y;
554 // ** // mvt_merc2lonlat(&point2); 870 // ** // mvt_merc2lonlat(&point2);
555 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(struct wkb_point); 871 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(struct wkb_point);
872
556 873
557 // dbg(0, " lat,lon [%d] %d %d\n", j, (int)point1->x, (int)point1->y); 874 // dbg(0, " lat,lon [%d] %d %d\n", j, (int)point1->x, (int)point1->y);
558 875
559 //fprintf(stderr, "0x%08x\n", (uint32_t)point1->x); 876 //fprintf(stderr, "0x%08x\n", (uint32_t)point1->x);
560 //mvt_print_binary_64((uint32_t)point1->x); 877 //mvt_print_binary_64((uint32_t)point1->x);
595 // Polygon -------------------------------------------- 912 // Polygon --------------------------------------------
596 // Polygon -------------------------------------------- 913 // Polygon --------------------------------------------
597 // Polygon -------------------------------------------- 914 // Polygon --------------------------------------------
598 915
599 916
600 // dbg(0, " XX6\n"); 917 //dbg(0, " XX6\n");
601 } 918 }
602 919
603 // dbg(0, " XX7\n"); 920 //dbg(0, " XX7\n");
921
922 // MultiPolygon ---------------------------------------
923 // MultiPolygon ---------------------------------------
924 // MultiPolygon ---------------------------------------
925
604 } 926 }
605 // dbg(0, " XX8\n");
606 927
607
608
609 // dbg(0, " XX8a\n"); 928 dbg(0, " XX8a\n");
610 929
611 // ======================= 930 // =======================
612 // buffer_uncpr_pos = buffer_uncpr_pos_save + (long)*feature_len; // use save position as start here 931 // buffer_uncpr_pos = buffer_uncpr_pos_save + (long)*feature_len; // use save position as start here
613 // ======================= 932 // =======================
614 933
615 // dbg(0, " XX8b\n"); 934 //dbg(0, " XX8b\n");
616 935
617 } 936 }
618 937
619 // dbg(0, " XX9\n"); 938 dbg(0, " XX9\n");
620 939
621 } 940 }
622 941
623 // dbg(0, " XX10\n"); 942 dbg(0, " XX10\n");
624 943
625 free(buffer_compressed); 944 g_free(buffer_compressed);
626 buffer_compressed = NULL; 945 buffer_compressed = NULL;
627 946
628 // dbg(0, " XX11\n"); 947 dbg(0, " XX11\n");
629 948
630 free(buffer_uncpr); 949 g_free(buffer_uncpr);
631 buffer_uncpr = NULL; 950 buffer_uncpr = NULL;
632 951
633 // dbg(0, " XX12\n"); 952 dbg(0, " XX12\n");
634 953
635 // -------------- GFX ----------------- 954 // -------------- GFX -----------------
636 // -------------- GFX ----------------- 955 // -------------- GFX -----------------
637 // -------------- GFX ----------------- 956 // -------------- GFX -----------------
638 free(p_ring); 957 g_free(p_ring);
639 // dbg(0, " XX13\n"); 958 //dbg(0, " XX13\n");
640 free(c_ring); 959 g_free(c_ring);
641 // dbg(0, " XX14\n"); 960 //dbg(0, " XX14\n");
642 // -------------- GFX ----------------- 961 // -------------- GFX -----------------
643 // -------------- GFX ----------------- 962 // -------------- GFX -----------------
644 // -------------- GFX ----------------- 963 // -------------- GFX -----------------
645 964
646 965
647 }
648 966
649 // dbg(0, " XX15\n");
650 967
651 }
652
653 // dbg(0, " XX16\n");
654
655
656 // dbg(0,"decode_mvt_tile:--LEAVE--\n"); 968 dbg(0,"decode_mvt_tile:--LEAVE--\n");
969
657 970
658} 971}
659 972
660 973
661void loop_mapnik_tiles(double lat_lt, double lon_lt, double lat_cn, double lon_cn, double lat_rb, double lon_rb, int mapnik_zoom, const char* basedir, struct displaylist *display_list) 974void loop_mapnik_tiles(double lat_lt, double lon_lt, double lat_cn, double lon_cn, double lat_rb, double lon_rb, int mapnik_zoom, const char* basedir, struct displaylist *display_list)
709 if ((mapfile_zvt) && (is_ok)) 1022 if ((mapfile_zvt) && (is_ok))
710 { 1023 {
711 1024
712 buffer = malloc(sizeof(struct zvt_header)); 1025 buffer = malloc(sizeof(struct zvt_header));
713 fread(buffer, sizeof(struct zvt_header), 1, mapfile_zvt); 1026 fread(buffer, sizeof(struct zvt_header), 1, mapfile_zvt);
714
715 // buffer2 = buffer; 1027 // buffer2 = buffer;
716 // buffer2[sizeof(struct zvt_header)] = '\0'; 1028 // buffer2[sizeof(struct zvt_header)] = '\0';
717 // dbg(0, "header=%s\n", buffer2); 1029 // dbg(0, "header=%s\n", buffer2);
718
719 free(buffer); 1030 free(buffer);
720 1031
721 1032
722 get_mapnik_tilenumber(&mnt_lt, lat_lt, lon_lt, mapnik_zoom); 1033 get_mapnik_tilenumber(&mnt_lt, lat_lt, lon_lt, mapnik_zoom);
723 get_mapnik_tilenumber(&mnt_cn, lat_cn, lon_cn, mapnik_zoom); 1034 get_mapnik_tilenumber(&mnt_cn, lat_cn, lon_cn, mapnik_zoom);
732 screen_height = r->rl.y - r->lu.y; 1043 screen_height = r->rl.y - r->lu.y;
733 dbg(0, "transform_get_size:w=%d h=%d\n", screen_width, screen_height); 1044 dbg(0, "transform_get_size:w=%d h=%d\n", screen_width, screen_height);
734 dbg(0, "transform_get_size:%d %d %d %d\n", r->rl.x, r->rl.y, r->lu.x, r->lu.y); 1045 dbg(0, "transform_get_size:%d %d %d %d\n", r->rl.x, r->rl.y, r->lu.x, r->lu.y);
735 } 1046 }
736 */ 1047 */
737
738
739
740
741
742 1048
743 1049
744 d_lat = (mnt_lt.y) - (mnt_cn.y); 1050 d_lat = (mnt_lt.y) - (mnt_cn.y);
745 d_lon = (mnt_lt.x) - (mnt_cn.x); 1051 d_lon = (mnt_lt.x) - (mnt_cn.x);
746 d_max = abs(d_lon); 1052 d_max = abs(d_lon);
863 1169
864 free(filename); 1170 free(filename);
865 } 1171 }
866} 1172}
867 1173
1174/*
868void mvt_print_binary_64(uint64_t n) 1175void mvt_print_binary_64(uint64_t n)
869{ 1176{
870 int c; 1177 int c;
871 1178
872 for(c=0;c<64;c++) 1179 for(c=0;c<64;c++)
882 } 1189 }
883 n >>= 1; 1190 n >>= 1;
884 } 1191 }
885 fprintf(stderr, "\n"); 1192 fprintf(stderr, "\n");
886} 1193}
1194*/
887 1195
888 1196
889/* 1197/*
890==================================================================== 1198====================================================================
891*/ 1199*/

Legend:
Removed from v.50  
changed lines
  Added in v.51

   
Visit the ZANavi Wiki