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

Contents of /navit/navit/mvt_tiles_full.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 56 - (show annotations) (download)
Sun Mar 19 08:44:36 2017 UTC (7 years ago) by zoff99
File MIME type: text/plain
File size: 21288 byte(s)
updates
1 /**
2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2016 Zoff <zoff@zoff.cc>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20
21
22 // **********=================== hack to display MVT tiles ===================**********
23 // **********=================== hack to display MVT tiles ===================**********
24 // **********=================== hack to display MVT tiles ===================**********
25 // **********=================== hack to display MVT tiles ===================**********
26 // **********=================== hack to display MVT tiles ===================**********
27
28
29
30
31
32 #define _MVT_LITTLEENDIAN_
33
34 /*
35 ====================================================================
36 */
37
38 struct __attribute__((__packed__)) mvt_header
39 {
40 uint8_t signature[4];
41 uint32_t len;
42 };
43
44 struct __attribute__((__packed__)) wkb_header
45 {
46 uint8_t is_little_endian; // 0 or 1
47 uint32_t type;
48 };
49
50 struct wkb_point
51 {
52 double x;
53 double y;
54 };
55
56 struct mapnik_tile
57 {
58 int x;
59 int y;
60 };
61
62
63 /*
64 ====================================================================
65 */
66
67 #ifdef _MVT_LITTLEENDIAN_
68 uint32_t swap_endian32(uint32_t num)
69 {
70 return ((num>>24)&0xff) | // move byte 3 to byte 0
71 ((num<<8)&0xff0000) | // move byte 1 to byte 2
72 ((num>>8)&0xff00) | // move byte 2 to byte 1
73 ((num<<24)&0xff000000); // byte 0 to byte 3
74 }
75
76
77 uint64_t swap_endian64(uint64_t x)
78 {
79 return (uint64_t)((((x) & 0xff00000000000000ull) >> 56)
80 | (((x) & 0x00ff000000000000ull) >> 40)
81 | (((x) & 0x0000ff0000000000ull) >> 24)
82 | (((x) & 0x000000ff00000000ull) >> 8)
83 | (((x) & 0x00000000ff000000ull) << 8)
84 | (((x) & 0x0000000000ff0000ull) << 24)
85 | (((x) & 0x000000000000ff00ull) << 40)
86 | (((x) & 0x00000000000000ffull) << 56));
87 }
88
89 #else
90 #define swap_endian32(x) x
91 #define swap_endian64(x) x
92 #endif
93
94 // for zlib ------------
95 #define Bytef unsigned char
96 #define uLong unsigned long
97 #define uLongf unsigned long
98 // for zlib ------------
99
100 const char *wkb_feature_type[] =
101 {
102 "Geometry", // 0
103 "Point",
104 "LineString",
105 "Polygon", // 3
106 "MultiPoint",
107 "MultiLineString",
108 "MultiPolygon", // 6
109 "GeometryCollection",
110 "CircularString",
111 "CompoundCurve",
112 "CurvePolygon", // 10
113 "MultiCurve", // 11
114 "MultiSurface",
115 "Curve",
116 "Surface",
117 "PolyhedralSurface",
118 "TIN",
119 "Triangle", // 17
120 };
121
122
123
124 // Max extent edge for spherical mercator
125 #define MVT_MAX_EXTENT 20037508.342789244
126 #define MVT_M_PI 3.14159265358979323846
127 #define MVT_M_PI_2 1.57079632679489661923
128 #define MVT_DEG_TO_RAD 0.01745329251
129 #define MVT_RAD_TO_DEG 57.2957795131
130
131 void mvt_merc2lonlat(struct wkb_point *in)
132 {
133 // "Convert coordinate pair from epsg:3857 to epsg:4326"
134 in->x = (in->x / MVT_MAX_EXTENT) * 180.0;
135 in->y = (in->y / MVT_MAX_EXTENT) * 180.0;
136 in->y = MVT_RAD_TO_DEG * (2.0 * atan(exp(in->y * MVT_DEG_TO_RAD)) - MVT_M_PI_2);
137
138 // fprintf(stderr, "lat, lon: %f %f\n", x1, y1);
139 }
140
141 void get_mapnik_tilenumber(struct mapnik_tile *mt, double lat, double lon, int mapnik_zoom)
142 {
143 mt->x = (int)( ( lon + 180) / 360 * pow(2, mapnik_zoom) );
144 mt->y = (int)( (1 - log(tan(MVT_DEG_TO_RAD * lat) + (1/(cos(MVT_DEG_TO_RAD * lat))) )/MVT_M_PI)/2 * pow(2, mapnik_zoom) );
145
146 // dbg(0, "%d %d %f %f %d\n", mt->x, mt->y, lat, lon, mapnik_zoom);
147 }
148
149 void decode_mvt_tile(const char* basedir, int mapnik_zoom, int tile_x, int tile_y, struct displaylist *display_list)
150 {
151
152 // dbg(0,"decode_mvt_tile:--ENTER--\n");
153
154 char *filename;
155 // const char *filename = "0.mvt";
156 FILE *fp = NULL;
157 struct mvt_header *buffer = NULL;
158 struct wkb_header *buffer_wkb_header = NULL;
159 void *buffer_compressed = NULL;
160 Bytef *buffer_uncpr = NULL;
161 uLongf buffer_uncpr_len = -1;
162 unsigned long buffer_uncpr_end = -1;
163 int res = -1;
164 uint32_t *feature_count = NULL;
165 uint32_t *feature_len = NULL;
166 uint32_t *json_len = NULL;
167 uint32_t numrings = -1;
168 uint32_t numpolys = -1;
169 Bytef *buffer_uncpr_pos = NULL;
170 Bytef *buffer_uncpr_pos_save = NULL;
171 int i = -1;
172 int j = -1;
173 int k = -1;
174 int l = -1;
175 int num_coords = 0;
176 uint32_t *n = NULL;
177 double lat = 0;
178 uint64_t *lat_p = NULL;
179 double lon = 0;
180 uint64_t *lon_p = NULL;
181 struct wkb_point *point1 = NULL;
182 struct wkb_point point2;
183
184
185 filename = malloc(2000);
186 if (filename)
187 {
188 sprintf(filename, "%s/%d/%d/%d.mvt", basedir, mapnik_zoom, tile_x, tile_y);
189 // dbg(0, "filename=%s\n", filename);
190
191 fp = fopen(filename, "rb");
192
193 if (fp)
194 {
195
196 // -------------- GFX -----------------
197 // -------------- GFX -----------------
198 // -------------- GFX -----------------
199 struct point *p_ring = malloc(sizeof(struct point) * 2000); // 2000 points in 1 polygon max ?!
200 struct coord *c_ring = malloc(sizeof(struct coord) * 2000); // 2000 coords in 1 polygon max ?!
201 struct coord *c_temp = c_ring;
202 struct coord_geo g_temp;
203 struct graphics *gra = display_list->dc.gra;
204 // struct graphics_gc *gc = display_list->dc.gc;
205 struct color custom_color;
206 int count = 0;
207
208 if (!gra->gc[0])
209 {
210 gra->gc[0] = graphics_gc_new(gra);
211 }
212
213 // -------------- GFX -----------------
214 // -------------- GFX -----------------
215 // -------------- GFX -----------------
216
217
218 // fprintf(stderr, "file open\n");
219 // fseek(fp, 0, SEEK_SET); // start of file
220 // fprintf(stderr, "file start\n");
221
222 buffer = malloc(sizeof(struct mvt_header));
223
224 fread(buffer, sizeof(struct mvt_header), 1, fp);
225 // fprintf(stderr, "sig:%s\n", buffer->signature);
226 buffer->len = swap_endian32(buffer->len);
227
228 // dbg(0, "compressed len:%ld\n", (long)buffer->len);
229 // fprintf(stderr, "0x%08x\n", buffer->len);
230
231 buffer_compressed = malloc((size_t)buffer->len);
232 fread(buffer_compressed, buffer->len, 1, fp);
233 fclose(fp);
234
235 buffer_uncpr_len = buffer->len * 20;
236 buffer_uncpr_end = buffer_uncpr + buffer_uncpr_len;
237 buffer_uncpr = malloc((size_t)buffer_uncpr_len);
238
239 res = uncompress(buffer_uncpr, &buffer_uncpr_len, buffer_compressed, buffer->len);
240
241 if (res == Z_BUF_ERROR)
242 {
243 dbg(0, "res=Z_BUF_ERROR\n");
244 }
245 else if (res == Z_STREAM_ERROR)
246 {
247 dbg(0, "res=Z_STREAM_ERROR\n");
248 }
249 else if (res == Z_MEM_ERROR)
250 {
251 dbg(0, "res=Z_MEM_ERROR\n");
252 }
253 else if (res == Z_DATA_ERROR)
254 {
255 dbg(0, "res=Z_DATA_ERROR\n");
256 }
257 else
258 {
259 // dbg(0, "res=%d\n", res);
260
261 // dbg(0, "un-compressed len:%ld\n", (long)buffer_uncpr_len);
262
263 buffer_uncpr_pos = buffer_uncpr;
264 feature_count = (void *)buffer_uncpr_pos;
265 *feature_count = swap_endian32(*feature_count);
266 // fprintf(stderr, "0x%08x\n", *feature_count);
267 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
268
269 // dbg(0, "feature_count:%d\n", (int)*feature_count);
270 // fprintf(stderr, "sizeof feature_count:%d\n", sizeof(uint32_t));
271
272 // loop through features
273 for(i=0;i<(int)*feature_count;i++)
274 {
275 // dbg(0, "feature#:%d\n", i);
276
277 feature_len = (void *)buffer_uncpr_pos;
278 *feature_len = swap_endian32(*feature_len);
279 // fprintf(stderr, "0x%08x\n", *feature_len);
280 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
281 // dbg(0, " feature_len:%d\n", (int)*feature_len);
282
283 // =======================
284 buffer_uncpr_pos_save = buffer_uncpr_pos; // save position
285 // =======================
286
287
288 buffer_wkb_header = (void *)buffer_uncpr_pos;
289 // dbg(0, " is_little_endian:%d\n", (int)buffer_wkb_header->is_little_endian);
290 // fprintf(stderr, " 0x%08x\n", (Bytef)buffer_wkb_header->is_little_endian);
291
292 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(struct wkb_header);
293
294 if (buffer_wkb_header->is_little_endian)
295 {
296 // dbg(0, " little endian\n");
297 // dbg(0, " feature type:%d\n", (int)buffer_wkb_header->type);
298 // dbg(0, " feature type:%s\n", wkb_feature_type[(int)buffer_wkb_header->type]);
299
300
301 if (buffer_wkb_header->type == 3)
302 {
303 // Polygon --------------------------------------------
304 // Polygon --------------------------------------------
305 // Polygon --------------------------------------------
306 n = (void *)buffer_uncpr_pos;
307 numrings = *n;
308 // dbg(0, " numRings:%d\n", (int)*n);
309 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
310
311
312
313
314 // -------------- GFX -----------------
315 // -------------- GFX -----------------
316 // -------------- GFX -----------------
317 count = 0;
318
319 // water color: #82c8ea
320 // 130, 200, 234
321 custom_color.r = 130 << 8;
322 custom_color.g = 200 << 8;
323 custom_color.b = 234 << 8;
324
325 custom_color.a = 0xffff;
326
327 // graphics_gc_set_foreground(gra->gc[0], &custom_color);
328 gra->gc[0]->meth.gc_set_foreground(gra->gc[0]->priv, &custom_color);
329 // -------------- GFX -----------------
330 // -------------- GFX -----------------
331 // -------------- GFX -----------------
332
333
334
335 for(k=0;k<numrings;k++)
336 {
337
338 n = (void *)buffer_uncpr_pos;
339 num_coords = (int)*n;
340 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
341
342
343 // -------------- GFX -----------------
344 // -------------- GFX -----------------
345 // -------------- GFX -----------------
346 count = 0;
347 c_temp = c_ring;
348 // -------------- GFX -----------------
349 // -------------- GFX -----------------
350 // -------------- GFX -----------------
351
352
353 // dbg(0, " num of coords:%d\n", num_coords);
354
355 for(j=0;j<num_coords;j++)
356 {
357 // fprintf(stderr, " size of double:%d\n", sizeof(lat));
358
359 point1 = (void *)buffer_uncpr_pos;
360 point2.x = point1->x;
361 point2.y = point1->y;
362 mvt_merc2lonlat(&point2);
363 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(struct wkb_point);
364
365 // dbg(0, " lat,lon [%d] %lf %lf\n", j, point2.x, point2.y);
366 //fprintf(stderr, "%016llx\n", (long long unsigned int)point1->x);
367 //mvt_print_binary_64((uint32_t)point1->x);
368 //fprintf(stderr, "%016llx\n", (long long unsigned int)point1->y);
369 //mvt_print_binary_64((uint32_t)point1->y);
370
371 // -------------- GFX -----------------
372 // -------------- GFX -----------------
373 // -------------- GFX -----------------
374 g_temp.lat = point2.y;
375 g_temp.lng = point2.x;
376 transform_from_geo(projection_mg, &g_temp, c_temp);
377 count++;
378 c_temp++;
379 // -------------- GFX -----------------
380 // -------------- GFX -----------------
381 // -------------- GFX -----------------
382
383
384 }
385
386
387 // -------------- GFX -----------------
388 // -------------- GFX -----------------
389 // -------------- GFX -----------------
390 if (count > 0)
391 {
392 count = transform(global_navit->trans, projection_mg, c_ring, p_ring, count, 0, 0, NULL);
393
394 //Z//graphics_draw_polygon_clipped(gra, display_list->dc.gc, p_ring, count);
395 gra->meth.draw_polygon(gra->priv, gra->gc[0]->priv, p_ring, count);
396 //Z//gra->meth.draw_polygon(gra, display_list->dc.gc, p_ring, count);
397 }
398 // -------------- GFX -----------------
399 // -------------- GFX -----------------
400 // -------------- GFX -----------------
401
402
403
404 }
405
406 // Polygon --------------------------------------------
407 // Polygon --------------------------------------------
408 // Polygon --------------------------------------------
409 }
410 else if (buffer_wkb_header->type == 6)
411 {
412 // MultiPolygon
413 n = (void *)buffer_uncpr_pos;
414 numpolys = *n;
415 // dbg(0, " numpolys:%d\n", (int)*n);
416 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
417
418
419 // -------------- GFX -----------------
420 // -------------- GFX -----------------
421 // -------------- GFX -----------------
422 count = 0;
423
424 // water color: #82c8ea
425 // 130, 200, 234
426 custom_color.r = 130 << 8;
427 custom_color.g = 200 << 8;
428 custom_color.b = 234 << 8;
429
430 custom_color.a = 0xffff;
431
432 //graphics_gc_set_foreground(gra->gc[0], &custom_color);
433 gra->gc[0]->meth.gc_set_foreground(gra->gc[0]->priv, &custom_color);
434
435 // -------------- GFX -----------------
436 // -------------- GFX -----------------
437 // -------------- GFX -----------------
438
439 for(l=0;l<numpolys;l++)
440 {
441
442 // dbg(0, " poly#:%d\n", l);
443
444 buffer_wkb_header = (void *)buffer_uncpr_pos;
445 // dbg(0, " is_little_endian:%d\n", (int)buffer_wkb_header->is_little_endian);
446 // fprintf(stderr, " 0x%08x\n", (Bytef)buffer_wkb_header->is_little_endian);
447
448 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(struct wkb_header);
449
450 // Polygon --------------------------------------------
451 // Polygon --------------------------------------------
452 // Polygon --------------------------------------------
453 n = (void *)buffer_uncpr_pos;
454 numrings = *n;
455 // dbg(0, " numRings:%d\n", (int)*n);
456 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
457
458 for(k=0;k<numrings;k++)
459 {
460
461 // -------------- GFX -----------------
462 // -------------- GFX -----------------
463 // -------------- GFX -----------------
464 count = 0;
465 c_temp = c_ring;
466
467 if (k == 0)
468 {
469 // water color: #82c8ea
470 // 130, 200, 234
471 custom_color.r = 130 << 8;
472 custom_color.g = 200 << 8;
473 custom_color.b = 234 << 8;
474
475 // graphics_gc_set_foreground(gra->gc[0], &custom_color);
476 gra->gc[0]->meth.gc_set_foreground(gra->gc[0]->priv, &custom_color);
477 }
478 else
479 {
480 // bg color: #fef9ee
481 // 254, 249, 238
482 custom_color.r = 254 << 8;
483 custom_color.g = 249 << 8;
484 custom_color.b = 238 << 8;
485
486 // graphics_gc_set_foreground(gra->gc[0], &custom_color);
487 gra->gc[0]->meth.gc_set_foreground(gra->gc[0]->priv, &custom_color);
488
489 }
490 // -------------- GFX -----------------
491 // -------------- GFX -----------------
492 // -------------- GFX -----------------
493
494 n = (void *)buffer_uncpr_pos;
495 num_coords = (int)*n;
496 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
497
498
499 // dbg(0, " num of coords:%d\n", num_coords);
500
501 for(j=0;j<num_coords;j++)
502 {
503 // fprintf(stderr, " size of double:%d\n", sizeof(lat));
504
505 point1 = (void *)buffer_uncpr_pos;
506 point2.x = point1->x;
507 point2.y = point1->y;
508 mvt_merc2lonlat(&point2);
509 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(struct wkb_point);
510
511 //dbg(0, " lat,lon [%d] %lf %lf\n", j, point2.x, point2.y);
512
513 //fprintf(stderr, "0x%08x\n", (uint32_t)point1->x);
514 //mvt_print_binary_64((uint32_t)point1->x);
515 //fprintf(stderr, "0x%08x\n", (uint32_t)point1->y);
516 //mvt_print_binary_64((uint32_t)point1->y);
517
518 // -------------- GFX -----------------
519 // -------------- GFX -----------------
520 // -------------- GFX -----------------
521 g_temp.lat = point2.y;
522 g_temp.lng = point2.x;
523 transform_from_geo(projection_mg, &g_temp, c_temp);
524 count++;
525 c_temp++;
526 // -------------- GFX -----------------
527 // -------------- GFX -----------------
528 // -------------- GFX -----------------
529
530 }
531
532
533 // -------------- GFX -----------------
534 // -------------- GFX -----------------
535 // -------------- GFX -----------------
536 if (count > 0)
537 {
538 count = transform(global_navit->trans, projection_mg, c_ring, p_ring, count, 0, 0, NULL);
539 //Z//graphics_draw_polygon_clipped(gra, display_list->dc.gc, p_ring, count);
540 gra->meth.draw_polygon(gra->priv, gra->gc[0]->priv, p_ring, count);
541 //Z//gra->meth.draw_polygon(gra, display_list->dc.gc, p_ring, count);
542 }
543 // -------------- GFX -----------------
544 // -------------- GFX -----------------
545 // -------------- GFX -----------------
546
547
548 }
549 // Polygon --------------------------------------------
550 // Polygon --------------------------------------------
551 // Polygon --------------------------------------------
552
553 }
554 }
555 }
556 else
557 {
558 dbg(0, " BIG endian\n");
559 }
560
561 // =======================
562 buffer_uncpr_pos = buffer_uncpr_pos_save + (long)*feature_len; // use save position as start here
563 // =======================
564
565
566 json_len = (void *)buffer_uncpr_pos;
567 *json_len = swap_endian32(*json_len);
568 // fprintf(stderr, "0x%08x\n", *json_len);
569 buffer_uncpr_pos = buffer_uncpr_pos + sizeof(uint32_t);
570 // dbg(0, " json_len:%d\n", (int)*json_len);
571
572 buffer_uncpr_pos = buffer_uncpr_pos + (int)*json_len;
573 }
574
575 }
576
577 free(buffer_compressed);
578 buffer_compressed = NULL;
579
580 free(buffer_uncpr);
581 buffer_uncpr = NULL;
582
583 free(buffer);
584 buffer = NULL;
585
586 // -------------- GFX -----------------
587 // -------------- GFX -----------------
588 // -------------- GFX -----------------
589 free(p_ring);
590 free(c_ring);
591 // -------------- GFX -----------------
592 // -------------- GFX -----------------
593 // -------------- GFX -----------------
594
595
596 }
597
598 free(filename);
599 filename = NULL;
600 }
601
602 // dbg(0,"decode_mvt_tile:--LEAVE--\n");
603
604 }
605
606
607 void 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)
608 {
609 // loop thru all mapniktiles in this bbox and call something
610
611 struct mapnik_tile mnt_lt;
612 struct mapnik_tile mnt_cn;
613 struct mapnik_tile mnt_rb;
614 int i;
615 int j;
616 int d_lat;
617 int d_lon;
618 float d_lat_f;
619 float d_lon_f;
620 int d_max;
621 int base_x;
622 int base_y;
623 int d2_lat;
624 int d2_lon;
625 float d2_lat_f;
626 float d2_lon_f;
627 int d2_max;
628 int color;
629 int tile_x;
630 int tile_y;
631 int overlap = 1; // tiles more than needed around the bbox
632
633 get_mapnik_tilenumber(&mnt_lt, lat_lt, lon_lt, mapnik_zoom);
634 get_mapnik_tilenumber(&mnt_cn, lat_cn, lon_cn, mapnik_zoom);
635 get_mapnik_tilenumber(&mnt_rb, lat_rb, lon_rb, mapnik_zoom);
636
637
638 /*
639 struct point_rect *r;
640 if (global_navit->trans->screen_sel)
641 {
642 r = &global_navit->trans->screen_sel->u.p_rect;
643 screen_width = r->rl.x - r->lu.x;
644 screen_height = r->rl.y - r->lu.y;
645 dbg(0, "transform_get_size:w=%d h=%d\n", screen_width, screen_height);
646 dbg(0, "transform_get_size:%d %d %d %d\n", r->rl.x, r->rl.y, r->lu.x, r->lu.y);
647 }
648 */
649
650
651
652
653
654
655
656 d_lat = (mnt_lt.y) - (mnt_cn.y);
657 d_lon = (mnt_lt.x) - (mnt_cn.x);
658 d_max = abs(d_lon);
659 if (abs(d_lat) > abs(d_lon))
660 {
661 d_max = abs(d_lat);
662 }
663
664 if (d_max > 0)
665 {
666 d_lat_f = (float)d_lat / (float)d_max;
667 d_lon_f = (float)d_lon / (float)d_max;
668 }
669 else
670 {
671 d_lat_f = 0.0;
672 d_lon_f = 0.0;
673 }
674 // dbg(0, "%f %f %f %f %f\n", (float)d_lat_f, (float)d_lon_f, (float)d_max, (float)d_lat, (float)d_lon);
675
676
677 d2_lat = (mnt_rb.y) - (mnt_cn.y);
678 d2_lon = (mnt_rb.x) - (mnt_cn.x);
679 d2_max = abs(d2_lon);
680 if (abs(d2_lat) > abs(d2_lon))
681 {
682 d2_max = abs(d2_lat);
683 }
684
685 if (d2_max > 0)
686 {
687 d2_lat_f = (float)d2_lat / (float)d2_max;
688 d2_lon_f = (float)d2_lon / (float)d2_max;
689 }
690 else
691 {
692 d2_lat_f = 0.0;
693 d2_lon_f = 0.0;
694 }
695 // dbg(0, "%f %f %f %f %f\n", (float)d2_lat_f, (float)d2_lon_f, (float)d2_max, (float)d2_lat, (float)d2_lon);
696
697 // lon == x
698 // lat == y
699 color = 2;
700 for(i=-overlap;i<(d2_max + 1 + overlap);i++)
701 {
702 base_y = (int)((float)i * (d2_lat_f));
703 base_x = (int)((float)i * (d2_lon_f));
704 // dbg(0, "%d:%d %d\n", i, base_x, base_y);
705
706 color = 3 - color; // color = toggle between "1" and "2"
707 for(j=-overlap;j<(d_max + 1 + overlap);j++)
708 {
709 tile_y = mnt_cn.y + base_y + (int)((float)j * (d_lat_f));
710 tile_x = mnt_cn.x + base_x + (int)((float)j * (d_lon_f));
711
712 // dbg(0, "tile:%d/%d/%d\n", mapnik_zoom, tile_x, tile_y);
713 decode_mvt_tile(basedir, mapnik_zoom, tile_x, tile_y, display_list);
714 }
715 }
716 }
717
718 void mvt_print_binary_64(uint64_t n)
719 {
720 int c;
721
722 for(c=0;c<64;c++)
723 {
724 // fprintf(stderr, "c=%d\n", c);
725 if (n & 1)
726 {
727 fprintf(stderr, "1");
728 }
729 else
730 {
731 fprintf(stderr, "0");
732 }
733 n >>= 1;
734 }
735 fprintf(stderr, "\n");
736 }
737
738
739 /*
740 ====================================================================
741 */
742
743
744
745
746 // **********=================== hack to display MVT tiles ===================**********
747 // **********=================== hack to display MVT tiles ===================**********
748 // **********=================== hack to display MVT tiles ===================**********
749 // **********=================== hack to display MVT tiles ===================**********
750 // **********=================== hack to display MVT tiles ===================**********
751
752

   
Visit the ZANavi Wiki