Compare commits
1342 commits
revert-347
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
bb3106d04f | ||
|
8ebd792258 | ||
|
e7a2bacb5d | ||
|
05389e3c73 | ||
|
abeace5167 | ||
|
92b1ea9ceb | ||
|
cd082c5872 | ||
|
c1117a4d33 | ||
|
20b154ae49 | ||
|
379261434b | ||
|
3d172b94f7 | ||
|
5f327ff3c8 | ||
|
dc97085b31 | ||
|
7a1663f0a2 | ||
|
924123e9c7 | ||
|
75756b33f3 | ||
|
f1a3d6d7da | ||
|
3348f97c76 | ||
|
a982e69525 | ||
|
4f6a7a2571 | ||
|
7358a66c2f | ||
|
727e3a1ca7 | ||
|
fc029ae5a5 | ||
|
4df58036aa | ||
|
5e7b478627 | ||
|
0526c603d4 | ||
|
2ef5003283 | ||
|
eb99057a47 | ||
|
d9a6494858 | ||
|
7f743210a0 | ||
|
53900d359c | ||
|
507a834264 | ||
|
0e0aed3bde | ||
|
e7d0b85dbc | ||
|
1a878af2f7 | ||
|
85801bd402 | ||
|
02049bb811 | ||
|
52bde246d2 | ||
|
ffcf059556 | ||
|
054c2a18a9 | ||
|
f91f522e71 | ||
|
9a0d7445be | ||
|
63d7e51b84 | ||
|
3da7a3b1a1 | ||
|
cde255852d | ||
|
8c3048bf99 | ||
|
9610c4e2ad | ||
|
b8166f81a6 | ||
|
84cd5864e7 | ||
|
61cb187dbb | ||
|
d7a8f1d04a | ||
|
f5acdb3efd | ||
|
c87b245f71 | ||
|
4798be914c | ||
|
653d8b7310 | ||
|
d7a490ffc2 | ||
|
2c9e55b770 | ||
|
9510cd68a3 | ||
|
0a10de3827 | ||
|
b3dd7a0e7d | ||
|
34bb44e490 | ||
|
658a8bb080 | ||
|
21276ab2a0 | ||
|
9292899240 | ||
|
ab626ac052 | ||
|
7ef431ece2 | ||
|
e1feef5a79 | ||
|
4114824e6b | ||
|
99aa246b73 | ||
|
3a461630f7 | ||
|
1283ca5b77 | ||
|
454837070d | ||
|
f89f221445 | ||
|
09067f55fa | ||
|
f84c30f20c | ||
|
3176749613 | ||
|
e412e12599 | ||
|
77cd733258 | ||
|
bbeac846d7 | ||
|
e18643ed08 | ||
|
8afed63683 | ||
|
6e81004cfb | ||
|
0d0c471eb5 | ||
|
751c96ec4a | ||
|
7350d0a653 | ||
|
e1d7d3deb5 | ||
|
6e44fb052c | ||
|
7c45369e88 | ||
|
754b12b008 | ||
|
a85bc95135 | ||
|
15abda8b3e | ||
|
dc5ad24ef8 | ||
|
e3b0044f8e | ||
|
a8d1797bcf | ||
|
283e2762d4 | ||
|
3ef2e8e3da | ||
|
0ffd196010 | ||
|
15f6745223 | ||
|
6c58ae3ae1 | ||
|
0897271a8e | ||
|
d6fc3b1ddc | ||
|
5cc57566cc | ||
|
658d5e69a4 | ||
|
7afaa7e6cc | ||
|
5ac45af78e | ||
|
93ab8b4690 | ||
|
7864289291 | ||
|
0708ee8724 | ||
|
c2c6d2ed60 | ||
|
83f833f1ce | ||
|
7aceade7c5 | ||
|
a9e0bf5bee | ||
|
1e4c17256a | ||
|
6479059c7e | ||
|
e394db6c8f | ||
|
fb61b3fb12 | ||
|
493c7fd5a1 | ||
|
ba2125b095 | ||
|
6d420b0911 | ||
|
f9b9261d53 | ||
|
61b5ff26f2 | ||
|
2b932be0ca | ||
|
02e3b1577c | ||
|
8d2388870a | ||
|
62c449e6d1 | ||
|
d4173b022d | ||
|
34c95df267 | ||
|
5b08c21eb0 | ||
|
38193817de | ||
|
c067399041 | ||
|
0e9f8b06a3 | ||
|
b911464472 | ||
|
127f9ba143 | ||
|
995d3044a4 | ||
|
1da533b5e5 | ||
|
6350e1b259 | ||
|
dcfb2d692c | ||
|
1c6d14eb85 | ||
|
cc1c990a2a | ||
|
45f954c578 | ||
|
4f6ab6a4a2 | ||
|
2e1b32512b | ||
|
9d5c458405 | ||
|
ee76817d14 | ||
|
88652012a9 | ||
|
a5a96aacad | ||
|
c8fd548133 | ||
|
437feebaf1 | ||
|
8cdca5f5be | ||
|
d745e43eb1 | ||
|
7d2029165e | ||
|
2d20d5a3c5 | ||
|
738a7f19b7 | ||
|
279acf4c36 | ||
|
bff4fdde77 | ||
|
f391178af0 | ||
|
50f1b05f86 | ||
|
47f7f6bd4d | ||
|
d69a0902d4 | ||
|
cb352ac609 | ||
|
388d3fd8da | ||
|
b7332b07a1 | ||
|
b1282fe32c | ||
|
ee8c403779 | ||
|
123232ffde | ||
|
2445dbe063 | ||
|
ed0f8dcb48 | ||
|
f226d4fd93 | ||
|
708e2a4009 | ||
|
92426bfc8e | ||
|
20acc0e656 | ||
|
6003293e25 | ||
|
76c5fd047d | ||
|
3b81effb3e | ||
|
35d901072b | ||
|
e847bb738b | ||
|
cd4069f91e | ||
|
c4aa24496a | ||
|
63f33eed4b | ||
|
bc09efb8f5 | ||
|
bb280a2815 | ||
|
93e488a6cf | ||
|
9f88d4c3a4 | ||
|
f6cd056552 | ||
|
0e9996dde0 | ||
|
fc2d27d349 | ||
|
e4557c016f | ||
|
edec46e8c3 | ||
|
b7fdeeeb02 | ||
|
ecfccdd36c | ||
|
338942b490 | ||
|
00199754a2 | ||
|
49912a423e | ||
|
5504aea704 | ||
|
779c04af06 | ||
|
a244effa91 | ||
|
45b48721fa | ||
|
106a46bbf6 | ||
|
96a6fcd941 | ||
|
d680d1d7f5 | ||
|
be0b537f52 | ||
|
a3f65197dd | ||
|
c646d245b4 | ||
|
f36ac22f82 | ||
|
87ac079bb6 | ||
|
accb28eb80 | ||
|
7035b3e399 | ||
|
692c2faa0e | ||
|
db9c4bc340 | ||
|
52b5cab584 | ||
|
41bb612e5d | ||
|
3dbeb1ee4f | ||
|
21d31bf62e | ||
|
02445f43ed | ||
|
1351d90d51 | ||
|
8839f5774a | ||
|
a499989b1d | ||
|
d1f16479d1 | ||
|
5e980ec853 | ||
|
8efaa959f0 | ||
|
e0da4468d2 | ||
|
b4f1bc09f8 | ||
|
ce073c64c7 | ||
|
b9175100bd | ||
|
fb97fb10f7 | ||
|
c62e03344f | ||
|
ccbf27400c | ||
|
00e2027d86 | ||
|
43a7d7e455 | ||
|
edddd08d73 | ||
|
4e064b8b8e | ||
|
7cce5ce346 | ||
|
e811958745 | ||
|
64a031a19b | ||
|
51b5c9604a | ||
|
6afcb73135 | ||
|
e27bc63887 | ||
|
f4eec2e24f | ||
|
d29aeb2ddb | ||
|
dd38dd18f9 | ||
|
bc38652079 | ||
|
be46202511 | ||
|
d417b8933a | ||
|
2ff1f4228d | ||
|
d949acb925 | ||
|
cbb80aa0db | ||
|
0b62415225 | ||
|
d436c94c25 | ||
|
0e5e77121c | ||
|
0071eb1163 | ||
|
df1ff425b7 | ||
|
7c24ff09ee | ||
|
e790aa6c06 | ||
|
b7953fa68b | ||
|
9c873d0e95 | ||
|
0968e12b5e | ||
|
ae5e283df9 | ||
|
2770657ba1 | ||
|
b26d0757b7 | ||
|
8bc1aad37f | ||
|
c3aec439a7 | ||
|
b3ed2280b6 | ||
|
bfdab8879c | ||
|
5f4711a019 | ||
|
7d267b47fe | ||
|
56312c68ad | ||
|
4fc828cf29 | ||
|
8c04fb1262 | ||
|
07789ad3cc | ||
|
817f644c6d | ||
|
6183005baf | ||
|
7d414450c1 | ||
|
4ef05da536 | ||
|
5347a1d939 | ||
|
0da7efdbac | ||
|
d4ae5ac653 | ||
|
a65d65a5ab | ||
|
1d75721a46 | ||
|
2a71903c75 | ||
|
7e5655eef4 | ||
|
5522cdd201 | ||
|
bd018ef5ab | ||
|
b438edd8da | ||
|
05661e5439 | ||
|
02af1f606c | ||
|
618ddef663 | ||
|
fa9ee1fc61 | ||
|
98e5e64d80 | ||
|
53a8e2ec2c | ||
|
9cf40a6144 | ||
|
9e8e178160 | ||
|
81103491b4 | ||
|
ce8bd250dd | ||
|
4cd4985e75 | ||
|
b9379f9024 | ||
|
e6553ef652 | ||
|
019af0ad1d | ||
|
13c4719912 | ||
|
cf78c2a129 | ||
|
a1596e4dad | ||
|
c8cff17fb6 | ||
|
7d8be299f3 | ||
|
3ab8e80f2a | ||
|
eb3823aa4a | ||
|
213be3777c | ||
|
2b7456f54b | ||
|
f48589738f | ||
|
f6bcdac258 | ||
|
14a5cc7e1a | ||
|
54b0381f4d | ||
|
e3d8e55a79 | ||
|
df141876d0 | ||
|
8abad1843a | ||
|
13c96ab7d0 | ||
|
69d682ef02 | ||
|
eb16e7a647 | ||
|
88052447b9 | ||
|
b6161dd439 | ||
|
9627432723 | ||
|
a9c98dff5d | ||
|
322f6cd805 | ||
|
34df24f4e2 | ||
|
c85f8462fd | ||
|
59d2f21369 | ||
|
25012517aa | ||
|
503fe35817 | ||
|
1ba1278b42 | ||
|
01e018eb0a | ||
|
5c06098caf | ||
|
a963ae5ea6 | ||
|
ca269f425c | ||
|
75ad499fb5 | ||
|
8c9e61373e | ||
|
1ce18f6698 | ||
|
85997107af | ||
|
2259f8da6f | ||
|
4f72043bcd | ||
|
6afdc89894 | ||
|
1bba69b108 | ||
|
e00847e711 | ||
|
2b8eec969b | ||
|
5ee7571761 | ||
|
4493a06878 | ||
|
515a7e8279 | ||
|
bb1bc2f07b | ||
|
2d03db8ef1 | ||
|
45568e8895 | ||
|
ee63a6f055 | ||
|
0f0e06c6b8 | ||
|
6fcdccaf83 | ||
|
c0d52ced18 | ||
|
f9e69b4090 | ||
|
f3da900c35 | ||
|
0769303075 | ||
|
01f414de59 | ||
|
65dde2cce3 | ||
|
49ef468e84 | ||
|
42f465f842 | ||
|
713104c2dc | ||
|
843eb3eae5 | ||
|
e75725ef37 | ||
|
d148121dad | ||
|
8a1f2579e9 | ||
|
2d846dd5f3 | ||
|
0c8352fc3e | ||
|
32ca0104a7 | ||
|
f9b310a8ca | ||
|
cda203a83f | ||
|
bff4dbd957 | ||
|
d7b83c0f7d | ||
|
9bf8fcc823 | ||
|
779787f980 | ||
|
7df7e16c56 | ||
|
dafdbb01ea | ||
|
7bccb2a280 | ||
|
ef062ac314 | ||
|
3b1d09702c | ||
|
3012ea43ee | ||
|
aee8519bac | ||
|
ba27149232 | ||
|
08dcab617e | ||
|
ccd44da4a2 | ||
|
c5d4bfe680 | ||
|
4fbaa032f0 | ||
|
65035706fb | ||
|
6dcf754077 | ||
|
d5a873e81c | ||
|
e7c3d04309 | ||
|
6fe46f61e2 | ||
|
61dd5dccab | ||
|
1d6350b1e5 | ||
|
9ac35a0a9c | ||
|
9e3bafcd4c | ||
|
a3ccf2967f | ||
|
611fd93308 | ||
|
c16aa1e5c4 | ||
|
fe887a2c83 | ||
|
26052486ee | ||
|
fb06428250 | ||
|
4f95463c75 | ||
|
cf5541d180 | ||
|
3c2aff82bc | ||
|
79901e494b | ||
|
7a1b441cf0 | ||
|
6d47d3b70f | ||
|
d546cda6d5 | ||
|
eb4390b5a6 | ||
|
92b1dbaf32 | ||
|
c5d3d9c188 | ||
|
c6619d042c | ||
|
7195448334 | ||
|
500728e51f | ||
|
4b66137654 | ||
|
14f913d6ab | ||
|
a911e33d7b | ||
|
fbb0ae1489 | ||
|
7a7a8125a9 | ||
|
f0940c2075 | ||
|
dc5f497495 | ||
|
4eb38c1051 | ||
|
e626ba2688 | ||
|
f2ab25cf98 | ||
|
aa903c675f | ||
|
4695c42b51 | ||
|
28378b81e8 | ||
|
c551ed3a62 | ||
|
aef71dbae5 | ||
|
cab3ba345c | ||
|
15798e6ebb | ||
|
0edb018465 | ||
|
a89447686c | ||
|
5ef2e27e8e | ||
|
01dccee231 | ||
|
83b4989bd4 | ||
|
561a79720e | ||
|
6dee79f442 | ||
|
dea63374f4 | ||
|
59f7a61661 | ||
|
ba8a972254 | ||
|
05c2278893 | ||
|
a73d2f7d94 | ||
|
bf6081b207 | ||
|
ac95449ff5 | ||
|
56e8de6b16 | ||
|
1a5aea5653 | ||
|
a0525ddd26 | ||
|
8714432a67 | ||
|
d96b6843b3 | ||
|
95e210521c | ||
|
6f01d7a34a | ||
|
feca084ed6 | ||
|
a1a3a712dd | ||
|
333e745d7b | ||
|
8c83e15404 | ||
|
fa2fec338b | ||
|
fcc7016124 | ||
|
a2d3364ec7 | ||
|
1c51a8e529 | ||
|
5287c234d6 | ||
|
f1ed49edec | ||
|
35ea6f2a56 | ||
|
d57f0ac93a | ||
|
755e8d322e | ||
|
25774ac82a | ||
|
9d4d7fd273 | ||
|
1ccbbf95b5 | ||
|
8bd463d4fc | ||
|
737e7a69c2 | ||
|
69911ad9ea | ||
|
f40822980e | ||
|
02180115bf | ||
|
262f769ece | ||
|
0198cad883 | ||
|
4b4cfca706 | ||
|
83e77559c4 | ||
|
29eea37b38 | ||
|
8500b3cd69 | ||
|
a8d6bdcac1 | ||
|
fcda7021b6 | ||
|
6b5e4dcec2 | ||
|
001718cf73 | ||
|
872f1139db | ||
|
02fed92074 | ||
|
f80a7724bf | ||
|
ac6842656e | ||
|
f90c684471 | ||
|
08791f496d | ||
|
6739c30941 | ||
|
42fec31784 | ||
|
e2524f80df | ||
|
72600b996e | ||
|
54e63dd9fe | ||
|
01516c9603 | ||
|
1f6a794b43 | ||
|
28d286ecb8 | ||
|
d737569574 | ||
|
4d3affb95d | ||
|
14944cd235 | ||
|
bbcf1c2009 | ||
|
b925abf403 | ||
|
03b1f18c89 | ||
|
7b0aa9d3bf | ||
|
3001e0c78a | ||
|
bcc66a739c | ||
|
81397f84bc | ||
|
9998ca7dd9 | ||
|
3a2996e5b0 | ||
|
199fd8218b | ||
|
282986c503 | ||
|
e5cf5dda39 | ||
|
c5ced60c38 | ||
|
01159d0721 | ||
|
59f9974baa | ||
|
3397fff8ea | ||
|
cdb598e67b | ||
|
c5f0565654 | ||
|
eb1236d5dd | ||
|
e408bf9a22 | ||
|
6a19824c12 | ||
|
7a13a940df | ||
|
7231d06a46 | ||
|
7f2511632f | ||
|
d610671327 | ||
|
cdf41a3144 | ||
|
51b118ef2f | ||
|
d17abeddb7 | ||
|
a7ec89a8a1 | ||
|
0a8e353e83 | ||
|
0efdcafe56 | ||
|
6fa2666747 | ||
|
fb2e45c579 | ||
|
4879efce58 | ||
|
5a109a99fb | ||
|
88a15daf93 | ||
|
a1cb756fa0 | ||
|
3031b7cf6a | ||
|
4ff25eb2a8 | ||
|
21fd41b9a9 | ||
|
7c5f4539e1 | ||
|
fd204874ec | ||
|
654a3c1f9f | ||
|
0feabeb7e8 | ||
|
55370c3453 | ||
|
f293371a9d | ||
|
9c2132f895 | ||
|
ff8c411749 | ||
|
4f783f61ed | ||
|
e1fa32f21f | ||
|
1929fbc0ba | ||
|
02f78e4ce5 | ||
|
b6d8f54779 | ||
|
6bab4e56fd | ||
|
9049a7e58d | ||
|
8c3b9758eb | ||
|
b974a4a683 | ||
|
5963c64960 | ||
|
bb18a5ba0a | ||
|
bed3ffb3dc | ||
|
ee90425de1 | ||
|
f57d39378d | ||
|
b1e1ea66f5 | ||
|
7121bd6fbf | ||
|
d2066da339 | ||
|
8cd78b6945 | ||
|
53669bc42e | ||
|
7897bb5c83 | ||
|
1367e7007f | ||
|
2b977f14c9 | ||
|
eb943d11d0 | ||
|
3489bdbe36 | ||
|
0ab47e1fc6 | ||
|
b2116fd9e9 | ||
|
f093d0cf6e | ||
|
5dfd1a24fc | ||
|
c29c84327a | ||
|
f8b159f8ff | ||
|
503b9c5bbf | ||
|
0a3bb4e8bd | ||
|
31c0b08548 | ||
|
59b97a57fc | ||
|
4eed15f87a | ||
|
772e50ba79 | ||
|
e963af53a5 | ||
|
61a1248262 | ||
|
db6d1a1293 | ||
|
9835f07179 | ||
|
c76f65a49a | ||
|
d756b534e3 | ||
|
2bb5bdb9fe | ||
|
f82ed08d6a | ||
|
b24fc9a8da | ||
|
3a302667a1 | ||
|
59aa5087fc | ||
|
602948f783 | ||
|
167461ccc4 | ||
|
5afe22030f | ||
|
9df7afd0a3 | ||
|
6af16764aa | ||
|
6b9b42f314 | ||
|
ebbd544d75 | ||
|
9c7e21fa47 | ||
|
36be4fe594 | ||
|
4604aee202 | ||
|
4e898b2a52 | ||
|
ae43a49b71 | ||
|
a0d60f233b | ||
|
199e609a79 | ||
|
fbc6bec12a | ||
|
56d63073b4 | ||
|
387d54fe9d | ||
|
6099804559 | ||
|
c1d9bde886 | ||
|
f9d65edf20 | ||
|
79d369db1f | ||
|
b3fb65edaa | ||
|
baad6b3819 | ||
|
c71bcdc92d | ||
|
f432204180 | ||
|
68efb709ed | ||
|
ec880947e0 | ||
|
342bf2947b | ||
|
74c79eb17c | ||
|
689aa4cdef | ||
|
d9b7055cbe | ||
|
b70e5adad0 | ||
|
a6ced1622c | ||
|
13a6b0c03a | ||
|
5f78b90572 | ||
|
466ff8c319 | ||
|
e91d1ec0a5 | ||
|
93f239f5cb | ||
|
256ee86104 | ||
|
692907761a | ||
|
5d5cc3a5db | ||
|
f5d911968f | ||
|
abf05e8bc8 | ||
|
5d88fa4a2c | ||
|
8271bbde06 | ||
|
0714e61545 | ||
|
ebc3dabd6d | ||
|
0e0d222ede | ||
|
f8877e2263 | ||
|
eb49b5776a | ||
|
977c65e9de | ||
|
7cbbd7305b | ||
|
8f126a1000 | ||
|
fb325f527b | ||
|
f1fc3c4948 | ||
|
1259b1d333 | ||
|
2cd0c91215 | ||
|
e8c2ba7eeb | ||
|
61a73d21e6 | ||
|
459ea9f486 | ||
|
3c475ab7da | ||
|
6124b1fae8 | ||
|
1bc84b837a | ||
|
65273e7a07 | ||
|
489154b342 | ||
|
84a05a6597 | ||
|
b532beccde | ||
|
554556e4d5 | ||
|
b75737fd6a | ||
|
6fedae386d | ||
|
11ff758c38 | ||
|
a149ebed16 | ||
|
cb75f00780 | ||
|
3a6362f1a9 | ||
|
c3eda40e01 | ||
|
2009598cdc | ||
|
74b325e71a | ||
|
54a61f7553 | ||
|
5f02b197dd | ||
|
1f73d1c771 | ||
|
dec9056511 | ||
|
e5c182591a | ||
|
5c086b0cd5 | ||
|
0b76278adc | ||
|
4bc99d8047 | ||
|
e60d4368ed | ||
|
d159bec46a | ||
|
a7c9f5b941 | ||
|
247ceff7a7 | ||
|
953796645f | ||
|
14f4362bb5 | ||
|
db9829d702 | ||
|
6cc353f8a2 | ||
|
ff14ad3425 | ||
|
19511463ab | ||
|
d35f0596d1 | ||
|
b1982cc68a | ||
|
88241b32ee | ||
|
bec509d5b8 | ||
|
bd961c4da2 | ||
|
c8b8b5c1d0 | ||
|
002c6e2a5e | ||
|
6a286c7ac2 | ||
|
bf51fc8650 | ||
|
cb4f1ff63a | ||
|
176b4bf8f7 | ||
|
dca32e5cf3 | ||
|
fb6334287a | ||
|
9127d6334e | ||
|
17a1c72f41 | ||
|
6f36340888 | ||
|
7520e16340 | ||
|
9c76fdc3bb | ||
|
006c66e488 | ||
|
834c1eac44 | ||
|
34a42a8fa1 | ||
|
8e1ff0785a | ||
|
cbd19b6052 | ||
|
410393fefa | ||
|
b3a34de3ce | ||
|
f432018bdb | ||
|
9ede58f2b7 | ||
|
37dd7c17df | ||
|
8096bd869f | ||
|
f027667daa | ||
|
765e1ad0c6 | ||
|
983087b5c5 | ||
|
f6acf4c027 | ||
|
85736c4c95 | ||
|
68528ffb28 | ||
|
29cd904c5f | ||
|
f68f7e88de | ||
|
45fd654898 | ||
|
b11ef9d44b | ||
|
691d385687 | ||
|
99d8c3e503 | ||
|
695ad02cb2 | ||
|
96a8327d06 | ||
|
0eb0408cc3 | ||
|
3eb00b9794 | ||
|
096befe69e | ||
|
0084628d61 | ||
|
07546fe098 | ||
|
744aa2a76a | ||
|
9213f76d49 | ||
|
f447cad781 | ||
|
9a132080b5 | ||
|
8de67bc262 | ||
|
3990fbe1dd | ||
|
e3789e219a | ||
|
f390a830ae | ||
|
6254f7c09e | ||
|
7d46eda60d | ||
|
895d89a125 | ||
|
d86a90a10a | ||
|
e6f6d0f133 | ||
|
5420ccd6af | ||
|
621ab99961 | ||
|
fe3160ca99 | ||
|
f6b7bc0867 | ||
|
945e57286b | ||
|
c945dd7195 | ||
|
16b98fe3e7 | ||
|
a2df8b7ad2 | ||
|
a06e4efcb1 | ||
|
64054fade4 | ||
|
75643e6f68 | ||
|
4227fd5d69 | ||
|
3ae38bbab1 | ||
|
309c7b3422 | ||
|
12cdc1af69 | ||
|
f9b18c3614 | ||
|
8cba41b2d8 | ||
|
5abb40e3be | ||
|
c6fc956a77 | ||
|
3a58dd89b5 | ||
|
a9d9f7ed99 | ||
|
4fbf8a054f | ||
|
7ecff4b693 | ||
|
7d1a559ae2 | ||
|
fba418d20b | ||
|
277de45dbc | ||
|
adced85761 | ||
|
5629a6fb6f | ||
|
d6d69df498 | ||
|
ea7003628f | ||
|
9cb1b7e37f | ||
|
8913b673c3 | ||
|
6e40d4bcf7 | ||
|
4bd05cec22 | ||
|
8901fd0fa5 | ||
|
e45b7571a8 | ||
|
1079264aea | ||
|
ed1696db4a | ||
|
cc78a5de78 | ||
|
a14d27f090 | ||
|
8f3dded093 | ||
|
d0b40f62dc | ||
|
9bfe888cef | ||
|
52ae365c66 | ||
|
cb638eaabf | ||
|
3e178a2153 | ||
|
11cbc189f3 | ||
|
657442947b | ||
|
ddd2ceae63 | ||
|
e3f4e76c47 | ||
|
5a73efbb07 | ||
|
1784c4f03e | ||
|
d26fc722d5 | ||
|
8d73767949 | ||
|
0d693b151d | ||
|
c69e467ad0 | ||
|
2ddbff46d5 | ||
|
cc9e8e3db3 | ||
|
27bf941211 | ||
|
b6e567d87c | ||
|
4d54e81889 | ||
|
8a90551b63 | ||
|
00b888c1ef | ||
|
3be9ce8fa0 | ||
|
be017f1945 | ||
|
6f4c15d077 | ||
|
3dee9b634f | ||
|
82533b2f7a | ||
|
0636734f8f | ||
|
39202f5ac0 | ||
|
26d3084ead | ||
|
2e78959435 | ||
|
65dce899cb | ||
|
b22d5d2fac | ||
|
720fbc74a1 | ||
|
c7d29b826f | ||
|
7e604ed8b0 | ||
|
ba4ad23af8 | ||
|
ed194a3c09 | ||
|
53f8c49620 | ||
|
d87cf7db48 | ||
|
b6e9711add | ||
|
97e33ec8ca | ||
|
cab05f1f2c | ||
|
c30adf39c8 | ||
|
4276f01404 | ||
|
fe893134a5 | ||
|
c4fda867c0 | ||
|
1a0b1a1e77 | ||
|
7f54e94748 | ||
|
4e26d2a7d6 | ||
|
0420b13055 | ||
|
60a33a9b8f | ||
|
44982cddc5 | ||
|
b4b5f393e3 | ||
|
222835e73a | ||
|
c5f3e6c654 | ||
|
0bddff6977 | ||
|
d38d16ade9 | ||
|
f19bd188c2 | ||
|
538eb20264 | ||
|
59e5f50e26 | ||
|
7f2c8b756a | ||
|
44198d1ac2 | ||
|
cfa5809cd2 | ||
|
94dd756669 | ||
|
5482d8c7e2 | ||
|
29069560a9 | ||
|
6f6a0ed1ef | ||
|
fc25053e8b | ||
|
9dac8dcc34 | ||
|
a5a24f0260 | ||
|
838c88b318 | ||
|
77483e4266 | ||
|
e82c6e65fb | ||
|
bf6ce8dd8d | ||
|
9e82006314 | ||
|
f33e318ac5 | ||
|
b84c414f2e | ||
|
7003255c0e | ||
|
33fac6d47d | ||
|
370f38a2c3 | ||
|
f2732ed517 | ||
|
e72803935a | ||
|
05d488f98d | ||
|
8aae32ec4c | ||
|
1edd3b7a93 | ||
|
dec6bc0950 | ||
|
0842d0af6f | ||
|
c9da5cbd8e | ||
|
b60de49388 | ||
|
0b4f3dc497 | ||
|
fdf60044c3 | ||
|
162ac80675 | ||
|
d1697efe6d | ||
|
cea7821722 | ||
|
2dcb31cd01 | ||
|
a3086c06a5 | ||
|
c61d0d541d | ||
|
297126906d | ||
|
d5a7c9e214 | ||
|
f6fda91717 | ||
|
b541c3595f | ||
|
65d2d9d188 | ||
|
a25f53e667 | ||
|
08ccaf109b | ||
|
e80dd063ba | ||
|
699b3c11d9 | ||
|
931dc8921c | ||
|
a0ea7db1a7 | ||
|
b504a86696 | ||
|
8c4313f1b5 | ||
|
8a44f7ffbb | ||
|
05546b2053 | ||
|
f68a147ff4 | ||
|
7d1bfaeb4b | ||
|
ef2adc855c | ||
|
b617197aba | ||
|
3dfac03633 | ||
|
fa714f2a01 | ||
|
f104edbefb | ||
|
c191e196c0 | ||
|
01a4057317 | ||
|
e90a4fca7d | ||
|
563bb00de5 | ||
|
45168024a9 | ||
|
b890dc2775 | ||
|
6f83cdf572 | ||
|
a74543a145 | ||
|
ac19076f0b | ||
|
f04ab0cbae | ||
|
201268334d | ||
|
831e353c5d | ||
|
dc15e70f79 | ||
|
88f3b29a92 | ||
|
cdcc97ac4b | ||
|
ddf0f337c2 | ||
|
783437f16b | ||
|
918e1a3a90 | ||
|
46478d4b5a | ||
|
0db5d6231f | ||
|
1377ec9752 | ||
|
ab03726659 | ||
|
b1185fc099 | ||
|
653bd92ce9 | ||
|
2dde0eb257 | ||
|
c2b1103cb6 | ||
|
23492d6742 | ||
|
16ae1c0472 | ||
|
19a979955e | ||
|
27a4d60026 | ||
|
d2ba5e5eec | ||
|
bcb1e67507 | ||
|
e583063ab5 | ||
|
bcb4f2020e | ||
|
abcd96be0e | ||
|
91b868d7ad | ||
|
2344fe3ac2 | ||
|
940f0dc39d | ||
|
def1994856 | ||
|
9406eb4c44 | ||
|
65e98c1940 | ||
|
c08b639902 | ||
|
c6cd132c31 | ||
|
7dcf5ee082 | ||
|
46de0f661b | ||
|
3b188b4c26 | ||
|
90a1b65081 | ||
|
da69fdf66b | ||
|
982f156995 | ||
|
85aad2ec32 | ||
|
c067eb7eec | ||
|
493eaa4d18 | ||
|
776fa0d2f8 | ||
|
692fc7f107 | ||
|
fcec445a2e | ||
|
d42d2740f3 | ||
|
384158fa7c | ||
|
d823378260 | ||
|
18c1a99604 | ||
|
86e70a726d | ||
|
2ceac9b496 | ||
|
17de0f89ed | ||
|
2929c4ae6d | ||
|
a6057af11f | ||
|
f432f5f1cc | ||
|
eff8890b4f | ||
|
5d51bdde7a | ||
|
d0f7b405a6 | ||
|
b4bce33b34 | ||
|
a33e984dbd | ||
|
6a7317d354 | ||
|
b50498cb53 | ||
|
a6e0b6b857 | ||
|
9275ca9373 | ||
|
8a1fdb3900 | ||
|
2b8226316f | ||
|
6a3452da96 | ||
|
ee28954786 | ||
|
74b2886036 | ||
|
99b25c72d9 | ||
|
c2251faa91 | ||
|
242c9eba3c | ||
|
22f913d892 | ||
|
8b27aba0c4 | ||
|
1a87e920da | ||
|
cfbc044fd2 | ||
|
f400f17c75 | ||
|
7f0daee8b3 | ||
|
33a42303d1 | ||
|
8a0dca38a3 | ||
|
3683c30557 | ||
|
af842a8bf9 | ||
|
686355cbbe | ||
|
acbf80677a | ||
|
4a93209423 | ||
|
6e71bad70c | ||
|
b796cc9912 | ||
|
ace2baafbd | ||
|
50caf755c3 | ||
|
7cf93eb70f | ||
|
f930bea045 | ||
|
174c82662d | ||
|
fed8effb67 | ||
|
64462b8dca | ||
|
39b6dca059 | ||
|
70fbdd21c7 | ||
|
5eca7731e9 | ||
|
93d0eea8af | ||
|
65080e2a95 | ||
|
c819a03bb3 | ||
|
93c566638f | ||
|
5fe0dda890 | ||
|
1ddd3afc51 | ||
|
774a618d13 | ||
|
bdf7876652 | ||
|
67dbb96580 | ||
|
f1d07d6718 | ||
|
a98d1b8071 | ||
|
4c31bd16d2 | ||
|
69c317cd1f | ||
|
68a7f5f63c | ||
|
1e6feecb91 | ||
|
f84191204e | ||
|
32e7202223 | ||
|
e11f3a660a | ||
|
a0a2c78950 | ||
|
187c1df332 | ||
|
0a6e82e555 | ||
|
7c4ccf0209 | ||
|
354be41811 | ||
|
65f3bb75dd | ||
|
d70c2d978c | ||
|
5091a4ba9d | ||
|
fa55e3dfa9 | ||
|
25f0ef09a5 | ||
|
c2c00570b3 | ||
|
b20e42ba3f | ||
|
fb8e75afec | ||
|
558dcdb7d0 | ||
|
249c4b6c6c | ||
|
ae3a9404b7 | ||
|
62912d25af | ||
|
d4f113e302 | ||
|
947e424f56 | ||
|
2a98fe0155 | ||
|
9a30fda852 | ||
|
abbe44db6d | ||
|
c389cdc562 | ||
|
70a511165b | ||
|
e9befd9057 | ||
|
15f953672d | ||
|
2c2669d655 | ||
|
735acb297a | ||
|
df0ba4a777 | ||
|
81183d6fe6 | ||
|
2977688a8a | ||
|
9d44a73ad0 | ||
|
7db6b0c9f0 | ||
|
c81a40d9eb | ||
|
ba0e13c812 | ||
|
51065985df | ||
|
9e3014494c | ||
|
178edb9da6 | ||
|
bdaf7813af | ||
|
2e82c17d92 | ||
|
58592ed597 | ||
|
04e1f82734 | ||
|
d62e215ff9 | ||
|
e31578045e | ||
|
b417ddf32d | ||
|
89d0c6da19 | ||
|
16eb870303 | ||
|
a17de02ce4 | ||
|
a2af3a53fa | ||
|
4531393367 | ||
|
e63003a6e0 | ||
|
9baa10d135 | ||
|
5544c4c74f | ||
|
6befc23101 | ||
|
42d3f2d0d3 | ||
|
d60be13ed8 | ||
|
a914047770 | ||
|
c458cf0c57 | ||
|
1d7fc9c070 | ||
|
434511ca3b | ||
|
7673bbe827 | ||
|
e9ebc938e0 | ||
|
712cce8213 | ||
|
4753aeb73a | ||
|
25f1b8cb18 | ||
|
10aaf85f54 | ||
|
4f570413ba | ||
|
9cd40947d8 | ||
|
7c8215dfda | ||
|
977c86af6c | ||
|
8e11ef3fd7 | ||
|
a396282189 | ||
|
e84fbf1523 | ||
|
95d5fabad0 | ||
|
16501f8641 | ||
|
102fc3eaf9 | ||
|
0becc1c5e9 | ||
|
0195047d7a | ||
|
b7e486d3c3 | ||
|
846e961b05 | ||
|
d75a73a727 | ||
|
c2fe73ecbe | ||
|
051f2fa906 | ||
|
3deb55cc5f | ||
|
89b5cb4f22 | ||
|
ab05de48df | ||
|
497055d80d | ||
|
23755a527a | ||
|
b1a19bc13c | ||
|
d8dbe11fd0 | ||
|
871991dced | ||
|
4691315e5a | ||
|
8af9bfe8e0 | ||
|
3171b89fea | ||
|
0a2be27ba9 | ||
|
b7bdd08837 | ||
|
664d3508de | ||
|
c946620fec | ||
|
9e79e1edf1 | ||
|
def0fd1f31 | ||
|
b392b8214e | ||
|
fe5c4bb978 | ||
|
82fb67441f | ||
|
f04248e57d | ||
|
d2d587cb1b | ||
|
1ddfe6c315 | ||
|
f7098a8a7e | ||
|
a217b38fd5 | ||
|
25e4bb3f6c | ||
|
65b4afdfc1 | ||
|
caa2a88177 | ||
|
ae6c9c7e37 | ||
|
ac50139c54 | ||
|
a8d7fc1cfb | ||
|
c737f4d56f | ||
|
030b0de105 | ||
|
934124d30c | ||
|
eb1a32eb79 | ||
|
5b8b75e680 | ||
|
abce91a180 | ||
|
3ad43a33ae | ||
|
fb8cbb6848 | ||
|
60c505d08b | ||
|
37b7f05180 | ||
|
3ebbf2075f | ||
|
c12f11fe42 | ||
|
765406f9a7 | ||
|
8876d13356 | ||
|
ff56c86446 | ||
|
cec5e0e391 | ||
|
b77ad659d8 | ||
|
2a090aa799 | ||
|
c5e91a5c1e | ||
|
cdb301b357 | ||
|
bac24cd844 | ||
|
d43c4c1812 | ||
|
429d79c81d | ||
|
a2f596951e | ||
|
b8e6a0accc | ||
|
6815ac2869 | ||
|
17a98767b4 | ||
|
4c444d0082 | ||
|
533c6d6e5b | ||
|
2a594d4f0e | ||
|
b6c451d7e3 | ||
|
e08786b5fb | ||
|
3976014dcd | ||
|
15f16ce6ec | ||
|
f117546f73 | ||
|
976555041d | ||
|
3e6d4aa58a | ||
|
1adebaaf73 | ||
|
f10e051e17 | ||
|
d4826eea6f | ||
|
f4f63a1006 | ||
|
953d1d1a01 | ||
|
c975c1b6b8 | ||
|
69c3ee550d | ||
|
5aebd821f6 | ||
|
828346add3 | ||
|
223a240751 | ||
|
fb5ca1bb8e | ||
|
2461058ecc | ||
|
0c5d167028 | ||
|
22d0cb72fd | ||
|
c6b9036002 | ||
|
8bc236ba7b | ||
|
4e160acc88 | ||
|
99038229f7 | ||
|
a97eace434 | ||
|
da8b5c46d7 | ||
|
ec53f3d879 | ||
|
ab4e1b77d0 | ||
|
e5e0b7674a | ||
|
43a9f70314 | ||
|
5ab6db2607 | ||
|
b193d03151 | ||
|
2aab39b8e7 | ||
|
3af3286436 | ||
|
f6b11b86a8 | ||
|
ff31c6d6eb | ||
|
a04ca98c6b | ||
|
c24568f033 | ||
|
e2d741bdb7 | ||
|
45d4d5afb3 | ||
|
c29f944726 | ||
|
92afd0bebf | ||
|
50169e95b2 | ||
|
a67f5abb67 | ||
|
7febf6c24a | ||
|
f52a0fa4f6 | ||
|
ea7ba2c099 | ||
|
e243e16fd9 | ||
|
43d7278352 | ||
|
54532cecb5 | ||
|
5507ab817a | ||
|
5d9a5b99a5 | ||
|
bfb071233e | ||
|
92150e9ca9 | ||
|
851708c26e | ||
|
a04caf339e | ||
|
8cd2ae322e | ||
|
cf6b88f8da | ||
|
ce12610adc | ||
|
a790d8cdb9 | ||
|
047c3f4bba | ||
|
c18730a182 | ||
|
58d7c72a22 | ||
|
a780581ebc | ||
|
5732df452c | ||
|
a2b7f642e0 | ||
|
5e06dfb50b | ||
|
f32f3b34ae | ||
|
3cb74f0871 | ||
|
97f520c7cf | ||
|
2cd335509b | ||
|
fe268b0e71 | ||
|
5db45d9fa3 | ||
|
4aaba786fa | ||
|
8258c7e621 | ||
|
00a8aba245 | ||
|
142c0373d7 | ||
|
9f4e5844c4 | ||
|
c2ca920181 | ||
|
1ad3ae044b | ||
|
26a1c79efb | ||
|
98c26bcae0 | ||
|
743c14d3ff | ||
|
1a338bb924 | ||
|
be5085d2e9 | ||
|
0a4214fe36 | ||
|
2271e4a5a4 | ||
|
62b10d83be | ||
|
05849f0da5 | ||
|
f02a259011 | ||
|
e5b837ff97 | ||
|
cdd8b35112 | ||
|
4952baf494 | ||
|
8c7d7e25cd | ||
|
8347778abb | ||
|
8dc1456766 | ||
|
de9364d447 | ||
|
377253bcc8 | ||
|
43ea5dcb82 | ||
|
eefe3de34b | ||
|
71321e8e6b | ||
|
53ad3f0fe8 | ||
|
94ce4d530a | ||
|
f3cf1ad388 | ||
|
304cce8efa | ||
|
3d4963f40c | ||
|
afb2af84f7 | ||
|
f210699884 | ||
|
143d1e57cf | ||
|
e9f912bba9 | ||
|
fa96232258 | ||
|
5d5ef602be | ||
|
13d678d9af | ||
|
c07397e71b | ||
|
5a87d8fef9 | ||
|
d14203561d | ||
|
c7c10fed46 | ||
|
c80cde6044 | ||
|
acec6ae824 | ||
|
e54287293f | ||
|
8bc080c7b8 | ||
|
02c6124559 | ||
|
01574e8038 | ||
|
797e8c7553 | ||
|
e97759d01b | ||
|
aafc5d6d51 | ||
|
f19ca6672e | ||
|
04f9db4b18 | ||
|
6e9c56ee2c | ||
|
6777721391 | ||
|
b2f3fdb73b | ||
|
ebb8d3b3ed | ||
|
3135d58a40 | ||
|
13ff9e1706 | ||
|
4bc7ec73de | ||
|
01bf0fb6ce | ||
|
8689048ba6 | ||
|
9b0fd7a8d7 | ||
|
40c51c469c | ||
|
6c19efa990 | ||
|
d81a7610d3 | ||
|
541c1a35a0 | ||
|
94ef6170d8 | ||
|
2aa0ce9d74 | ||
|
a682575da2 | ||
|
2426a44671 | ||
|
e00152b262 | ||
|
4064c8ae8e | ||
|
947ce9a8d1 | ||
|
e0a251c456 | ||
|
0c814dbeb0 | ||
|
eee92a5420 | ||
|
9cea9707f3 | ||
|
3bbb5f413a | ||
|
dd507550c9 | ||
|
2715500533 | ||
|
28ffa84d44 | ||
|
8d3c08f3ef | ||
|
fc3d194ad2 | ||
|
217d18a996 | ||
|
63df9eecff | ||
|
442cc281e1 |
2571 changed files with 516926 additions and 74052 deletions
94
.clang-format
Normal file
94
.clang-format
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
Language: Cpp
|
||||||
|
AccessModifierOffset: -2
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignArrayOfStructures: None
|
||||||
|
AlignConsecutiveAssignments: None
|
||||||
|
AlignConsecutiveDeclarations: None
|
||||||
|
AlignConsecutiveMacros: Consecutive
|
||||||
|
AlignEscapedNewlines: Right
|
||||||
|
AlignOperands: Align
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllArgumentsOnNextLine: false
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
AllowShortBlocksOnASingleLine: Empty
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortEnumsOnASingleLine: true
|
||||||
|
AllowShortFunctionsOnASingleLine: Inline
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLambdasOnASingleLine: Inline
|
||||||
|
# AlwaysBreakAfterReturnType:
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
BinPackArguments: false
|
||||||
|
BitFieldColonSpacing: After
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
|
AfterClass: true
|
||||||
|
AfterControlStatement: Always
|
||||||
|
AfterEnum: false # see AllowShortEnumsOnASingleLine
|
||||||
|
AfterFunction: true # see AllowShortFunctionsOnASingleLine
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterStruct: true
|
||||||
|
AfterExternBlock: false
|
||||||
|
BeforeCatch: true
|
||||||
|
BeforeElse: true
|
||||||
|
BeforeLambdaBody: false
|
||||||
|
BeforeWhile: false
|
||||||
|
SplitEmptyFunction: false
|
||||||
|
SplitEmptyRecord: false
|
||||||
|
SplitEmptyNamespace: false
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeConceptDeclarations: false
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializers: BeforeComma
|
||||||
|
BreakInheritanceList: AfterComma
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 120
|
||||||
|
CompactNamespaces: false
|
||||||
|
ContinuationIndentWidth: 2
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DeriveLineEnding: true
|
||||||
|
EmptyLineAfterAccessModifier: Leave
|
||||||
|
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||||
|
FixNamespaceComments: true
|
||||||
|
IncludeBlocks: Preserve
|
||||||
|
IndentCaseBlocks: false
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentExternBlock: NoIndent
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentRequires: true
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
LambdaBodyIndentation: Signature
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: None
|
||||||
|
# PackConstructorInitializers: CurrentLine # only clang-format > 14
|
||||||
|
PointerAlignment: Left
|
||||||
|
#QualifierAlignment: Left # only clang-format > 14
|
||||||
|
ReferenceAlignment: Left
|
||||||
|
ReflowComments: true
|
||||||
|
SortIncludes: Never
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: false
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
Standard: c++14
|
||||||
|
BinPackParameters: false
|
||||||
|
BreakBeforeInheritanceComma: false
|
||||||
|
IncludeCategories:
|
||||||
|
# Headers in <> without extension.
|
||||||
|
- Regex: '<([A-Za-z0-9\Q/-_\E])+>'
|
||||||
|
Priority: 1
|
||||||
|
# Headers in <> from specific external libraries.
|
||||||
|
- Regex: '<(boost)\/'
|
||||||
|
Priority: 2
|
||||||
|
# Headers in <> from specific external libraries.
|
||||||
|
- Regex: '<(mapnik)\/'
|
||||||
|
Priority: 3
|
||||||
|
# Headers in <> with extension.
|
||||||
|
- Regex: '<([A-Za-z0-9.\Q/-_\E])+>'
|
||||||
|
Priority: 4
|
||||||
|
# Headers in "" with extension.
|
||||||
|
- Regex: '"([A-Za-z0-9.\Q/-_\E])+"'
|
||||||
|
Priority: 5
|
1
.gitattributes
vendored
1
.gitattributes
vendored
|
@ -1 +1,2 @@
|
||||||
*.svg text eol=lf
|
*.svg text eol=lf
|
||||||
|
scons/** linguist-vendored
|
||||||
|
|
85
.github/actions/run_tests/action.yml
vendored
Normal file
85
.github/actions/run_tests/action.yml
vendored
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
name: Run tests with coverage
|
||||||
|
description: Runs all mapnik tests with coverage
|
||||||
|
inputs:
|
||||||
|
cmake-preset:
|
||||||
|
description: The used CMake preset
|
||||||
|
required: true
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: Set PROJ_LIB
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cmake --preset ${{ inputs.cmake-preset }} -N -L | grep -o "PROJ_LIB=.*" >> ${GITHUB_ENV}
|
||||||
|
|
||||||
|
- name: Set TEST_WRAPPER (Windows)
|
||||||
|
if: runner.os == 'Windows'
|
||||||
|
shell: bash
|
||||||
|
run: |-
|
||||||
|
echo "TEST_WRAPPER=OpenCppCoverage \
|
||||||
|
--cover_children \
|
||||||
|
--export_type binary \
|
||||||
|
--modules '*.input' \
|
||||||
|
--modules '*libmapnik*' \
|
||||||
|
--modules 'mapnik*.exe' \
|
||||||
|
--quiet \
|
||||||
|
--sources '${{ github.workspace }}' \
|
||||||
|
--" >> ${GITHUB_ENV}
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
UPDATE: 1
|
||||||
|
run: |
|
||||||
|
${TEST_WRAPPER:-} ctest --preset ${{ inputs.cmake-preset }}
|
||||||
|
|
||||||
|
- name: Test visuals
|
||||||
|
continue-on-error: true
|
||||||
|
working-directory: build/out
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
${TEST_WRAPPER:-} ./mapnik-test-visual -j ${CTEST_PARALLEL_LEVEL} --output-dir visual-test-result
|
||||||
|
|
||||||
|
- name: Pack visual test results
|
||||||
|
working-directory: build/out
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
tar -vzcf visual-test-results.tar.gz visual-test-result
|
||||||
|
|
||||||
|
- name: Upload visual test results
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ inputs.cmake-preset }}-visual-tests-${{ github.sha }}
|
||||||
|
path: build/out/visual-test-results.tar.gz
|
||||||
|
|
||||||
|
- name: Run Benchmarks (Linux & macOS)
|
||||||
|
working-directory: build/out
|
||||||
|
if: runner.os != 'Windows'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
./run_benchmarks
|
||||||
|
|
||||||
|
- name: Collect coverage (Linux & macOS)
|
||||||
|
working-directory: build
|
||||||
|
if: runner.os != 'Windows'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ "${RUNNER_OS}" == "macOS" ]; then
|
||||||
|
LCOV_EXTRA_OPTIONS="--ignore-errors count,gcov,inconsistent,range,unused --keep-going"
|
||||||
|
fi
|
||||||
|
lcov ${LCOV_EXTRA_OPTIONS:-} --directory . --capture --output-file coverage.info
|
||||||
|
lcov ${LCOV_EXTRA_OPTIONS:-} --remove coverage.info '/usr/*' '*/vcpkg_installed/*' '/.cache/*' '*/test/*' --output-file coverage.info
|
||||||
|
lcov ${LCOV_EXTRA_OPTIONS:-} --list coverage.info
|
||||||
|
|
||||||
|
- name: Upload coverage to Codecov (Linux & macOS)
|
||||||
|
if: runner.os != 'Windows'
|
||||||
|
uses: codecov/codecov-action@v4
|
||||||
|
with:
|
||||||
|
files: build/coverage.info
|
||||||
|
|
||||||
|
- name: Upload coverage to Codecov (Windows)
|
||||||
|
if: runner.os == 'Windows'
|
||||||
|
uses: codecov/codecov-action@v4
|
||||||
|
with:
|
||||||
|
files: ctest.cov,build/out/mapnik-test-visual.cov
|
136
.github/workflows/build_and_test.yml
vendored
Normal file
136
.github/workflows/build_and_test.yml
vendored
Normal file
|
@ -0,0 +1,136 @@
|
||||||
|
name: Build and Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "*"
|
||||||
|
pull_request:
|
||||||
|
branches-ignore:
|
||||||
|
- "no-ci-*"
|
||||||
|
|
||||||
|
env:
|
||||||
|
VCPKG_BINARY_SOURCES: clear;x-gha,readwrite
|
||||||
|
VCPKG_RELEASE: 2024.06.15
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
checkSource:
|
||||||
|
name: Check Source Code
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: "3.10"
|
||||||
|
- uses: pre-commit/action@v3.0.1
|
||||||
|
|
||||||
|
buildAndTest:
|
||||||
|
name: >-
|
||||||
|
Build & Test
|
||||||
|
(${{ matrix.os }})
|
||||||
|
(C++ ${{ matrix.cxx-standard }})
|
||||||
|
${{ startsWith(matrix.os, 'macos-') && (matrix.os == 'macos-14' && '(ARM64)' || '(AMD64)') || '' }}
|
||||||
|
needs: checkSource
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- macos-14
|
||||||
|
- ubuntu-22.04
|
||||||
|
- windows-2022
|
||||||
|
cxx-standard:
|
||||||
|
- 17
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Mapnik
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Checkout vcpkg
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
path: vcpkg
|
||||||
|
ref: ${{ env.VCPKG_RELEASE }}
|
||||||
|
repository: microsoft/vcpkg
|
||||||
|
|
||||||
|
- name: Export GitHub Actions cache environment variables
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||||
|
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||||
|
|
||||||
|
- name: Install required system packages
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ "${RUNNER_OS}" == "Linux" ]; then
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get -y install \
|
||||||
|
autoconf \
|
||||||
|
autoconf-archive \
|
||||||
|
automake \
|
||||||
|
gperf \
|
||||||
|
lcov \
|
||||||
|
libxxf86vm-dev \
|
||||||
|
ninja-build \
|
||||||
|
postgresql-client
|
||||||
|
elif [ "${RUNNER_OS}" == "macOS" ]; then
|
||||||
|
brew install \
|
||||||
|
autoconf \
|
||||||
|
autoconf-archive \
|
||||||
|
automake \
|
||||||
|
lcov \
|
||||||
|
libtool \
|
||||||
|
ninja \
|
||||||
|
vcpkg
|
||||||
|
elif [ "${RUNNER_OS}" == "Windows" ]; then
|
||||||
|
choco install \
|
||||||
|
ninja \
|
||||||
|
OpenCppCoverage
|
||||||
|
echo "C:\Program Files\OpenCppCoverage" >> ${GITHUB_PATH}
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Enable Developer Command Prompt (Windows)
|
||||||
|
uses: ilammy/msvc-dev-cmd@v1
|
||||||
|
if: runner.os == 'Windows'
|
||||||
|
|
||||||
|
- name: Set CMAKE_BUILD_PARALLEL_LEVEL, CTEST_PARALLEL_LEVEL & PRESET
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
PRESET=$(echo "${RUNNER_OS}" | perl -ne "print lc")-ci
|
||||||
|
if [ "${RUNNER_OS}" == "Linux" ]; then
|
||||||
|
echo "CMAKE_BUILD_PARALLEL_LEVEL=$(nproc)" >> ${GITHUB_ENV}
|
||||||
|
echo "CTEST_PARALLEL_LEVEL=$(nproc)" >> ${GITHUB_ENV}
|
||||||
|
elif [ "${RUNNER_OS}" == "macOS" ]; then
|
||||||
|
echo "CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu)" >> ${GITHUB_ENV}
|
||||||
|
echo "CTEST_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu)" >> ${GITHUB_ENV}
|
||||||
|
PRESET=${PRESET}-${{ matrix.os == 'macos-14' && 'arm64' || 'x64' }}
|
||||||
|
elif [ "${RUNNER_OS}" == "Windows" ]; then
|
||||||
|
echo "CMAKE_BUILD_PARALLEL_LEVEL=$(pwsh -Command '(Get-CimInstance -ClassName Win32_ComputerSystem).NumberOfLogicalProcessors')" >> ${GITHUB_ENV}
|
||||||
|
echo "CTEST_PARALLEL_LEVEL=$(pwsh -Command '(Get-CimInstance -ClassName Win32_ComputerSystem).NumberOfLogicalProcessors')" >> ${GITHUB_ENV}
|
||||||
|
fi
|
||||||
|
echo "PRESET=${PRESET}" >> ${GITHUB_ENV}
|
||||||
|
|
||||||
|
- name: Configure CMake
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cmake \
|
||||||
|
-DBUILD_SHARED_LIBS:BOOL=ON \
|
||||||
|
-DCMAKE_CXX_STANDARD:STRING=${{ matrix.cxx-standard }} \
|
||||||
|
-DUSE_MEMORY_MAPPED_FILE:BOOL=ON \
|
||||||
|
-LA \
|
||||||
|
--preset ${PRESET}
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cmake \
|
||||||
|
--build \
|
||||||
|
--preset ${PRESET}
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
uses: ./.github/actions/run_tests
|
||||||
|
with:
|
||||||
|
cmake-preset: ${{ env.PRESET }}
|
55
.github/workflows/release_linux.yml
vendored
Normal file
55
.github/workflows/release_linux.yml
vendored
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
name: Release Linux
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "*"
|
||||||
|
pull_request:
|
||||||
|
branches-ignore:
|
||||||
|
- "no-ci-*"
|
||||||
|
env:
|
||||||
|
PRESET: linux-ci-release
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: "ubuntu-22.04"
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: checkout mapnik
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: "recursive"
|
||||||
|
|
||||||
|
- name: "Install required system packages"
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install -y ninja-build\
|
||||||
|
libicu-dev \
|
||||||
|
libfreetype6-dev \
|
||||||
|
libharfbuzz-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
libjpeg-dev \
|
||||||
|
libtiff-dev \
|
||||||
|
libwebp-dev \
|
||||||
|
libcairo2-dev \
|
||||||
|
libproj-dev \
|
||||||
|
libgdal-dev \
|
||||||
|
libboost-filesystem-dev \
|
||||||
|
libboost-program-options-dev \
|
||||||
|
libboost-regex-dev
|
||||||
|
|
||||||
|
- name: Configure CMake
|
||||||
|
run: cmake -LA --preset ${{ env.PRESET }}
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build --preset ${{ env.PRESET }}
|
||||||
|
|
||||||
|
- name: Package
|
||||||
|
run: cmake --build --preset ${{ env.PRESET }} --target package
|
||||||
|
|
||||||
|
- name: Upload mapnik debian package
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ env.PRESET }}-deb
|
||||||
|
path: build/mapnik-*.deb
|
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,4 +1,6 @@
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.vscode
|
||||||
|
.cache
|
||||||
*.gcov
|
*.gcov
|
||||||
*.gcda
|
*.gcda
|
||||||
*.gcno
|
*.gcno
|
||||||
|
@ -56,3 +58,8 @@ demo/viewer/ui_layer_info.h
|
||||||
test/standalone/*-bin
|
test/standalone/*-bin
|
||||||
test/unit/run
|
test/unit/run
|
||||||
test/visual/run
|
test/visual/run
|
||||||
|
# cmake
|
||||||
|
build
|
||||||
|
.vs
|
||||||
|
|
||||||
|
CMakeUserPresets.json
|
||||||
|
|
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -18,3 +18,6 @@
|
||||||
path = deps/mapbox/protozero
|
path = deps/mapbox/protozero
|
||||||
url = https://github.com/mapbox/protozero.git
|
url = https://github.com/mapbox/protozero.git
|
||||||
branch = master
|
branch = master
|
||||||
|
[submodule "deps/mapbox/polylabel"]
|
||||||
|
path = deps/mapbox/polylabel
|
||||||
|
url = https://github.com/mapbox/polylabel.git
|
||||||
|
|
16
.pre-commit-config.yaml
Normal file
16
.pre-commit-config.yaml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# See https://pre-commit.com for more information
|
||||||
|
# See https://pre-commit.com/hooks.html for more hooks
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.6.0
|
||||||
|
hooks:
|
||||||
|
- id: trailing-whitespace
|
||||||
|
files: ^.*\.cmake|CMakeLists\.txt$
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
files: ^.*\.cmake|CMakeLists\.txt$
|
||||||
|
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||||
|
rev: v18.1.3
|
||||||
|
hooks:
|
||||||
|
- id: clang-format
|
||||||
|
types_or: [c++, c]
|
115
.travis.yml
115
.travis.yml
|
@ -1,115 +0,0 @@
|
||||||
language: generic
|
|
||||||
|
|
||||||
git:
|
|
||||||
depth: 10
|
|
||||||
submodules: false
|
|
||||||
|
|
||||||
env:
|
|
||||||
global:
|
|
||||||
- CCACHE_TEMPDIR=/tmp/.ccache-temp
|
|
||||||
- CCACHE_COMPRESS=1
|
|
||||||
- HEAVY_JOBS="2"
|
|
||||||
- PREFIX=/tmp/mapnik
|
|
||||||
- secure: "F6ivqDNMBQQnrDGA9+7IX+GDswuIqQQd7YPJdQqa2Ked9jddAQDeJClb05ig3JlwfOlYLGZOd43ZX0pKuMtI2Gbkwz211agGP9S3YunwlRg8iWtJlO5kYFUdKCmJNhjg4icfkGELCgwXn+zuEWFSLpkPcjqAFKFlQrIJeAJJgKM="
|
|
||||||
addons:
|
|
||||||
postgresql: "9.4"
|
|
||||||
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- $HOME/.ccache
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- os: linux
|
|
||||||
sudo: false
|
|
||||||
compiler: ": clang"
|
|
||||||
env: JOBS=4 CXX="ccache g++-6" CC="gcc-6"
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
sources: [ 'ubuntu-toolchain-r-test']
|
|
||||||
packages: [ 'libstdc++-6-dev', 'g++-6', 'xutils-dev']
|
|
||||||
- os: linux
|
|
||||||
sudo: false
|
|
||||||
compiler: ": clang"
|
|
||||||
env: JOBS=8 CXX="ccache clang++-3.9 -Qunused-arguments" CC="clang-3.9" TRIGGER=true
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
sources: [ 'ubuntu-toolchain-r-test']
|
|
||||||
packages: [ 'libstdc++-4.9-dev', 'xutils-dev']
|
|
||||||
- os: linux
|
|
||||||
sudo: false
|
|
||||||
compiler: ": clang-coverage"
|
|
||||||
env: JOBS=8 COVERAGE=true CXX="ccache clang++-3.9 -Qunused-arguments" CC="clang-3.9"
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
sources: [ 'ubuntu-toolchain-r-test']
|
|
||||||
packages: ['libstdc++-4.9-dev', 'xutils-dev' ]
|
|
||||||
- os: osx
|
|
||||||
compiler: ": clang-osx"
|
|
||||||
# https://docs.travis-ci.com/user/languages/objective-c/#Supported-OS-X-iOS-SDK-versions
|
|
||||||
osx_image: xcode7.3 # upgrades clang from 6 -> 7
|
|
||||||
env: JOBS=4 CXX="ccache clang++ -Qunused-arguments"
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
# workaround travis rvm bug
|
|
||||||
# http://superuser.com/questions/1044130/why-am-i-having-how-can-i-fix-this-error-shell-session-update-command-not-f
|
|
||||||
- |
|
|
||||||
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
|
|
||||||
rvm get head || true
|
|
||||||
fi
|
|
||||||
- source scripts/travis-common.sh
|
|
||||||
- export PATH=${PREFIX}/bin:$(pwd)/mason_packages/.link/bin:${PATH}
|
|
||||||
- export COVERAGE=${COVERAGE:-false}
|
|
||||||
- export MASON_PUBLISH=${MASON_PUBLISH:-false}
|
|
||||||
- export BENCH=${BENCH:-false}
|
|
||||||
- if [[ ${TRAVIS_BRANCH} != 'master' ]]; then export MASON_PUBLISH=false; fi
|
|
||||||
- if [[ ${TRAVIS_PULL_REQUEST} != 'false' ]]; then export MASON_PUBLISH=false; fi
|
|
||||||
- git_submodule_update --init --depth=10
|
|
||||||
|
|
||||||
install:
|
|
||||||
- on 'osx' export DATA_PATH=$(brew --prefix)/var/postgres
|
|
||||||
- on 'osx' rm -rf ${DATA_PATH}
|
|
||||||
- on 'osx' initdb ${DATA_PATH} -E utf8
|
|
||||||
- on 'osx' pg_ctl -w start -l postgres.log --pgdata ${DATA_PATH};
|
|
||||||
- on 'osx' cat postgres.log;
|
|
||||||
- on 'osx' createuser -s postgres
|
|
||||||
- psql -c 'create database template_postgis;' -U postgres
|
|
||||||
- psql -c 'create extension postgis;' -d template_postgis -U postgres
|
|
||||||
- enabled ${COVERAGE} curl -S -f https://codecov.io/bash -o codecov
|
|
||||||
- enabled ${COVERAGE} chmod +x codecov
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- source bootstrap.sh
|
|
||||||
- |
|
|
||||||
if [[ $(uname -s) == 'Linux' ]]; then
|
|
||||||
mason install clang++ 3.9.1
|
|
||||||
export PATH=$(mason prefix clang++ 3.9.1)/bin:${PATH}
|
|
||||||
mason install llvm-cov 3.9.1
|
|
||||||
export PATH=$(mason prefix llvm-cov 3.9.1)/bin:${PATH}
|
|
||||||
which llvm-cov
|
|
||||||
export LLVM_COV="$(mason prefix llvm-cov 3.9.1)/bin/llvm-cov"
|
|
||||||
fi
|
|
||||||
- ccache --version
|
|
||||||
- ccache -p || true
|
|
||||||
- ccache --show-stats || true
|
|
||||||
- commit_message_parse
|
|
||||||
|
|
||||||
script:
|
|
||||||
- export SCONSFLAGS='--debug=time'
|
|
||||||
- configure BENCHMARK=${BENCH}
|
|
||||||
- cat config.log
|
|
||||||
# we limit the `make` to 40 min
|
|
||||||
# to ensure that slow builds still upload their
|
|
||||||
# ccache results and therefore should be faster
|
|
||||||
# (and might work) for the next build
|
|
||||||
- DURATION=2400
|
|
||||||
- scripts/travis-command-wrapper.py -s "date" -i 120 --deadline=$(( $(date +%s) + ${DURATION} )) make
|
|
||||||
- RESULT=0
|
|
||||||
- make test || RESULT=$?
|
|
||||||
# we allow visual failures with g++ for now: https://github.com/mapnik/mapnik/issues/3567
|
|
||||||
- if [[ ${RESULT} != 0 ]] && [[ ${CXX} =~ 'clang++' ]]; then false; fi;
|
|
||||||
- enabled ${COVERAGE} coverage
|
|
||||||
- enabled ${BENCH} make bench
|
|
||||||
|
|
||||||
after_success:
|
|
||||||
- enabled ${TRIGGER} trigger_downstream
|
|
948
CHANGELOG.md
948
CHANGELOG.md
File diff suppressed because it is too large
Load diff
34
CITATION.cff
Normal file
34
CITATION.cff
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
# This CITATION.cff file was generated with cffinit.
|
||||||
|
# Visit https://bit.ly/cffinit to generate yours today!
|
||||||
|
|
||||||
|
cff-version: 1.2.0
|
||||||
|
title: mapnik
|
||||||
|
message: >-
|
||||||
|
If you use this software, please cite it using the
|
||||||
|
metadata from this file.
|
||||||
|
type: software
|
||||||
|
authors:
|
||||||
|
- given-names: Artem
|
||||||
|
family-names: Pavlenko
|
||||||
|
identifiers:
|
||||||
|
- type: url
|
||||||
|
value: 'https://github.com/mapnik/mapnik'
|
||||||
|
description: GitHub Repository
|
||||||
|
- type: swh
|
||||||
|
value: >-
|
||||||
|
swh:1:dir:3f5758e17e9d54016ca694268da68cf6856fab58
|
||||||
|
description: Software Archive
|
||||||
|
repository-code: 'https://github.com/mapnik/mapnik'
|
||||||
|
url: 'https://mapnik.org/'
|
||||||
|
abstract: >-
|
||||||
|
Mapnik is an open source toolkit for developing
|
||||||
|
mapping applications. At the core is a C++ shared
|
||||||
|
library providing algorithms and patterns for
|
||||||
|
spatial data access and visualization.
|
||||||
|
keywords:
|
||||||
|
- mapping
|
||||||
|
- gis
|
||||||
|
- cartography
|
||||||
|
- beautiful-maps
|
||||||
|
- rendering
|
||||||
|
license: LGPL-2.1
|
472
CMakeLists.txt
Normal file
472
CMakeLists.txt
Normal file
|
@ -0,0 +1,472 @@
|
||||||
|
cmake_minimum_required(VERSION 3.15)
|
||||||
|
# 3.15 is required since the Boost::XXXX targets was first added. https://cmake.org/cmake/help/latest/module/FindBoost.html#imported-targets
|
||||||
|
# 3.14 is required since SQLite3 Module was first added. https://cmake.org/cmake/help/latest/module/FindSQLite3.html#findsqlite3
|
||||||
|
|
||||||
|
include(cmake/GetVersion.cmake)
|
||||||
|
get_mapnik_version()
|
||||||
|
|
||||||
|
project(mapnik
|
||||||
|
VERSION ${MAPNIK_MAJOR_VERSION}.${MAPNIK_MINOR_VERSION}.${MAPNIK_PATCH_VERSION}
|
||||||
|
HOMEPAGE_URL "https://mapnik.org/"
|
||||||
|
DESCRIPTION "Mapnik is an open source toolkit for developing mapping applications"
|
||||||
|
LANGUAGES CXX
|
||||||
|
)
|
||||||
|
message(STATUS "mapnik version: ${PROJECT_VERSION}")
|
||||||
|
|
||||||
|
# https://cliutils.gitlab.io/modern-cmake/chapters/features/ides.html
|
||||||
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
|
||||||
|
set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL ON) # with newer cmake versions put all find_package in global scope
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||||
|
include(FeatureSummary)
|
||||||
|
include(MapnikOption)
|
||||||
|
include(MapnikMinimumVersions)
|
||||||
|
include(MapnikFindPackage)
|
||||||
|
include(MapnikInstall)
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
add_feature_info(BUILD_TESTING BUILD_TESTING "Adds tests")
|
||||||
|
|
||||||
|
mapnik_option(INSTALL_DEPENDENCIES "if ON, all dependencies (eg. required dlls) will be copied into CMAKE_INSTALL_PREFIX/MAPNIK_BIN_DIR." ON)
|
||||||
|
mapnik_option(BUILD_SHARED_LIBS "build mapnik dynamic(ON) or static(OFF)" ON)
|
||||||
|
mapnik_option(BUILD_SHARED_PLUGINS "build dynamic plugins" ${BUILD_SHARED_LIBS}) # use BUILD_SHARED_LIBS as default option
|
||||||
|
mapnik_option(BUILD_SHARED_CRT "(only windows with msvc) use msvc shared crt" ON)
|
||||||
|
if(WIN32 AND BUILD_SHARED_PLUGINS AND NOT BUILD_SHARED_LIBS)
|
||||||
|
message(FATAL_ERROR "static libmapnik and dynamic plugins won't work correctly")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mapnik_option(USE_EXTERNAL_MAPBOX_GEOMETRY "Use a external mapnik/geometry.hpp. If off, use the submodule" OFF)
|
||||||
|
mapnik_option(USE_EXTERNAL_MAPBOX_POLYLABEL "Use a external mapnik/polylabel. If off, use the submodule" OFF)
|
||||||
|
mapnik_option(USE_EXTERNAL_MAPBOX_PROTOZERO "Use a external mapnik/protozero. If off, use the submodule" OFF)
|
||||||
|
mapnik_option(USE_EXTERNAL_MAPBOX_VARIANT "Use a external mapnik/variant. If off, use the submodule" OFF)
|
||||||
|
mapnik_option(USE_JPEG "adds jpeg support" ON)
|
||||||
|
mapnik_option(USE_PNG "adds png support" ON)
|
||||||
|
mapnik_option(USE_TIFF "adds tiff support" ON)
|
||||||
|
mapnik_option(USE_WEBP "adds webp support" ON)
|
||||||
|
mapnik_option(USE_LIBXML2 "adds libxml2 support" ON)
|
||||||
|
mapnik_option(USE_CAIRO "adds the cairo renderer" ON)
|
||||||
|
mapnik_option(USE_PROJ "adds proj support" ON)
|
||||||
|
mapnik_option(USE_GRID_RENDERER "adds grid renderer" ON)
|
||||||
|
mapnik_option(USE_SVG_RENDERER "adds svg renderer" ON)
|
||||||
|
mapnik_option(USE_BIGINT "uses 64 bit instead of 32" ON)
|
||||||
|
mapnik_option(USE_BOOST_FILESYSTEM "use boost::filesytem even if `std::filesystem` is available (since c++17)" OFF)
|
||||||
|
mapnik_option(USE_MEMORY_MAPPED_FILE "uses file cache" ON)
|
||||||
|
mapnik_option(USE_MULTITHREADED "enables the multithreaded features (threadsafe)" ON)
|
||||||
|
mapnik_option(USE_NO_ATEXIT "disable atexit" OFF)
|
||||||
|
mapnik_option(USE_NO_DLCLOSE "disable dlclose" OFF)
|
||||||
|
mapnik_option(USE_DEBUG_OUTPUT "enables some debug messages for development" OFF)
|
||||||
|
mapnik_option(USE_LOG "enables logging output. See log severity level." OFF)
|
||||||
|
# 0 = debug
|
||||||
|
# 1 = warn
|
||||||
|
# 2 = error
|
||||||
|
# 3 = none
|
||||||
|
set(USE_LOG_SEVERITY "1" CACHE STRING "sets the logging severity (only applies when USE_LOG is ON")
|
||||||
|
mapnik_option(USE_STATS "Enable statistics reporting" OFF)
|
||||||
|
|
||||||
|
mapnik_option(DISABLE_MAPNIK_AUTOSETUP "disables the autosetup. Need to call mapnik::setup() then" OFF)
|
||||||
|
|
||||||
|
mapnik_option(USE_PLUGIN_INPUT_CSV "adds plugin input csv" ON)
|
||||||
|
mapnik_option(USE_PLUGIN_INPUT_GDAL "adds plugin input gdal" ON)
|
||||||
|
mapnik_option(USE_PLUGIN_INPUT_GEOBUF "adds plugin input geobuf" ON)
|
||||||
|
mapnik_option(USE_PLUGIN_INPUT_GEOJSON "adds plugin input geojson" ON)
|
||||||
|
mapnik_option(USE_PLUGIN_INPUT_OGR "adds plugin input ogr" ON)
|
||||||
|
mapnik_option(USE_PLUGIN_INPUT_PGRASTER "adds plugin input pgraster" ON)
|
||||||
|
mapnik_option(USE_PLUGIN_INPUT_POSTGIS "adds plugin input postgis" ON)
|
||||||
|
mapnik_option(USE_PLUGIN_INPUT_RASTER "adds plugin input raster" ON)
|
||||||
|
mapnik_option(USE_PLUGIN_INPUT_SHAPE "adds plugin input shape" ON)
|
||||||
|
mapnik_option(USE_PLUGIN_INPUT_SQLITE "adds plugin input sqlite" ON)
|
||||||
|
mapnik_option(USE_PLUGIN_INPUT_TOPOJSON "adds plugin input topojson" ON)
|
||||||
|
|
||||||
|
mapnik_option(BUILD_DEMO_VIEWER "builds the demo viewer" ON)
|
||||||
|
mapnik_option(BUILD_DEMO_CPP "builds the demo c++ application" ON)
|
||||||
|
|
||||||
|
mapnik_option(BUILD_BENCHMARK "builds benchmark project" ON)
|
||||||
|
|
||||||
|
mapnik_option(BUILD_UTILITY_GEOMETRY_TO_WKB "builds the utility program geometry_to_wkb" ON)
|
||||||
|
mapnik_option(BUILD_UTILITY_MAPNIK_INDEX "builds the utility program mapnik_index" ON)
|
||||||
|
mapnik_option(BUILD_UTILITY_MAPNIK_RENDER "builds the utility program mapnik_render" ON)
|
||||||
|
mapnik_option(BUILD_UTILITY_OGRINDEX "builds the utility program ogrindex" OFF)
|
||||||
|
mapnik_option(BUILD_UTILITY_PGSQL2SQLITE "builds the utility program pgsql2sqlite" ON)
|
||||||
|
mapnik_option(BUILD_UTILITY_SHAPEINDEX "builds the utility program shapeindex" ON)
|
||||||
|
mapnik_option(BUILD_UTILITY_SVG2PNG "builds the utility program svg2png" ON)
|
||||||
|
|
||||||
|
mapnik_option(USE_BOOST_REGEX_ICU_WORKAROUND "if you don't use your system libraries and get double linked icu libraries set this to ON" OFF)
|
||||||
|
mapnik_option(USE_GLIBC_WORKAROUND "see https://github.com/mapnik/mapnik/pull/3792 if you building with libstdc++-4.9" OFF)
|
||||||
|
|
||||||
|
feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
|
||||||
|
feature_summary(FILENAME "${CMAKE_CURRENT_BINARY_DIR}/features.log" WHAT ENABLED_FEATURES DISABLED_FEATURES)
|
||||||
|
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
# See for more details: https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html
|
||||||
|
set(MAPNIK_BIN_DIR ${CMAKE_INSTALL_BINDIR} CACHE STRING "Install directory for binaries")
|
||||||
|
set(MAPNIK_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING "Install directory for libraries")
|
||||||
|
set(MAPNIK_ARCHIVE_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING "Install directory for archives")
|
||||||
|
set(MAPNIK_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE STRING "Install directory for the headers")
|
||||||
|
set(MAPNIK_CMAKE_DIR ${MAPNIK_LIB_DIR}/cmake/mapnik CACHE STRING "Install directory of the cmake targets")
|
||||||
|
set(MAPNIK_PKGCONF_DIR ${MAPNIK_LIB_DIR}/pkgconfig CACHE STRING "Install directory for the .pc files for pkg-config")
|
||||||
|
set(MAPNIK_OUTPUT_DIR "${CMAKE_BINARY_DIR}/out")
|
||||||
|
if(WIN32)
|
||||||
|
set(DEFAULT_PLUGINS_INSTALL_DIR ${MAPNIK_BIN_DIR}/mapnik/input)
|
||||||
|
else()
|
||||||
|
set(DEFAULT_PLUGINS_INSTALL_DIR ${MAPNIK_LIB_DIR}/mapnik/input)
|
||||||
|
endif()
|
||||||
|
set(PLUGINS_INSTALL_DIR ${DEFAULT_PLUGINS_INSTALL_DIR} CACHE STRING "installs the plugins in the specified directory")
|
||||||
|
message(STATUS "Installing plugins to ${PLUGINS_INSTALL_DIR}")
|
||||||
|
|
||||||
|
set(FONTS_INSTALL_DIR ${MAPNIK_LIB_DIR}/mapnik/fonts CACHE STRING "installs the fonts in the specified directory")
|
||||||
|
message(STATUS "Installing fonts to ${FONTS_INSTALL_DIR}")
|
||||||
|
|
||||||
|
set(MAPNIK_COMPILE_DEFS "")
|
||||||
|
set(MAPNIK_OPTIONAL_LIBS "")
|
||||||
|
set(MAPNIK_OPTIONAL_LIBS_INCLUDE "")
|
||||||
|
|
||||||
|
#############################
|
||||||
|
#############################
|
||||||
|
# Begin project configuration
|
||||||
|
#############################
|
||||||
|
#############################
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17 CACHE STRING "Sets the c++ standard. c++17 is minimum.")
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON) # require the specified CMAKE_CXX_STANDARD
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF CACHE STRING "Enables the compiler specific extensions.") # Fallsback to -std=c++<ver> if off
|
||||||
|
message(STATUS "Using c++${CMAKE_CXX_STANDARD}")
|
||||||
|
message(STATUS "Using c++ extensions: ${CXX_EXTENSIONS}")
|
||||||
|
|
||||||
|
# add debug postfix to the libraries
|
||||||
|
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "sets the debug library postfix on mapnik, wkt and json")
|
||||||
|
message(STATUS "postfix for debug libraries: ${CMAKE_DEBUG_POSTFIX}")
|
||||||
|
|
||||||
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>")
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}")
|
||||||
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}")
|
||||||
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib")
|
||||||
|
|
||||||
|
# needs to be before the first call of find_boost.
|
||||||
|
if(CMAKE_CXX_STANDARD VERSION_LESS 17)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS BOOST_SPIRIT_X3_HIDE_CXX17_WARNING)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_MULTITHREADED)
|
||||||
|
set(Boost_USE_MULTITHREADED ON)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_THREADSAFE)
|
||||||
|
else()
|
||||||
|
set(Boost_USE_MULTITHREADED OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
mapnik_find_package(PkgConfig REQUIRED)
|
||||||
|
mapnik_find_threads()
|
||||||
|
mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data)
|
||||||
|
|
||||||
|
mapnik_find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS regex)
|
||||||
|
if(CMAKE_CXX_STANDARD VERSION_LESS 17)
|
||||||
|
set(USE_BOOST_FILESYSTEM ON CACHE BOOL "Use boost::filesystem" FORCE)
|
||||||
|
endif()
|
||||||
|
if(USE_BOOST_FILESYSTEM)
|
||||||
|
mapnik_find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS filesystem system)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS BOOST_REGEX_HAS_ICU)
|
||||||
|
if(USE_BOOST_REGEX_ICU_WORKAROUND)
|
||||||
|
message(STATUS "using boost regex workaround")
|
||||||
|
set_property(TARGET Boost::regex PROPERTY INTERFACE_LINK_LIBRARIES)
|
||||||
|
endif()
|
||||||
|
include(CheckBoostRegexIcu)
|
||||||
|
check_boost_regex()
|
||||||
|
if(BOOST_REGEX_HAS_ICU)
|
||||||
|
message(STATUS "boost regex has icu support")
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS BOOST_REGEX_HAS_ICU)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mapnik_find_package(Freetype REQUIRED)
|
||||||
|
|
||||||
|
# try to find harfbuzz with the native configuration and fallback to our "own" FindHarfBuzz
|
||||||
|
mapnik_find_package(harfbuzz CONFIG QUIET)
|
||||||
|
if(harfbuzz_FOUND)
|
||||||
|
message(STATUS "Found harfbuzz native cmake")
|
||||||
|
list(APPEND MAPNIK_OPTIONAL_LIBS harfbuzz::harfbuzz)
|
||||||
|
else()
|
||||||
|
# Use pkg-config when harfbuzz is not found.
|
||||||
|
# It might be possible that in future version harfbuzz could only be found via pkg-config.
|
||||||
|
# harfbuzz related discussion: https://github.com/harfbuzz/harfbuzz/issues/2653
|
||||||
|
message(STATUS "harfbuzz not found via cmake. Searching via pkg-config...")
|
||||||
|
mapnik_pkg_check_modules(harfbuzz REQUIRED IMPORTED_TARGET harfbuzz>=${HARFBUZZ_MIN_VERSION})
|
||||||
|
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::harfbuzz)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_EXTERNAL_MAPBOX_GEOMETRY)
|
||||||
|
# this is used to provide a way to specify include dirs with CACHE VARIABLES
|
||||||
|
if(NOT MAPBOX_GEOMETRY_INCLUDE_DIRS)
|
||||||
|
message(STATUS "Searching for the include dir of mapbox/geometry.hpp")
|
||||||
|
find_path(MAPBOX_GEOMETRY_INCLUDE_DIRS "mapbox/geometry.hpp" REQUIRED)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(MAPBOX_GEOMETRY_INCLUDE_DIRS
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/geometry/include>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
if(NOT MAPBOX_GEOMETRY_INCLUDE_DIRS)
|
||||||
|
message(FATAL_ERROR "Set -DMAPBOX_GEOMETRY_INCLUDE_DIRS to the mapbox/geometry.hpp include dir")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_EXTERNAL_MAPBOX_POLYLABEL)
|
||||||
|
if(NOT MAPBOX_POLYLABEL_INCLUDE_DIRS)
|
||||||
|
message(STATUS "Searching for the include dir of mapbox/polylabel")
|
||||||
|
find_path(MAPBOX_POLYLABEL_INCLUDE_DIRS "mapbox/polylabel.hpp")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(MAPBOX_POLYLABEL_INCLUDE_DIRS
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/polylabel/include>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
if(NOT MAPBOX_POLYLABEL_INCLUDE_DIRS)
|
||||||
|
message(FATAL_ERROR "Set MAPBOX_POLYLABEL_INCLUDE_DIRS to the mapbox/geometry include dir")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_EXTERNAL_MAPBOX_PROTOZERO)
|
||||||
|
if(NOT MAPBOX_PROTOZERO_INCLUDE_DIRS)
|
||||||
|
message(STATUS "Searching for the include dir of mapbox/protozero")
|
||||||
|
find_path(MAPBOX_PROTOZERO_INCLUDE_DIRS "protozero/pbf_message.hpp")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(MAPBOX_PROTOZERO_INCLUDE_DIRS
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/protozero/include>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
if(NOT MAPBOX_PROTOZERO_INCLUDE_DIRS)
|
||||||
|
message(FATAL_ERROR "Set MAPBOX_PROTOZERO_INCLUDE_DIRS to the mapbox/protozero include dir")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_EXTERNAL_MAPBOX_VARIANT)
|
||||||
|
if(NOT MAPBOX_VARIANT_INCLUDE_DIRS)
|
||||||
|
message(STATUS "Searching for the include dir of mapbox/variant")
|
||||||
|
find_path(MAPBOX_VARIANT_INCLUDE_DIRS "mapbox/variant.hpp")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(MAPBOX_VARIANT_INCLUDE_DIRS
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/variant/include>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
if(NOT MAPBOX_VARIANT_INCLUDE_DIRS)
|
||||||
|
message(FATAL_ERROR "Set MAPBOX_VARIANT_INCLUDE_DIRS to the mapbox/variant include dir")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# (used by MapnikInstall.cmake. properties are needed since "set(...)" will be out of scope
|
||||||
|
set_property(GLOBAL PROPERTY TARGETS "")
|
||||||
|
set_property(GLOBAL PROPERTY PLUGINS "")
|
||||||
|
set_property(GLOBAL PROPERTY MAPNIK_UTILITIES "")
|
||||||
|
|
||||||
|
if(USE_GLIBC_WORKAROUND)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_ENABLE_GLIBC_WORKAROUND)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_BIGINT)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS BIGINT)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_BOOST_FILESYSTEM)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS USE_BOOST_FILESYSTEM)
|
||||||
|
list(APPEND MAPNIK_OPTIONAL_LIBS Boost::filesystem)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_MEMORY_MAPPED_FILE)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_MEMORY_MAPPED_FILE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_NO_ATEXIT)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_NO_ATEXIT)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_NO_DLCLOSE)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_NO_DLCLOSE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_DEBUG_OUTPUT)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_DEBUG)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_LOG)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_LOG MAPNIK_DEFAULT_LOG_SEVERITY=${USE_LOG_SEVERITY})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_STATS)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_STATS)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_LIBXML2)
|
||||||
|
mapnik_find_package(LibXml2 REQUIRED)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS HAVE_LIBXML2)
|
||||||
|
list(APPEND MAPNIK_OPTIONAL_LIBS LibXml2::LibXml2)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_PNG)
|
||||||
|
mapnik_find_package(PNG REQUIRED)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS HAVE_PNG)
|
||||||
|
list(APPEND MAPNIK_OPTIONAL_LIBS PNG::PNG)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_JPEG)
|
||||||
|
mapnik_find_package(JPEG REQUIRED)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS HAVE_JPEG)
|
||||||
|
list(APPEND MAPNIK_OPTIONAL_LIBS JPEG::JPEG)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_TIFF)
|
||||||
|
mapnik_find_package(TIFF REQUIRED)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS HAVE_TIFF)
|
||||||
|
list(APPEND MAPNIK_OPTIONAL_LIBS TIFF::TIFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_WEBP)
|
||||||
|
mapnik_pkg_check_modules(WebP REQUIRED IMPORTED_TARGET libwebp)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS HAVE_WEBP)
|
||||||
|
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::WebP)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_CAIRO)
|
||||||
|
mapnik_pkg_check_modules(Cairo REQUIRED IMPORTED_TARGET cairo)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS HAVE_CAIRO)
|
||||||
|
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::Cairo)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_PROJ)
|
||||||
|
#https://proj.org/development/cmake.html
|
||||||
|
mapnik_find_package(PROJ QUIET)
|
||||||
|
# currently the cmake files are not installed, when installing proj via apt-get. So search via pkg-config
|
||||||
|
if(NOT PROJ_FOUND)
|
||||||
|
message(STATUS "PROJ not found via FindPROJ. Searching via pkg-config...")
|
||||||
|
mapnik_pkg_check_modules(PROJ REQUIRED IMPORTED_TARGET proj>=${PROJ_MIN_VERSION})
|
||||||
|
string(REGEX MATCH "([0-9]+)\.([0-9]+)\.([0-9]+)" _dummy "${PROJ_VERSION}")
|
||||||
|
set(PROJ_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
||||||
|
set(PROJ_VERSION_MINOR "${CMAKE_MATCH_2}")
|
||||||
|
set(PROJ_VERSION_PATCH "${CMAKE_MATCH_3}")
|
||||||
|
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::PROJ)
|
||||||
|
else()
|
||||||
|
if(PROJ_VERSION VERSION_LESS PROJ_MIN_VERSION)
|
||||||
|
message(FATAL_ERROR "Proj needs to be at least version ${PROJ_MIN_VERSION}")
|
||||||
|
endif()
|
||||||
|
list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ_LIBRARIES})
|
||||||
|
list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE $<BUILD_INTERFACE:${PROJ_INCLUDE_DIRS}>)
|
||||||
|
endif()
|
||||||
|
math(EXPR MAPNIK_PROJ_VERSION "${PROJ_VERSION_MAJOR}*10000 + ${PROJ_VERSION_MINOR}*100 + ${PROJ_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL)
|
||||||
|
message(STATUS "Using mapnik PROJ version: ${MAPNIK_PROJ_VERSION}")
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_USE_PROJ MAPNIK_PROJ_VERSION=${MAPNIK_PROJ_VERSION})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_GRID_RENDERER)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS GRID_RENDERER)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_SVG_RENDERER)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS SVG_RENDERER)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT WIN32)
|
||||||
|
message(STATUS "Compiling with -DMAPNIK_HAS_DLCFN")
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_HAS_DLCFN)
|
||||||
|
list(APPEND MAPNIK_OPTIONAL_LIBS ${CMAKE_DL_LIBS})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT BUILD_SHARED_PLUGINS)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_STATIC_PLUGINS)
|
||||||
|
endif()
|
||||||
|
# when building static, this have to be public so that all depending libs know about
|
||||||
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_STATIC_DEFINE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DISABLE_MAPNIK_AUTOSETUP)
|
||||||
|
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_DISABLE_AUTOSETUP)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# force utf-8 source code processing
|
||||||
|
# see https://docs.microsoft.com/de-de/cpp/build/reference/utf-8-set-source-and-executable-character-sets-to-utf-8?view=msvc-170
|
||||||
|
add_compile_options(
|
||||||
|
"$<$<CXX_COMPILER_ID:MSVC>:/utf-8>"
|
||||||
|
"$<$<CXX_COMPILER_ID:MSVC>:/EHsc>"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(core INTERFACE)
|
||||||
|
add_library(mapnik::core ALIAS core)
|
||||||
|
|
||||||
|
target_include_directories(core INTERFACE
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<BUILD_INTERFACE:${MAPBOX_GEOMETRY_INCLUDE_DIRS}>
|
||||||
|
$<BUILD_INTERFACE:${MAPBOX_POLYLABEL_INCLUDE_DIRS}>
|
||||||
|
$<BUILD_INTERFACE:${MAPBOX_VARIANT_INCLUDE_DIRS}>
|
||||||
|
$<BUILD_INTERFACE:${MAPBOX_PROTOZERO_INCLUDE_DIRS}>
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
${MAPNIK_OPTIONAL_LIBS_INCLUDE}
|
||||||
|
)
|
||||||
|
target_link_libraries(core INTERFACE
|
||||||
|
Threads::Threads
|
||||||
|
ICU::uc
|
||||||
|
ICU::data
|
||||||
|
ICU::i18n
|
||||||
|
Boost::headers
|
||||||
|
Boost::regex
|
||||||
|
Freetype::Freetype
|
||||||
|
${MAPNIK_OPTIONAL_LIBS}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(core INTERFACE ${MAPNIK_COMPILE_DEFS})
|
||||||
|
|
||||||
|
mapnik_install(core)
|
||||||
|
|
||||||
|
###
|
||||||
|
# forward declaring libraries to consume them when building static plugins (circle deps between mapnik <-> plugin_target)
|
||||||
|
add_library(mapnik "")
|
||||||
|
add_library(mapnik::mapnik ALIAS mapnik)
|
||||||
|
add_library(wkt STATIC "")
|
||||||
|
add_library(mapnik::wkt ALIAS wkt)
|
||||||
|
add_library(json STATIC "")
|
||||||
|
add_library(mapnik::json ALIAS json)
|
||||||
|
# end forward declaration
|
||||||
|
###
|
||||||
|
|
||||||
|
add_subdirectory(deps)
|
||||||
|
add_subdirectory(plugins)
|
||||||
|
add_subdirectory(src)
|
||||||
|
add_subdirectory(utils)
|
||||||
|
add_subdirectory(demo)
|
||||||
|
if(BUILD_BENCHMARK)
|
||||||
|
add_subdirectory(benchmark)
|
||||||
|
endif()
|
||||||
|
if(BUILD_TESTING)
|
||||||
|
add_subdirectory(test)
|
||||||
|
endif()
|
||||||
|
file(COPY fonts DESTINATION "${MAPNIK_OUTPUT_DIR}")
|
||||||
|
|
||||||
|
feature_summary(FILENAME "${CMAKE_CURRENT_BINARY_DIR}/packages.log" WHAT PACKAGES_FOUND PACKAGES_NOT_FOUND INCLUDE_QUIET_PACKAGES)
|
||||||
|
|
||||||
|
# start package mapnik
|
||||||
|
include(MapnikExport)
|
||||||
|
include(MapnikExportPkgConfig)
|
||||||
|
|
||||||
|
install(DIRECTORY include/mapnik/ DESTINATION "${MAPNIK_INCLUDE_DIR}/mapnik")
|
||||||
|
install(DIRECTORY deps/agg/include/ DESTINATION "${MAPNIK_INCLUDE_DIR}/mapnik/agg")
|
||||||
|
install(DIRECTORY deps/mapnik DESTINATION "${MAPNIK_INCLUDE_DIR}")
|
||||||
|
file(GLOB TTF_FONT_FILES "fonts/*/*/*.ttf")
|
||||||
|
install(FILES ${TTF_FONT_FILES} DESTINATION "${FONTS_INSTALL_DIR}")
|
||||||
|
|
||||||
|
if(NOT USE_EXTERNAL_MAPBOX_GEOMETRY)
|
||||||
|
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/geometry/include/" DESTINATION "${MAPNIK_INCLUDE_DIR}")
|
||||||
|
endif()
|
||||||
|
if(NOT USE_EXTERNAL_MAPBOX_POLYLABEL)
|
||||||
|
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/polylabel/include/" DESTINATION "${MAPNIK_INCLUDE_DIR}")
|
||||||
|
endif()
|
||||||
|
if(NOT USE_EXTERNAL_MAPBOX_PROTOZERO)
|
||||||
|
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/protozero/include/" DESTINATION "${MAPNIK_INCLUDE_DIR}")
|
||||||
|
endif()
|
||||||
|
if(NOT USE_EXTERNAL_MAPBOX_VARIANT)
|
||||||
|
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/variant/include/" DESTINATION "${MAPNIK_INCLUDE_DIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mapnik_install_targets()
|
||||||
|
|
||||||
|
include(pack)
|
350
CMakePresets.json
Normal file
350
CMakePresets.json
Normal file
|
@ -0,0 +1,350 @@
|
||||||
|
{
|
||||||
|
"version": 6,
|
||||||
|
"cmakeMinimumRequired": {
|
||||||
|
"major": 3,
|
||||||
|
"minor": 25,
|
||||||
|
"patch": 0
|
||||||
|
},
|
||||||
|
"configurePresets": [
|
||||||
|
{
|
||||||
|
"name": "use-ninja",
|
||||||
|
"hidden": true,
|
||||||
|
"generator": "Ninja",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "default-build-dir",
|
||||||
|
"hidden": true,
|
||||||
|
"binaryDir": "${sourceDir}/build"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "debug-build",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Debug",
|
||||||
|
"USE_DEBUG_OUTPUT": "ON",
|
||||||
|
"USE_LOG": "ON",
|
||||||
|
"USE_LOG_SEVERITY": "0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-with-debug-build",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
|
||||||
|
"USE_DEBUG_OUTPUT": "OFF",
|
||||||
|
"USE_LOG": "OFF"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "release-build",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Release",
|
||||||
|
"USE_DEBUG_OUTPUT": "OFF",
|
||||||
|
"USE_LOG": "OFF"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "use-clang",
|
||||||
|
"hidden": true,
|
||||||
|
"inherits": [
|
||||||
|
"default-build-dir",
|
||||||
|
"use-ninja"
|
||||||
|
],
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_C_COMPILER": "clang",
|
||||||
|
"CMAKE_CXX_COMPILER": "clang++",
|
||||||
|
"CMAKE_CXX_FLAGS": "-stdlib=libc++",
|
||||||
|
"CMAKE_EXE_LINKER_FLAGS": "-stdlib=libc++",
|
||||||
|
"CMAKE_SHARED_LINKER_FLAGS": "-stdlib=libc++"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "use-gcc",
|
||||||
|
"hidden": true,
|
||||||
|
"inherits": [
|
||||||
|
"default-build-dir",
|
||||||
|
"use-ninja"
|
||||||
|
],
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_C_COMPILER": "gcc",
|
||||||
|
"CMAKE_CXX_COMPILER": "g++"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "use-msvc-cl",
|
||||||
|
"hidden": true,
|
||||||
|
"inherits": [
|
||||||
|
"default-build-dir",
|
||||||
|
"use-ninja"
|
||||||
|
],
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_C_COMPILER": "cl",
|
||||||
|
"CMAKE_CXX_COMPILER": "cl"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "use-msvc-clang-cl",
|
||||||
|
"hidden": true,
|
||||||
|
"inherits": [
|
||||||
|
"default-build-dir",
|
||||||
|
"use-ninja"
|
||||||
|
],
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_C_COMPILER": "clang-cl",
|
||||||
|
"CMAKE_CXX_COMPILER": "clang-cl"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-clang-debug",
|
||||||
|
"displayName": "Linux clang debug",
|
||||||
|
"inherits": [
|
||||||
|
"use-clang",
|
||||||
|
"debug-build"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-clang-release",
|
||||||
|
"displayName": "Linux clang release",
|
||||||
|
"inherits": [
|
||||||
|
"use-clang",
|
||||||
|
"release-build"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-gcc-debug",
|
||||||
|
"displayName": "Linux gcc debug",
|
||||||
|
"inherits": [
|
||||||
|
"use-gcc",
|
||||||
|
"debug-build"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-gcc-release",
|
||||||
|
"displayName": "Linux gcc release",
|
||||||
|
"inherits": [
|
||||||
|
"use-gcc",
|
||||||
|
"release-build"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "windows-arch-x64",
|
||||||
|
"hidden": true,
|
||||||
|
"architecture": {
|
||||||
|
"value": "x64",
|
||||||
|
"strategy": "external"
|
||||||
|
},
|
||||||
|
"toolset": {
|
||||||
|
"value": "host=x64",
|
||||||
|
"strategy": "external"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "windows-default",
|
||||||
|
"displayName": "Windows x64 Debug",
|
||||||
|
"hidden": true,
|
||||||
|
"inherits": [
|
||||||
|
"use-msvc-cl",
|
||||||
|
"windows-arch-x64"
|
||||||
|
],
|
||||||
|
"vendor": {
|
||||||
|
"microsoft.com/VisualStudioSettings/CMake/1.0": {
|
||||||
|
"hostOS": [
|
||||||
|
"Windows"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "windows-debug",
|
||||||
|
"displayName": "Windows x64 Debug",
|
||||||
|
"inherits": [
|
||||||
|
"windows-default",
|
||||||
|
"debug-build"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "windows-release",
|
||||||
|
"displayName": "Windows x64 Release",
|
||||||
|
"inherits": [
|
||||||
|
"windows-default",
|
||||||
|
"release-build"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ci-options",
|
||||||
|
"hidden": true,
|
||||||
|
"cacheVariables": {
|
||||||
|
"BUILD_TESTING": "ON",
|
||||||
|
"BUILD_DEMO_VIEWER": "OFF",
|
||||||
|
"DISABLE_MAPNIK_AUTOSETUP": "ON"
|
||||||
|
},
|
||||||
|
"toolchainFile": "vcpkg/scripts/buildsystems/vcpkg.cmake"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "windows-ci",
|
||||||
|
"description": "used by the ci pipeline",
|
||||||
|
"inherits": [
|
||||||
|
"windows-release",
|
||||||
|
"ci-options"
|
||||||
|
],
|
||||||
|
"cacheVariables": {
|
||||||
|
"INSTALL_DEPENDENCIES": "ON",
|
||||||
|
"ADDITIONAL_LIBARIES_PATHS": "${sourceDir}/build/vcpkg_installed/x64-windows/bin"
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"PROJ_LIB": "${sourceDir}/build/vcpkg_installed/x64-windows/share/proj"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-ci",
|
||||||
|
"description": "used by the ci pipeline",
|
||||||
|
"inherits": [
|
||||||
|
"release-with-debug-build",
|
||||||
|
"use-gcc",
|
||||||
|
"ci-options"
|
||||||
|
],
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_CXX_FLAGS": "--coverage"
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"PROJ_LIB": "${sourceDir}/build/vcpkg_installed/x64-linux/share/proj"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-ci-release",
|
||||||
|
"description": "used by the ci pipeline for releasing",
|
||||||
|
"inherits": [
|
||||||
|
"release-build",
|
||||||
|
"linux-gcc-release"
|
||||||
|
],
|
||||||
|
"cacheVariables": {
|
||||||
|
"BUILD_TESTING": "OFF",
|
||||||
|
"BUILD_DEMO_VIEWER": "OFF",
|
||||||
|
"USE_MEMORY_MAPPED_FILE": "ON"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macos-ci-arm64",
|
||||||
|
"description": "used by the ci pipeline",
|
||||||
|
"inherits": [
|
||||||
|
"use-ninja",
|
||||||
|
"release-with-debug-build",
|
||||||
|
"default-build-dir",
|
||||||
|
"ci-options"
|
||||||
|
],
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_CXX_FLAGS": "-fprofile-arcs -ftest-coverage"
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"PROJ_LIB": "${sourceDir}/build/vcpkg_installed/arm64-osx/share/proj"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macos-ci-x64",
|
||||||
|
"description": "used by the ci pipeline",
|
||||||
|
"inherits": [
|
||||||
|
"use-ninja",
|
||||||
|
"release-with-debug-build",
|
||||||
|
"default-build-dir",
|
||||||
|
"ci-options"
|
||||||
|
],
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_CXX_FLAGS": "-fprofile-arcs -ftest-coverage"
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"PROJ_LIB": "${sourceDir}/build/vcpkg_installed/x64-osx/share/proj"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"buildPresets": [
|
||||||
|
{
|
||||||
|
"name": "windows-debug",
|
||||||
|
"configurePreset": "windows-debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "windows-release",
|
||||||
|
"configurePreset": "windows-release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-clang-debug",
|
||||||
|
"configurePreset": "linux-clang-debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-clang-release",
|
||||||
|
"configurePreset": "linux-clang-release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-gcc-debug",
|
||||||
|
"configurePreset": "linux-gcc-debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-gcc-release",
|
||||||
|
"configurePreset": "linux-gcc-release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "windows-ci",
|
||||||
|
"configurePreset": "windows-ci"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-ci",
|
||||||
|
"configurePreset": "linux-ci"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-ci-release",
|
||||||
|
"configurePreset": "linux-ci-release"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macos-ci-arm64",
|
||||||
|
"configurePreset": "macos-ci-arm64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macos-ci-x64",
|
||||||
|
"configurePreset": "macos-ci-x64"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testPresets": [
|
||||||
|
{
|
||||||
|
"name": "test-default",
|
||||||
|
"hidden": true,
|
||||||
|
"output": {
|
||||||
|
"outputOnFailure": true
|
||||||
|
},
|
||||||
|
"execution": {
|
||||||
|
"noTestsAction": "error",
|
||||||
|
"stopOnFailure": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "windows-ci",
|
||||||
|
"configurePreset": "windows-ci",
|
||||||
|
"inherits": [
|
||||||
|
"test-default"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-ci",
|
||||||
|
"configurePreset": "linux-ci",
|
||||||
|
"inherits": [
|
||||||
|
"test-default"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macos-ci-arm64",
|
||||||
|
"configurePreset": "macos-ci-arm64",
|
||||||
|
"inherits": [
|
||||||
|
"test-default"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "macos-ci-x64",
|
||||||
|
"configurePreset": "macos-ci-x64",
|
||||||
|
"inherits": [
|
||||||
|
"test-default"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
30
INSTALL.md
30
INSTALL.md
|
@ -2,10 +2,18 @@
|
||||||
|
|
||||||
Mapnik runs on Linux, OS X, Windows, and BSD systems.
|
Mapnik runs on Linux, OS X, Windows, and BSD systems.
|
||||||
|
|
||||||
|
## Package managers
|
||||||
|
### vcpkg
|
||||||
|
To install mapnik with vcpkg type `vcpkg install mapnik`. It will install a minimal version of mapnik and all the needed dependencies.
|
||||||
|
To install more features, type `vcpkg search mapnik` to see all available features.
|
||||||
|
|
||||||
|
## Source build
|
||||||
|
|
||||||
First clone mapnik from github and initialize submodules
|
First clone mapnik from github and initialize submodules
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/mapnik/mapnik.git
|
git clone https://github.com/mapnik/mapnik.git
|
||||||
|
cd mapnik
|
||||||
git submodule update --init
|
git submodule update --init
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -34,8 +42,8 @@ To use a Python interpreter that is not named `python` for your build, do
|
||||||
something like the following instead:
|
something like the following instead:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ PYTHON=python2 ./configure
|
$ PYTHON=python3 ./configure
|
||||||
$ make PYTHON=python2
|
$ make PYTHON=python3
|
||||||
```
|
```
|
||||||
|
|
||||||
NOTE: the above will not work on windows, rather see https://github.com/mapnik/mapnik/wiki/WindowsInstallation
|
NOTE: the above will not work on windows, rather see https://github.com/mapnik/mapnik/wiki/WindowsInstallation
|
||||||
|
@ -63,15 +71,15 @@ For troubleshooting help see https://github.com/mapnik/mapnik/wiki/InstallationT
|
||||||
|
|
||||||
Build system dependencies are:
|
Build system dependencies are:
|
||||||
|
|
||||||
* C++ compiler supporting `-std=c++11` (like >= g++ 4.8 or >= clang++ 3.4)
|
* C++ compiler supporting `-std=c++17` (like >= g++ 9 or >= clang++ 5)
|
||||||
* >= 2 GB RAM (> 5 GB for g++)
|
* \>= 2 GB RAM (> 5 GB for g++)
|
||||||
* Python 2.4-2.7
|
* Python 3
|
||||||
* Scons (a copy is bundled)
|
* Scons (a copy is bundled) or CMake >= 3.15 see [docs/cmake-usage.md](./docs/cmake-usage.md)
|
||||||
|
|
||||||
Mapnik Core depends on:
|
Mapnik Core depends on:
|
||||||
|
|
||||||
* Boost
|
* Boost
|
||||||
- >= 1.47 is required and >= 1.56 recommended
|
- \>= 1.73 is required
|
||||||
- These libraries are used:
|
- These libraries are used:
|
||||||
- filesystem
|
- filesystem
|
||||||
- system
|
- system
|
||||||
|
@ -89,7 +97,7 @@ Mapnik Core optionally depends on:
|
||||||
* libjpeg - JPEG graphics (Default enabled, if found)
|
* libjpeg - JPEG graphics (Default enabled, if found)
|
||||||
* libtiff - TIFF graphics (Default enabled, if found)
|
* libtiff - TIFF graphics (Default enabled, if found)
|
||||||
* libwebp - WEBP graphics (Default enabled, if found)
|
* libwebp - WEBP graphics (Default enabled, if found)
|
||||||
* libproj - PROJ.4 projection library (Default enabled, if found)
|
* libproj >= 7.2.0 - PROJ projection library (Default enabled, if found)
|
||||||
|
|
||||||
Additional optional dependencies:
|
Additional optional dependencies:
|
||||||
|
|
||||||
|
@ -183,7 +191,7 @@ If you need help or want to participate starting points include:
|
||||||
### Cartographers
|
### Cartographers
|
||||||
|
|
||||||
TileMill, which uses Mapnik internally, offers great step by step tutorials for
|
TileMill, which uses Mapnik internally, offers great step by step tutorials for
|
||||||
learning advanced map styling: http://mapbox.com/tilemill/docs/crashcourse/introduction/
|
learning advanced map styling: https://tilemill-project.github.io/tilemill/docs/crashcourse/introduction/
|
||||||
|
|
||||||
### Programmers
|
### Programmers
|
||||||
|
|
||||||
|
@ -191,6 +199,6 @@ Mapnik is great for building your own mapping applications. Visit
|
||||||
https://github.com/mapnik/mapnik/wiki/LearningMapnik for basic
|
https://github.com/mapnik/mapnik/wiki/LearningMapnik for basic
|
||||||
tutorials on how to programmatically use Mapnik.
|
tutorials on how to programmatically use Mapnik.
|
||||||
|
|
||||||
### Contributers
|
### Contributors
|
||||||
|
|
||||||
Read docs/contributing.md for resources for getting involved with Mapnik development.
|
Read [docs/contributing.md](docs/contributing.md) for resources for getting involved with Mapnik development.
|
||||||
|
|
3
Makefile
3
Makefile
|
@ -28,7 +28,8 @@ src/json/libmapnik-json.a:
|
||||||
src/renderer_common/render_thunk_extractor.os \
|
src/renderer_common/render_thunk_extractor.os \
|
||||||
src/json/libmapnik-json.a \
|
src/json/libmapnik-json.a \
|
||||||
src/wkt/libmapnik-wkt.a \
|
src/wkt/libmapnik-wkt.a \
|
||||||
src/css_color_grammar_x3.os \
|
src/css/css_grammar_x3.os \
|
||||||
|
src/css/css_color_grammar_x3.os \
|
||||||
src/expression_grammar_x3.os \
|
src/expression_grammar_x3.os \
|
||||||
src/transform_expression_grammar_x3.os \
|
src/transform_expression_grammar_x3.os \
|
||||||
src/image_filter_grammar_x3.os \
|
src/image_filter_grammar_x3.os \
|
||||||
|
|
|
@ -8,8 +8,7 @@ _/ _/ _/_/_/ _/_/_/ _/ _/ _/ _/ _/
|
||||||
_/
|
_/
|
||||||
```
|
```
|
||||||
|
|
||||||
[![Build Status Linux](https://api.travis-ci.org/mapnik/mapnik.svg?branch=master)](http://travis-ci.org/mapnik/mapnik)
|
[![TravisCI](https://api.travis-ci.com/mapnik/mapnik.svg?branch=master)](http://travis-ci.com/mapnik/mapnik)
|
||||||
[![Build Status Windows](https://ci.appveyor.com/api/projects/status/hc9l7okdjtucfqqn?branch=master&svg=true)](https://ci.appveyor.com/project/Mapbox/mapnik)
|
|
||||||
[![codecov](https://codecov.io/gh/mapnik/mapnik/branch/master/graph/badge.svg)](https://codecov.io/gh/mapnik/mapnik)
|
[![codecov](https://codecov.io/gh/mapnik/mapnik/branch/master/graph/badge.svg)](https://codecov.io/gh/mapnik/mapnik)
|
||||||
|
|
||||||
Mapnik is an open source toolkit for developing mapping applications. At the core is a C++ shared library providing algorithms and patterns for spatial data access and visualization.
|
Mapnik is an open source toolkit for developing mapping applications. At the core is a C++ shared library providing algorithms and patterns for spatial data access and visualization.
|
||||||
|
@ -28,4 +27,4 @@ Please note that this project is released with a [Contributor Code of Conduct](h
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
Mapnik software is free and is released under the LGPL ([GNU Lesser General Public License](http://www.gnu.org/licenses/lgpl.html)). Please see [COPYING](https://github.com/mapnik/mapnik/blob/master/COPYING) for more information.
|
Mapnik software is free and is released under the LGPL v2.1 ([GNU Lesser General Public License, version 2.1](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html)). Please see [COPYING](https://github.com/mapnik/mapnik/blob/master/COPYING) for more information.
|
||||||
|
|
672
SConstruct
672
SConstruct
File diff suppressed because it is too large
Load diff
39
appveyor.yml
39
appveyor.yml
|
@ -1,39 +0,0 @@
|
||||||
environment:
|
|
||||||
msvs_toolset: 14
|
|
||||||
FASTBUILD: 1
|
|
||||||
matrix:
|
|
||||||
- platform: x64
|
|
||||||
configuration: Release
|
|
||||||
|
|
||||||
os: Visual Studio 2015
|
|
||||||
|
|
||||||
#shallow_clone: true
|
|
||||||
# limit clone to latest 5 commits
|
|
||||||
clone_depth: 5
|
|
||||||
|
|
||||||
services:
|
|
||||||
- postgresql94 #if changing this, also change PATH below
|
|
||||||
|
|
||||||
install:
|
|
||||||
- SET PGUSER=postgres
|
|
||||||
- SET PGPASSWORD=Password12!
|
|
||||||
- SET PATH=C:\Program Files\PostgreSQL\9.4\bin\;%PATH%
|
|
||||||
|
|
||||||
build_script:
|
|
||||||
- scripts\build-appveyor.bat
|
|
||||||
|
|
||||||
after_build:
|
|
||||||
- 7z a visual-test-results.zip C:\tmp\mapnik-visual-images\visual-test-results
|
|
||||||
|
|
||||||
artifacts:
|
|
||||||
- path: mapnik-gyp\msbuild-summary.txt
|
|
||||||
name: msbuild-summary.txt
|
|
||||||
- path: mapnik-gyp\msbuild-errors.txt
|
|
||||||
name: msbuild-errors.txt
|
|
||||||
- path: mapnik-gyp\msbuild-warnings.txt
|
|
||||||
name: msbuild-warnings.txt
|
|
||||||
- path: visual-test-results.zip
|
|
||||||
name: visual-test-results.zip
|
|
||||||
|
|
||||||
test: off
|
|
||||||
deploy: off
|
|
52
benchmark/CMakeLists.txt
Normal file
52
benchmark/CMakeLists.txt
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
project(mapnik-benchmark)
|
||||||
|
|
||||||
|
set(BENCHMARK_SRCS
|
||||||
|
src/normalize_angle.cpp
|
||||||
|
src/test_array_allocation.cpp
|
||||||
|
src/test_expression_parse.cpp
|
||||||
|
src/test_face_ptr_creation.cpp
|
||||||
|
src/test_font_registration.cpp
|
||||||
|
src/test_getline.cpp
|
||||||
|
src/test_marker_cache.cpp
|
||||||
|
src/test_noop_rendering.cpp
|
||||||
|
src/test_numeric_cast_vs_static_cast.cpp
|
||||||
|
src/test_offset_converter.cpp
|
||||||
|
src/test_png_encoding1.cpp
|
||||||
|
src/test_png_encoding2.cpp
|
||||||
|
src/test_polygon_clipping_rendering.cpp
|
||||||
|
src/test_polygon_clipping.cpp
|
||||||
|
src/test_proj_transform1.cpp
|
||||||
|
src/test_quad_tree.cpp
|
||||||
|
src/test_rendering_shared_map.cpp
|
||||||
|
src/test_rendering.cpp
|
||||||
|
src/test_to_bool.cpp
|
||||||
|
src/test_to_double.cpp
|
||||||
|
src/test_to_int.cpp
|
||||||
|
src/test_to_string1.cpp
|
||||||
|
src/test_to_string2.cpp
|
||||||
|
src/test_utf_encoding.cpp
|
||||||
|
)
|
||||||
|
function(mapnik_create_benchmark)
|
||||||
|
get_filename_component(BENCHNAME ${ARGV0} NAME_WE)
|
||||||
|
set(TARGET_NAME "mapnik-benchmark-${BENCHNAME}")
|
||||||
|
add_executable(${TARGET_NAME} ${ARGV0})
|
||||||
|
target_include_directories(${TARGET_NAME} PRIVATE include)
|
||||||
|
target_link_libraries(${TARGET_NAME} PRIVATE
|
||||||
|
mapnik::agg
|
||||||
|
mapnik::mapnik
|
||||||
|
ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?)
|
||||||
|
)
|
||||||
|
set_target_properties(${TARGET_NAME} PROPERTIES
|
||||||
|
OUTPUT_NAME "${BENCHNAME}"
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
foreach(benchmark ${BENCHMARK_SRCS})
|
||||||
|
mapnik_create_benchmark(${benchmark})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
file(COPY data DESTINATION "${MAPNIK_OUTPUT_DIR}/benchmark")
|
||||||
|
file(COPY run_benchmarks
|
||||||
|
DESTINATION "${MAPNIK_OUTPUT_DIR}"
|
||||||
|
FILE_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE GROUP_WRITE GROUP_READ GROUP_EXECUTE WORLD_READ
|
||||||
|
)
|
|
@ -9,6 +9,7 @@ test_env = env.Clone()
|
||||||
test_env['LIBS'] = [env['MAPNIK_NAME']]
|
test_env['LIBS'] = [env['MAPNIK_NAME']]
|
||||||
test_env.AppendUnique(LIBS=copy(env['LIBMAPNIK_LIBS']))
|
test_env.AppendUnique(LIBS=copy(env['LIBMAPNIK_LIBS']))
|
||||||
test_env.AppendUnique(LIBS='mapnik-wkt')
|
test_env.AppendUnique(LIBS='mapnik-wkt')
|
||||||
|
test_env.AppendUnique(LIBS='sqlite3')
|
||||||
if env['PLATFORM'] == 'Linux':
|
if env['PLATFORM'] == 'Linux':
|
||||||
test_env.AppendUnique(LIBS='dl')
|
test_env.AppendUnique(LIBS='dl')
|
||||||
test_env.AppendUnique(LIBS='rt')
|
test_env.AppendUnique(LIBS='rt')
|
||||||
|
@ -18,40 +19,19 @@ test_env.Append(CPPDEFINES = env['LIBMAPNIK_DEFINES'])
|
||||||
if test_env['HAS_CAIRO']:
|
if test_env['HAS_CAIRO']:
|
||||||
test_env.PrependUnique(CPPPATH=test_env['CAIRO_CPPPATHS'])
|
test_env.PrependUnique(CPPPATH=test_env['CAIRO_CPPPATHS'])
|
||||||
test_env.Append(CPPDEFINES = '-DHAVE_CAIRO')
|
test_env.Append(CPPDEFINES = '-DHAVE_CAIRO')
|
||||||
|
test_env.PrependUnique(CPPPATH='include', delete_existing=True)
|
||||||
test_env['LINKFLAGS'] = copy(test_env['LIBMAPNIK_LINKFLAGS'])
|
test_env['LINKFLAGS'] = copy(test_env['LIBMAPNIK_LINKFLAGS'])
|
||||||
if env['PLATFORM'] == 'Darwin':
|
if env['PLATFORM'] == 'Darwin':
|
||||||
test_env.Append(LINKFLAGS='-F/ -framework CoreFoundation')
|
test_env.Append(LINKFLAGS='-F/ -framework CoreFoundation')
|
||||||
|
|
||||||
test_env_local = test_env.Clone()
|
test_env_local = test_env.Clone()
|
||||||
|
|
||||||
#benchmarks = glob.glob('test*cpp')
|
benchmarks = glob.glob("src/*.cpp")
|
||||||
benchmarks = [
|
|
||||||
#"test_array_allocation.cpp",
|
for src in benchmarks:
|
||||||
#"test_png_encoding1.cpp",
|
name, ext = os.path.splitext(os.path.basename(src))
|
||||||
#"test_png_encoding2.cpp",
|
out = os.path.join("out", name)
|
||||||
#"test_to_string1.cpp",
|
test_program = test_env_local.Program(out, source=[src])
|
||||||
#"test_to_string2.cpp",
|
|
||||||
#"test_to_bool.cpp",
|
|
||||||
#"test_to_double.cpp",
|
|
||||||
#"test_to_int.cpp",
|
|
||||||
#"test_utf_encoding.cpp"
|
|
||||||
"test_polygon_clipping.cpp",
|
|
||||||
#"test_polygon_clipping_rendering.cpp",
|
|
||||||
"test_proj_transform1.cpp",
|
|
||||||
"test_expression_parse.cpp",
|
|
||||||
"test_face_ptr_creation.cpp",
|
|
||||||
"test_font_registration.cpp",
|
|
||||||
"test_rendering.cpp",
|
|
||||||
"test_rendering_shared_map.cpp",
|
|
||||||
"test_offset_converter.cpp",
|
|
||||||
"test_marker_cache.cpp",
|
|
||||||
"test_quad_tree.cpp",
|
|
||||||
"test_noop_rendering.cpp",
|
|
||||||
"test_getline.cpp",
|
|
||||||
# "test_numeric_cast_vs_static_cast.cpp",
|
|
||||||
]
|
|
||||||
for cpp_test in benchmarks:
|
|
||||||
test_program = test_env_local.Program('out/'+cpp_test.replace('.cpp',''), source=[cpp_test])
|
|
||||||
if 'install' in COMMAND_LINE_TARGETS:
|
if 'install' in COMMAND_LINE_TARGETS:
|
||||||
env.Alias('install',test_program)
|
env.Alias('install',test_program)
|
||||||
#Depends(test_program, env.subst('../src/%s' % env['MAPNIK_LIB_NAME']))
|
#Depends(test_program, env.subst('../src/%s' % env['MAPNIK_LIB_NAME']))
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
#ifndef MAPNIK_COMPARE_IMAGES_HPP
|
|
||||||
#define MAPNIK_COMPARE_IMAGES_HPP
|
|
||||||
|
|
||||||
#include <mapnik/image.hpp>
|
|
||||||
#include <mapnik/image_util.hpp>
|
|
||||||
#include <mapnik/image_reader.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
namespace benchmark {
|
|
||||||
|
|
||||||
bool compare_images(std::string const& src_fn,std::string const& dest_fn)
|
|
||||||
{
|
|
||||||
std::unique_ptr<mapnik::image_reader> reader1(mapnik::get_image_reader(dest_fn,"png"));
|
|
||||||
if (!reader1.get())
|
|
||||||
{
|
|
||||||
throw mapnik::image_reader_exception("Failed to load: " + dest_fn);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<mapnik::image_reader> reader2(mapnik::get_image_reader(src_fn,"png"));
|
|
||||||
if (!reader2.get())
|
|
||||||
{
|
|
||||||
throw mapnik::image_reader_exception("Failed to load: " + src_fn);
|
|
||||||
}
|
|
||||||
|
|
||||||
const mapnik::image_any desc_any = reader1->read(0,0,reader1->width(), reader1->height());
|
|
||||||
const mapnik::image_any src_any = reader2->read(0,0,reader2->width(), reader2->height());
|
|
||||||
|
|
||||||
mapnik::image_rgba8 const& dest = mapnik::util::get<mapnik::image_rgba8>(desc_any);
|
|
||||||
mapnik::image_rgba8 const& src = mapnik::util::get<mapnik::image_rgba8>(src_any);
|
|
||||||
|
|
||||||
return compare(dest, src, 0, true) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // MAPNIK_COMPARE_IMAGES_HPP
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!DOCTYPE Map[]>
|
<!DOCTYPE Map[]>
|
||||||
<Map
|
<Map
|
||||||
srs="+init=epsg:4326"
|
srs="epsg:4326"
|
||||||
background-color="#dfd8c9">
|
background-color="#dfd8c9">
|
||||||
|
|
||||||
<Style name="style">
|
<Style name="style">
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
</Rule>
|
</Rule>
|
||||||
</Style>
|
</Style>
|
||||||
<Layer name="layer"
|
<Layer name="layer"
|
||||||
srs="+init=epsg:4326">
|
srs="epsg:4326">
|
||||||
<StyleName>style</StyleName>
|
<StyleName>style</StyleName>
|
||||||
<Datasource>
|
<Datasource>
|
||||||
<Parameter name="file">./valid.geotiff.tif</Parameter>
|
<Parameter name="file">./valid.geotiff.tif</Parameter>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!DOCTYPE Map[]>
|
<!DOCTYPE Map[]>
|
||||||
<Map
|
<Map
|
||||||
srs="+init=epsg:4326"
|
srs="epsg:4326"
|
||||||
background-color="#dfd8c9">
|
background-color="#dfd8c9">
|
||||||
|
|
||||||
<Style name="style">
|
<Style name="style">
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
</Rule>
|
</Rule>
|
||||||
</Style>
|
</Style>
|
||||||
<Layer name="layer"
|
<Layer name="layer"
|
||||||
srs="+init=epsg:4326">
|
srs="epsg:4326">
|
||||||
<StyleName>style</StyleName>
|
<StyleName>style</StyleName>
|
||||||
<Datasource>
|
<Datasource>
|
||||||
<Parameter name="file">./valid.geotiff.tif</Parameter>
|
<Parameter name="file">./valid.geotiff.tif</Parameter>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define MAPNIK_BENCH_FRAMEWORK_HPP
|
#define MAPNIK_BENCH_FRAMEWORK_HPP
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
|
#include <mapnik/mapnik.hpp>
|
||||||
#include <mapnik/debug.hpp>
|
#include <mapnik/debug.hpp>
|
||||||
#include <mapnik/params.hpp>
|
#include <mapnik/params.hpp>
|
||||||
#include <mapnik/value/types.hpp>
|
#include <mapnik/value/types.hpp>
|
||||||
|
@ -12,44 +13,36 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cmath> // log10, round
|
#include <cmath> // log10, round
|
||||||
#include <cstdio> // snprintf
|
#include <cstdio> // snprintf
|
||||||
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <set>
|
|
||||||
#include <sstream>
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <mutex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace benchmark {
|
namespace benchmark {
|
||||||
|
|
||||||
template <typename T>
|
template<typename T>
|
||||||
using milliseconds = std::chrono::duration<T, std::milli>;
|
using milliseconds = std::chrono::duration<T, std::milli>;
|
||||||
|
|
||||||
template <typename T>
|
template<typename T>
|
||||||
using seconds = std::chrono::duration<T>;
|
using seconds = std::chrono::duration<T>;
|
||||||
|
|
||||||
class test_case
|
class test_case
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
mapnik::parameters params_;
|
mapnik::parameters params_;
|
||||||
std::size_t threads_;
|
std::size_t threads_;
|
||||||
std::size_t iterations_;
|
std::size_t iterations_;
|
||||||
public:
|
|
||||||
|
public:
|
||||||
test_case(mapnik::parameters const& params)
|
test_case(mapnik::parameters const& params)
|
||||||
: params_(params),
|
: params_(params)
|
||||||
threads_(mapnik::safe_cast<std::size_t>(*params.get<mapnik::value_integer>("threads",0))),
|
, threads_(mapnik::safe_cast<std::size_t>(*params.get<mapnik::value_integer>("threads", 0)))
|
||||||
iterations_(mapnik::safe_cast<std::size_t>(*params.get<mapnik::value_integer>("iterations",0)))
|
, iterations_(mapnik::safe_cast<std::size_t>(*params.get<mapnik::value_integer>("iterations", 0)))
|
||||||
{}
|
{}
|
||||||
std::size_t threads() const
|
std::size_t threads() const { return threads_; }
|
||||||
{
|
std::size_t iterations() const { return iterations_; }
|
||||||
return threads_;
|
mapnik::parameters const& params() const { return params_; }
|
||||||
}
|
|
||||||
std::size_t iterations() const
|
|
||||||
{
|
|
||||||
return iterations_;
|
|
||||||
}
|
|
||||||
mapnik::parameters const& params() const
|
|
||||||
{
|
|
||||||
return params_;
|
|
||||||
}
|
|
||||||
virtual bool validate() const = 0;
|
virtual bool validate() const = 0;
|
||||||
virtual bool operator()() const = 0;
|
virtual bool operator()() const = 0;
|
||||||
};
|
};
|
||||||
|
@ -57,21 +50,25 @@ public:
|
||||||
// gathers --long-option values in 'params';
|
// gathers --long-option values in 'params';
|
||||||
// returns the index of the first non-option argument,
|
// returns the index of the first non-option argument,
|
||||||
// or negated index of an ill-formed option argument
|
// or negated index of an ill-formed option argument
|
||||||
inline int parse_args(int argc, char** argv, mapnik::parameters & params)
|
inline int parse_args(int argc, char** argv, mapnik::parameters& params)
|
||||||
{
|
{
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i)
|
||||||
|
{
|
||||||
const char* opt = argv[i];
|
const char* opt = argv[i];
|
||||||
if (opt[0] != '-') {
|
if (opt[0] != '-')
|
||||||
|
{
|
||||||
// non-option argument, return its index
|
// non-option argument, return its index
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
if (opt[1] != '-') {
|
if (opt[1] != '-')
|
||||||
|
{
|
||||||
// we only accept --long-options, but instead of throwing,
|
// we only accept --long-options, but instead of throwing,
|
||||||
// just issue a warning and let the caller decide what to do
|
// just issue a warning and let the caller decide what to do
|
||||||
std::clog << argv[0] << ": invalid option '" << opt << "'\n";
|
std::clog << argv[0] << ": invalid option '" << opt << "'\n";
|
||||||
return -i; // negative means ill-formed option #i
|
return -i; // negative means ill-formed option #i
|
||||||
}
|
}
|
||||||
if (opt[2] == '\0') {
|
if (opt[2] == '\0')
|
||||||
|
{
|
||||||
// option-list terminator '--'
|
// option-list terminator '--'
|
||||||
return i + 1;
|
return i + 1;
|
||||||
}
|
}
|
||||||
|
@ -79,15 +76,18 @@ inline int parse_args(int argc, char** argv, mapnik::parameters & params)
|
||||||
// take option name without the leading '--'
|
// take option name without the leading '--'
|
||||||
std::string key(opt + 2);
|
std::string key(opt + 2);
|
||||||
size_t eq = key.find('=');
|
size_t eq = key.find('=');
|
||||||
if (eq != std::string::npos) {
|
if (eq != std::string::npos)
|
||||||
|
{
|
||||||
// one-argument form '--foo=bar'
|
// one-argument form '--foo=bar'
|
||||||
params[key.substr(0, eq)] = key.substr(eq + 1);
|
params[key.substr(0, eq)] = key.substr(eq + 1);
|
||||||
}
|
}
|
||||||
else if (i + 1 < argc) {
|
else if (i + 1 < argc)
|
||||||
|
{
|
||||||
// two-argument form '--foo' 'bar'
|
// two-argument form '--foo' 'bar'
|
||||||
params[key] = std::string(argv[++i]);
|
params[key] = std::string(argv[++i]);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
// missing second argument
|
// missing second argument
|
||||||
std::clog << argv[0] << ": missing option '" << opt << "' value\n";
|
std::clog << argv[0] << ": missing option '" << opt << "' value\n";
|
||||||
return -i; // negative means ill-formed option #i
|
return -i; // negative means ill-formed option #i
|
||||||
|
@ -98,7 +98,8 @@ inline int parse_args(int argc, char** argv, mapnik::parameters & params)
|
||||||
|
|
||||||
inline void handle_common_args(mapnik::parameters const& params)
|
inline void handle_common_args(mapnik::parameters const& params)
|
||||||
{
|
{
|
||||||
if (auto severity = params.get<std::string>("log")) {
|
if (auto severity = params.get<std::string>("log"))
|
||||||
|
{
|
||||||
if (*severity == "debug")
|
if (*severity == "debug")
|
||||||
mapnik::logger::set_severity(mapnik::logger::debug);
|
mapnik::logger::set_severity(mapnik::logger::debug);
|
||||||
else if (*severity == "warn")
|
else if (*severity == "warn")
|
||||||
|
@ -108,27 +109,27 @@ inline void handle_common_args(mapnik::parameters const& params)
|
||||||
else if (*severity == "none")
|
else if (*severity == "none")
|
||||||
mapnik::logger::set_severity(mapnik::logger::none);
|
mapnik::logger::set_severity(mapnik::logger::none);
|
||||||
else
|
else
|
||||||
std::clog << "ignoring option --log='" << *severity
|
std::clog << "ignoring option --log='" << *severity << "' (allowed values are: debug, warn, error, none)\n";
|
||||||
<< "' (allowed values are: debug, warn, error, none)\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int handle_args(int argc, char** argv, mapnik::parameters & params)
|
inline int handle_args(int argc, char** argv, mapnik::parameters& params)
|
||||||
{
|
{
|
||||||
int res = parse_args(argc, argv, params);
|
int res = parse_args(argc, argv, params);
|
||||||
handle_common_args(params);
|
handle_common_args(params);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BENCHMARK(test_class,name) \
|
#define BENCHMARK(test_class, name) \
|
||||||
int main(int argc, char** argv) \
|
int main(int argc, char** argv) \
|
||||||
{ \
|
{ \
|
||||||
|
mapnik::setup(); \
|
||||||
try \
|
try \
|
||||||
{ \
|
{ \
|
||||||
mapnik::parameters params; \
|
mapnik::parameters params; \
|
||||||
benchmark::handle_args(argc,argv,params); \
|
benchmark::handle_args(argc, argv, params); \
|
||||||
test_class test_runner(params); \
|
test_class test_runner(params); \
|
||||||
auto result = run(test_runner,name); \
|
auto result = run(test_runner, name); \
|
||||||
testing::run_cleanup(); \
|
testing::run_cleanup(); \
|
||||||
return result; \
|
return result; \
|
||||||
} \
|
} \
|
||||||
|
@ -138,7 +139,7 @@ inline int handle_args(int argc, char** argv, mapnik::parameters & params)
|
||||||
testing::run_cleanup(); \
|
testing::run_cleanup(); \
|
||||||
return -1; \
|
return -1; \
|
||||||
} \
|
} \
|
||||||
} \
|
}
|
||||||
|
|
||||||
struct big_number_fmt
|
struct big_number_fmt
|
||||||
{
|
{
|
||||||
|
@ -147,7 +148,9 @@ struct big_number_fmt
|
||||||
const char* u;
|
const char* u;
|
||||||
|
|
||||||
big_number_fmt(int width, double value, int base = 1000)
|
big_number_fmt(int width, double value, int base = 1000)
|
||||||
: w(width), v(value), u("")
|
: w(width)
|
||||||
|
, v(value)
|
||||||
|
, u("")
|
||||||
{
|
{
|
||||||
static const char* suffixes = "\0\0k\0M\0G\0T\0P\0E\0Z\0Y\0\0";
|
static const char* suffixes = "\0\0k\0M\0G\0T\0P\0E\0Z\0Y\0\0";
|
||||||
u = suffixes;
|
u = suffixes;
|
||||||
|
@ -163,7 +166,7 @@ struct big_number_fmt
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template<typename T>
|
||||||
int run(T const& test_runner, std::string const& name)
|
int run(T const& test_runner, std::string const& name)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -194,8 +197,7 @@ int run(T const& test_runner, std::string const& name)
|
||||||
std::mutex mtx_ready;
|
std::mutex mtx_ready;
|
||||||
std::unique_lock<std::mutex> lock_ready(mtx_ready);
|
std::unique_lock<std::mutex> lock_ready(mtx_ready);
|
||||||
|
|
||||||
auto stub = [&](T const& test_copy)
|
auto stub = [&](T const& test_copy) {
|
||||||
{
|
|
||||||
// workers will wait on this mutex until the main thread
|
// workers will wait on this mutex until the main thread
|
||||||
// constructs all of them and starts measuring time
|
// constructs all of them and starts measuring time
|
||||||
std::unique_lock<std::mutex> my_lock(mtx_ready);
|
std::unique_lock<std::mutex> my_lock(mtx_ready);
|
||||||
|
@ -205,14 +207,14 @@ int run(T const& test_runner, std::string const& name)
|
||||||
|
|
||||||
std::vector<std::thread> tg;
|
std::vector<std::thread> tg;
|
||||||
tg.reserve(num_threads);
|
tg.reserve(num_threads);
|
||||||
for (auto i = num_threads; i-- > 0; )
|
for (auto i = num_threads; i-- > 0;)
|
||||||
{
|
{
|
||||||
tg.emplace_back(stub, test_runner);
|
tg.emplace_back(stub, test_runner);
|
||||||
}
|
}
|
||||||
start = std::chrono::high_resolution_clock::now();
|
start = std::chrono::high_resolution_clock::now();
|
||||||
lock_ready.unlock();
|
lock_ready.unlock();
|
||||||
// wait for all workers to finish
|
// wait for all workers to finish
|
||||||
for (auto & t : tg)
|
for (auto& t : tg)
|
||||||
{
|
{
|
||||||
if (t.joinable())
|
if (t.joinable())
|
||||||
t.join();
|
t.join();
|
||||||
|
@ -226,7 +228,8 @@ int run(T const& test_runner, std::string const& name)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
start = std::chrono::high_resolution_clock::now();
|
start = std::chrono::high_resolution_clock::now();
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
test_runner();
|
test_runner();
|
||||||
elapsed = std::chrono::high_resolution_clock::now() - start;
|
elapsed = std::chrono::high_resolution_clock::now() - start;
|
||||||
total_iters += num_iters;
|
total_iters += num_iters;
|
||||||
|
@ -239,14 +242,26 @@ int run(T const& test_runner, std::string const& name)
|
||||||
big_number_fmt itersf(4, total_iters);
|
big_number_fmt itersf(4, total_iters);
|
||||||
big_number_fmt ips(5, total_iters / seconds<double>(elapsed_nonzero).count());
|
big_number_fmt ips(5, total_iters / seconds<double>(elapsed_nonzero).count());
|
||||||
|
|
||||||
std::snprintf(msg, sizeof(msg),
|
std::clog << std::left << std::setw(43) << name;
|
||||||
"%-43s %3zu threads %*.0f%s iters %6.0f milliseconds %*.0f%s i/s\n",
|
std::clog << std::resetiosflags(std::ios::adjustfield);
|
||||||
name.c_str(),
|
if (num_threads > 0)
|
||||||
num_threads,
|
{
|
||||||
itersf.w, itersf.v, itersf.u,
|
std::clog << ' ' << std::setw(3) << num_threads << " worker" << (num_threads > 1 ? "s" : " ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::clog << " main thread";
|
||||||
|
}
|
||||||
|
std::snprintf(msg,
|
||||||
|
sizeof(msg),
|
||||||
|
" %*.0f%s iters %6.0f milliseconds %*.0f%s i/t/s\n",
|
||||||
|
itersf.w,
|
||||||
|
itersf.v,
|
||||||
|
itersf.u,
|
||||||
dur_total,
|
dur_total,
|
||||||
ips.w, ips.v, ips.u
|
ips.w,
|
||||||
);
|
ips.v,
|
||||||
|
ips.u);
|
||||||
std::clog << msg;
|
std::clog << msg;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -265,13 +280,10 @@ struct sequencer
|
||||||
benchmark::handle_args(argc, argv, params_);
|
benchmark::handle_args(argc, argv, params_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int done() const
|
int done() const { return exit_code_; }
|
||||||
{
|
|
||||||
return exit_code_;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Test, typename... Args>
|
template<typename Test, typename... Args>
|
||||||
sequencer & run(std::string const& name, Args && ...args)
|
sequencer& run(std::string const& name, Args&&... args)
|
||||||
{
|
{
|
||||||
// Test instance lifetime is confined to this function
|
// Test instance lifetime is confined to this function
|
||||||
Test test_runner(params_, std::forward<Args>(args)...);
|
Test test_runner(params_, std::forward<Args>(args)...);
|
||||||
|
@ -280,11 +292,11 @@ struct sequencer
|
||||||
return *this; // allow chaining calls
|
return *this; // allow chaining calls
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
mapnik::parameters params_;
|
mapnik::parameters params_;
|
||||||
int exit_code_;
|
int exit_code_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace benchmark
|
||||||
|
|
||||||
#endif // MAPNIK_BENCH_FRAMEWORK_HPP
|
#endif // MAPNIK_BENCH_FRAMEWORK_HPP
|
35
benchmark/include/compare_images.hpp
Normal file
35
benchmark/include/compare_images.hpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef MAPNIK_COMPARE_IMAGES_HPP
|
||||||
|
#define MAPNIK_COMPARE_IMAGES_HPP
|
||||||
|
|
||||||
|
#include <mapnik/image.hpp>
|
||||||
|
#include <mapnik/image_util.hpp>
|
||||||
|
#include <mapnik/image_reader.hpp>
|
||||||
|
|
||||||
|
namespace benchmark {
|
||||||
|
|
||||||
|
bool compare_images(std::string const& src_fn, std::string const& dest_fn)
|
||||||
|
{
|
||||||
|
std::unique_ptr<mapnik::image_reader> reader1(mapnik::get_image_reader(dest_fn, "png"));
|
||||||
|
if (!reader1.get())
|
||||||
|
{
|
||||||
|
throw mapnik::image_reader_exception("Failed to load: " + dest_fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<mapnik::image_reader> reader2(mapnik::get_image_reader(src_fn, "png"));
|
||||||
|
if (!reader2.get())
|
||||||
|
{
|
||||||
|
throw mapnik::image_reader_exception("Failed to load: " + src_fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
const mapnik::image_any desc_any = reader1->read(0, 0, reader1->width(), reader1->height());
|
||||||
|
const mapnik::image_any src_any = reader2->read(0, 0, reader2->width(), reader2->height());
|
||||||
|
|
||||||
|
mapnik::image_rgba8 const& dest = mapnik::util::get<mapnik::image_rgba8>(desc_any);
|
||||||
|
mapnik::image_rgba8 const& src = mapnik::util::get<mapnik::image_rgba8>(src_any);
|
||||||
|
|
||||||
|
return compare(dest, src, 0, true) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace benchmark
|
||||||
|
|
||||||
|
#endif // MAPNIK_COMPARE_IMAGES_HPP
|
|
@ -28,6 +28,7 @@ run test_expression_parse 10 10000
|
||||||
run test_face_ptr_creation 10 1000
|
run test_face_ptr_creation 10 1000
|
||||||
run test_font_registration 10 100
|
run test_font_registration 10 100
|
||||||
run test_offset_converter 10 1000
|
run test_offset_converter 10 1000
|
||||||
|
#run normalize_angle 0 1000000 --min-duration=0.2
|
||||||
|
|
||||||
# commented since this is really slow on travis
|
# commented since this is really slow on travis
|
||||||
: '
|
: '
|
||||||
|
|
65
benchmark/run_benchmarks
Normal file
65
benchmark/run_benchmarks
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
BASE=.
|
||||||
|
function run {
|
||||||
|
local runner="$BASE/$1 --log=none"
|
||||||
|
local threads="$2"
|
||||||
|
local iters="$3"
|
||||||
|
shift 3
|
||||||
|
$runner --threads 0 --iterations $iters "$@"
|
||||||
|
if test $threads -gt 0; then
|
||||||
|
$runner --threads $threads --iterations $((iters/threads)) "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
run test_getline 30 10000000
|
||||||
|
#run test_array_allocation 20 100000
|
||||||
|
#run test_png_encoding1 10 1000
|
||||||
|
#run test_png_encoding2 10 50
|
||||||
|
#run test_to_string1 10 100000
|
||||||
|
#run test_to_string2 10 100000
|
||||||
|
#run test_polygon_clipping 10 1000
|
||||||
|
#run test_polygon_clipping_rendering 10 100
|
||||||
|
run test_proj_transform1 10 100
|
||||||
|
run test_expression_parse 10 10000
|
||||||
|
run test_face_ptr_creation 10 1000
|
||||||
|
run test_font_registration 10 100
|
||||||
|
run test_offset_converter 10 1000
|
||||||
|
#run normalize_angle 0 1000000 --min-duration=0.2
|
||||||
|
|
||||||
|
# commented since this is really slow on travis
|
||||||
|
: '
|
||||||
|
$BASE/test_rendering \
|
||||||
|
--name "text rendering" \
|
||||||
|
--map benchmark/data/roads.xml \
|
||||||
|
--extent 1477001.12245,6890242.37746,1480004.49012,6892244.62256 \
|
||||||
|
--width 600 \
|
||||||
|
--height 600 \
|
||||||
|
--iterations 20 \
|
||||||
|
--threads 10
|
||||||
|
'
|
||||||
|
|
||||||
|
$BASE/test_rendering \
|
||||||
|
--name "gdal tiff rendering" \
|
||||||
|
--map benchmark/data/gdal-wgs.xml \
|
||||||
|
--extent -180.0,-120.0,180.0,120.0 \
|
||||||
|
--width 600 \
|
||||||
|
--height 600 \
|
||||||
|
--iterations 20 \
|
||||||
|
--threads 10
|
||||||
|
|
||||||
|
$BASE/test_rendering \
|
||||||
|
--name "raster tiff rendering" \
|
||||||
|
--map benchmark/data/raster-wgs.xml \
|
||||||
|
--extent -180.0,-120.0,180.0,120.0 \
|
||||||
|
--width 600 \
|
||||||
|
--height 600 \
|
||||||
|
--iterations 20 \
|
||||||
|
--threads 10
|
||||||
|
|
||||||
|
$BASE/test_quad_tree \
|
||||||
|
--iterations 10000 \
|
||||||
|
--threads 1
|
||||||
|
|
||||||
|
$BASE/test_quad_tree \
|
||||||
|
--iterations 1000 \
|
||||||
|
--threads 10
|
72
benchmark/src/normalize_angle.cpp
Normal file
72
benchmark/src/normalize_angle.cpp
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
#include "bench_framework.hpp"
|
||||||
|
|
||||||
|
#include <mapnik/util/math.hpp>
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct bench_func : benchmark::test_case
|
||||||
|
{
|
||||||
|
T (*const func_)(T);
|
||||||
|
T const value_;
|
||||||
|
|
||||||
|
bench_func(mapnik::parameters const& params, T (*func)(T), T value)
|
||||||
|
: test_case(params)
|
||||||
|
, func_(func)
|
||||||
|
, value_(value)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool validate() const { return true; }
|
||||||
|
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
for (auto i = this->iterations_; i-- > 0;)
|
||||||
|
{
|
||||||
|
func_(value_);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#define BENCH_FUNC1(func, value) run<bench_func<double>>(#func "(" #value ")", func, value)
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
mapnik::setup();
|
||||||
|
return benchmark::sequencer(argc, argv)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +3)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +6)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +9)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +12)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +15)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +20)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +30)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +40)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +50)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +70)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +90)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +110)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +130)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +157)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +209)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +314)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +628)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +942)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -3)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -6)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -9)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -12)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -15)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -20)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -30)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -40)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -50)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -70)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -90)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -110)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -130)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -157)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -209)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -314)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -628)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -942)
|
||||||
|
.done();
|
||||||
|
}
|
370
benchmark/src/test_array_allocation.cpp
Normal file
370
benchmark/src/test_array_allocation.cpp
Normal file
|
@ -0,0 +1,370 @@
|
||||||
|
#include "bench_framework.hpp"
|
||||||
|
#include <cstring>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <deque>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <array>
|
||||||
|
#include <valarray>
|
||||||
|
#include <boost/version.hpp>
|
||||||
|
#if BOOST_VERSION >= 105400
|
||||||
|
#include <boost/container/static_vector.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// http://stackoverflow.com/questions/17347254/why-is-allocation-and-deallocation-of-stdvector-slower-than-dynamic-array-on-m
|
||||||
|
|
||||||
|
#define FULL_ZERO_CHECK
|
||||||
|
|
||||||
|
inline void ensure_zero(uint8_t* data, uint32_t size)
|
||||||
|
{
|
||||||
|
#ifdef FULL_ZERO_CHECK
|
||||||
|
for (std::size_t i = 0; i < size; ++i)
|
||||||
|
{
|
||||||
|
if (data[i] != 0)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("found non zero value");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (data[0] != 0)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("found non zero value");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
class test1 : public benchmark::test_case
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint32_t size_;
|
||||||
|
std::vector<uint8_t> array_;
|
||||||
|
test1(mapnik::parameters const& params)
|
||||||
|
: test_case(params)
|
||||||
|
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||||
|
, array_(size_, 0)
|
||||||
|
{}
|
||||||
|
bool validate() const { return true; }
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
// NOTE: sizeof(uint8_t) == 1
|
||||||
|
uint8_t* data = (uint8_t*)malloc(sizeof(uint8_t) * size_);
|
||||||
|
memcpy(data, &array_[0], size_);
|
||||||
|
ensure_zero(data, size_);
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class test1b : public benchmark::test_case
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint32_t size_;
|
||||||
|
std::vector<uint8_t> array_;
|
||||||
|
test1b(mapnik::parameters const& params)
|
||||||
|
: test_case(params)
|
||||||
|
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||||
|
, array_(size_, 0)
|
||||||
|
{}
|
||||||
|
bool validate() const { return true; }
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
// NOTE: sizeof(uint8_t) == 1
|
||||||
|
uint8_t* data = (uint8_t*)malloc(sizeof(uint8_t) * size_);
|
||||||
|
memset(data, 0, sizeof(uint8_t) * size_);
|
||||||
|
ensure_zero(data, size_);
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class test1c : public benchmark::test_case
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint32_t size_;
|
||||||
|
std::vector<uint8_t> array_;
|
||||||
|
test1c(mapnik::parameters const& params)
|
||||||
|
: test_case(params)
|
||||||
|
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||||
|
, array_(size_, 0)
|
||||||
|
{}
|
||||||
|
bool validate() const { return true; }
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
uint8_t* data = static_cast<uint8_t*>(::operator new(sizeof(uint8_t) * size_));
|
||||||
|
std::fill(data, data + size_, 0);
|
||||||
|
ensure_zero(data, size_);
|
||||||
|
::operator delete(data);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class test2 : public benchmark::test_case
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint32_t size_;
|
||||||
|
std::vector<uint8_t> array_;
|
||||||
|
test2(mapnik::parameters const& params)
|
||||||
|
: test_case(params)
|
||||||
|
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||||
|
, array_(size_, 0)
|
||||||
|
{}
|
||||||
|
bool validate() const { return true; }
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
uint8_t* data = static_cast<uint8_t*>(::operator new(sizeof(uint8_t) * size_));
|
||||||
|
memcpy(data, &array_[0], size_);
|
||||||
|
ensure_zero(data, size_);
|
||||||
|
::operator delete(data), data = 0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class test3 : public benchmark::test_case
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint32_t size_;
|
||||||
|
std::vector<uint8_t> array_;
|
||||||
|
test3(mapnik::parameters const& params)
|
||||||
|
: test_case(params)
|
||||||
|
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||||
|
, array_(size_, 0)
|
||||||
|
{}
|
||||||
|
bool validate() const { return true; }
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
std::vector<uint8_t> data(size_);
|
||||||
|
ensure_zero(&data[0], data.size());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class test3b : public benchmark::test_case
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint32_t size_;
|
||||||
|
std::vector<uint8_t> array_;
|
||||||
|
test3b(mapnik::parameters const& params)
|
||||||
|
: test_case(params)
|
||||||
|
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||||
|
, array_(size_, 0)
|
||||||
|
{}
|
||||||
|
bool validate() const { return true; }
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
std::vector<uint8_t> data(0);
|
||||||
|
data.resize(size_, 0);
|
||||||
|
ensure_zero(&data[0], data.size());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class test3c : public benchmark::test_case
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint32_t size_;
|
||||||
|
std::vector<uint8_t> array_;
|
||||||
|
test3c(mapnik::parameters const& params)
|
||||||
|
: test_case(params)
|
||||||
|
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||||
|
, array_(size_, 0)
|
||||||
|
{}
|
||||||
|
bool validate() const { return true; }
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
std::vector<uint8_t> data(0);
|
||||||
|
data.assign(size_, 0);
|
||||||
|
ensure_zero(&data[0], data.size());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class test3d : public benchmark::test_case
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint32_t size_;
|
||||||
|
std::vector<uint8_t> array_;
|
||||||
|
test3d(mapnik::parameters const& params)
|
||||||
|
: test_case(params)
|
||||||
|
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||||
|
, array_(size_, 0)
|
||||||
|
{}
|
||||||
|
bool validate() const { return true; }
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
std::deque<uint8_t> data(size_);
|
||||||
|
for (std::size_t i = 0; i < size_; ++i)
|
||||||
|
{
|
||||||
|
if (data[i] != 0)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("found non zero value");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class test4 : public benchmark::test_case
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint32_t size_;
|
||||||
|
std::vector<uint8_t> array_;
|
||||||
|
test4(mapnik::parameters const& params)
|
||||||
|
: test_case(params)
|
||||||
|
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||||
|
, array_(size_, 0)
|
||||||
|
{}
|
||||||
|
bool validate() const { return true; }
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
uint8_t* data = (uint8_t*)calloc(size_, sizeof(uint8_t));
|
||||||
|
ensure_zero(data, size_);
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class test5 : public benchmark::test_case
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint32_t size_;
|
||||||
|
std::vector<uint8_t> array_;
|
||||||
|
test5(mapnik::parameters const& params)
|
||||||
|
: test_case(params)
|
||||||
|
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||||
|
, array_(size_, 0)
|
||||||
|
{}
|
||||||
|
bool validate() const { return true; }
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
std::string data(array_.begin(), array_.end());
|
||||||
|
ensure_zero((uint8_t*)&data[0], size_);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class test5b : public benchmark::test_case
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint32_t size_;
|
||||||
|
std::vector<char> array_;
|
||||||
|
test5b(mapnik::parameters const& params)
|
||||||
|
: test_case(params)
|
||||||
|
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||||
|
, array_(size_, 0)
|
||||||
|
{}
|
||||||
|
bool validate() const { return true; }
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
std::string data(&array_[0], array_.size());
|
||||||
|
ensure_zero((uint8_t*)&data[0], size_);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// C++14 dynarray<T>
|
||||||
|
// http://isocpp.org/blog/2013/04/trip-report-iso-c-spring-2013-meeting
|
||||||
|
// http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130909/088700.html
|
||||||
|
// http://stackoverflow.com/questions/17303902/any-alternative-to-stddynarray-presently-available
|
||||||
|
|
||||||
|
class test6 : public benchmark::test_case
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint32_t size_;
|
||||||
|
std::vector<uint8_t> array_;
|
||||||
|
test6(mapnik::parameters const& params)
|
||||||
|
: test_case(params)
|
||||||
|
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||||
|
, array_(size_, 0)
|
||||||
|
{}
|
||||||
|
bool validate() const { return true; }
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
std::valarray<uint8_t> data(static_cast<uint8_t>(0), static_cast<size_t>(size_));
|
||||||
|
ensure_zero(&data[0], size_);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#if BOOST_VERSION >= 105400
|
||||||
|
// http://i42.co.uk/stuff/vecarray.htm
|
||||||
|
// http://www.boost.org/doc/libs/1_54_0/doc/html/boost/container/static_vector.html
|
||||||
|
|
||||||
|
class test7 : public benchmark::test_case
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint32_t size_;
|
||||||
|
std::vector<uint8_t> array_;
|
||||||
|
test7(mapnik::parameters const& params)
|
||||||
|
: test_case(params)
|
||||||
|
, size_(*params.get<mapnik::value_integer>("size", 256 * 256))
|
||||||
|
, array_(size_, 0)
|
||||||
|
{}
|
||||||
|
bool validate() const { return true; }
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
boost::container::static_vector<uint8_t, 256 * 256> data(size_, 0);
|
||||||
|
ensure_zero(&data[0], size_);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
mapnik::setup();
|
||||||
|
return benchmark::sequencer(argc, argv)
|
||||||
|
.run<test4>("calloc")
|
||||||
|
.run<test1>("malloc/memcpy")
|
||||||
|
.run<test1b>("malloc/memset")
|
||||||
|
.run<test1c>("operator new/std::fill")
|
||||||
|
.run<test2>("operator new/memcpy")
|
||||||
|
.run<test3>("vector(N)")
|
||||||
|
.run<test3b>("vector/resize")
|
||||||
|
.run<test3c>("vector/assign")
|
||||||
|
.run<test3d>("deque(N)")
|
||||||
|
.run<test5>("std::string range")
|
||||||
|
.run<test5b>("std::string &[0]")
|
||||||
|
.run<test6>("valarray")
|
||||||
|
#if BOOST_VERSION >= 105400
|
||||||
|
.run<test7>("static_vector")
|
||||||
|
#endif
|
||||||
|
.done();
|
||||||
|
}
|
|
@ -7,10 +7,12 @@
|
||||||
class test : public benchmark::test_case
|
class test : public benchmark::test_case
|
||||||
{
|
{
|
||||||
std::string expr_;
|
std::string expr_;
|
||||||
public:
|
|
||||||
|
public:
|
||||||
test(mapnik::parameters const& params)
|
test(mapnik::parameters const& params)
|
||||||
: test_case(params),
|
: test_case(params)
|
||||||
expr_("((([mapnik::geometry_type]=2) and ([oneway]=1)) and ([class]='path'))") {}
|
, expr_("((([mapnik::geometry_type]=2) and ([oneway]=1)) and ([class]='path'))")
|
||||||
|
{}
|
||||||
bool validate() const
|
bool validate() const
|
||||||
{
|
{
|
||||||
mapnik::expression_ptr expr = mapnik::parse_expression(expr_);
|
mapnik::expression_ptr expr = mapnik::parse_expression(expr_);
|
||||||
|
@ -24,18 +26,19 @@ public:
|
||||||
}
|
}
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
mapnik::expression_ptr expr = mapnik::parse_expression(expr_);
|
mapnik::expression_ptr expr = mapnik::parse_expression(expr_);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
mapnik::setup();
|
||||||
mapnik::parameters params;
|
mapnik::parameters params;
|
||||||
benchmark::handle_args(argc,argv,params);
|
benchmark::handle_args(argc, argv, params);
|
||||||
test test_runner(params);
|
test test_runner(params);
|
||||||
return run(test_runner,"expr parsing");
|
return run(test_runner, "expr parsing");
|
||||||
}
|
}
|
|
@ -4,9 +4,10 @@
|
||||||
|
|
||||||
class test : public benchmark::test_case
|
class test : public benchmark::test_case
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
test(mapnik::parameters const& params)
|
test(mapnik::parameters const& params)
|
||||||
: test_case(params) {}
|
: test_case(params)
|
||||||
|
{}
|
||||||
bool validate() const
|
bool validate() const
|
||||||
{
|
{
|
||||||
std::size_t count = 0;
|
std::size_t count = 0;
|
||||||
|
@ -22,14 +23,15 @@ public:
|
||||||
font_cache,
|
font_cache,
|
||||||
mapnik::freetype_engine::get_mapping(),
|
mapnik::freetype_engine::get_mapping(),
|
||||||
mapnik::freetype_engine::get_cache());
|
mapnik::freetype_engine::get_cache());
|
||||||
if (f) ++count;
|
if (f)
|
||||||
|
++count;
|
||||||
}
|
}
|
||||||
return count == expected_count;
|
return count == expected_count;
|
||||||
}
|
}
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
std::size_t expected_count = mapnik::freetype_engine::face_names().size();
|
std::size_t expected_count = mapnik::freetype_engine::face_names().size();
|
||||||
for (unsigned i=0;i<iterations_;++i)
|
for (unsigned i = 0; i < iterations_; ++i)
|
||||||
{
|
{
|
||||||
std::size_t count = 0;
|
std::size_t count = 0;
|
||||||
mapnik::freetype_engine::font_file_mapping_type font_file_mapping;
|
mapnik::freetype_engine::font_file_mapping_type font_file_mapping;
|
||||||
|
@ -43,9 +45,11 @@ public:
|
||||||
font_cache,
|
font_cache,
|
||||||
mapnik::freetype_engine::get_mapping(),
|
mapnik::freetype_engine::get_mapping(),
|
||||||
mapnik::freetype_engine::get_cache());
|
mapnik::freetype_engine::get_cache());
|
||||||
if (f) ++count;
|
if (f)
|
||||||
|
++count;
|
||||||
}
|
}
|
||||||
if (count != expected_count) {
|
if (count != expected_count)
|
||||||
|
{
|
||||||
std::clog << "warning: face creation not working as expected\n";
|
std::clog << "warning: face creation not working as expected\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,15 +59,16 @@ public:
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
mapnik::setup();
|
||||||
mapnik::parameters params;
|
mapnik::parameters params;
|
||||||
benchmark::handle_args(argc,argv,params);
|
benchmark::handle_args(argc, argv, params);
|
||||||
bool success = mapnik::freetype_engine::register_fonts("./fonts", true);
|
bool success = mapnik::freetype_engine::register_fonts("./fonts", true);
|
||||||
if (!success) {
|
if (!success)
|
||||||
|
{
|
||||||
std::clog << "warning, did not register any new fonts!\n";
|
std::clog << "warning, did not register any new fonts!\n";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
std::size_t face_count = mapnik::freetype_engine::face_names().size();
|
std::size_t face_count = mapnik::freetype_engine::face_names().size();
|
||||||
test test_runner(params);
|
test test_runner(params);
|
||||||
return run(test_runner,(boost::format("font_engine: creating %ld faces") % (face_count)).str());
|
return run(test_runner, (boost::format("font_engine: creating %ld faces") % (face_count)).str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,18 @@
|
||||||
#include "bench_framework.hpp"
|
#include "bench_framework.hpp"
|
||||||
#include <mapnik/font_engine_freetype.hpp>
|
#include <mapnik/font_engine_freetype.hpp>
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
#include <boost/foreach.hpp>
|
|
||||||
|
|
||||||
class test : public benchmark::test_case
|
class test : public benchmark::test_case
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
test(mapnik::parameters const& params)
|
test(mapnik::parameters const& params)
|
||||||
: test_case(params) {}
|
: test_case(params)
|
||||||
bool validate() const
|
{}
|
||||||
{
|
bool validate() const { return mapnik::freetype_engine::register_fonts("./fonts", true); }
|
||||||
return mapnik::freetype_engine::register_fonts("./fonts", true);
|
|
||||||
}
|
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
unsigned long count = 0;
|
unsigned long count = 0;
|
||||||
for (unsigned i=0;i<iterations_;++i)
|
for (unsigned i = 0; i < iterations_; ++i)
|
||||||
{
|
{
|
||||||
mapnik::freetype_engine::register_fonts("./fonts", true);
|
mapnik::freetype_engine::register_fonts("./fonts", true);
|
||||||
count++;
|
count++;
|
||||||
|
@ -24,4 +21,4 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
BENCHMARK(test,"font registration")
|
BENCHMARK(test, "font registration")
|
|
@ -1,17 +1,15 @@
|
||||||
#include "bench_framework.hpp"
|
#include "bench_framework.hpp"
|
||||||
#include "../plugins/input/csv/csv_getline.hpp"
|
#include "../plugins/input/csv/csv_getline.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class test : public benchmark::test_case
|
class test : public benchmark::test_case
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string line_data_;
|
std::string line_data_;
|
||||||
test(mapnik::parameters const& params)
|
test(mapnik::parameters const& params)
|
||||||
: test_case(params),
|
: test_case(params)
|
||||||
line_data_("this is one line\nand this is a second line\nand a third line")
|
, line_data_("this is one line\nand this is a second line\nand a third line")
|
||||||
{
|
{
|
||||||
boost::optional<std::string> line_data = params.get<std::string>("line");
|
auto line_data = params.get<std::string>("line");
|
||||||
if (line_data)
|
if (line_data)
|
||||||
{
|
{
|
||||||
line_data_ = *line_data;
|
line_data_ = *line_data;
|
||||||
|
@ -25,14 +23,15 @@ public:
|
||||||
std::string csv_line;
|
std::string csv_line;
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
s << line_data_;
|
s << line_data_;
|
||||||
std::getline(s,csv_line,newline);
|
std::getline(s, csv_line, newline);
|
||||||
if (csv_line != first)
|
if (csv_line != first)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::clog << "Error: the parsed line (" << csv_line << ") should be a subset of the original line (" << line_data_ << ") (ensure you pass a line with a \\n)\n";
|
std::clog << "Error: the parsed line (" << csv_line << ") should be a subset of the original line ("
|
||||||
|
<< line_data_ << ") (ensure you pass a line with a \\n)\n";
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -42,24 +41,23 @@ public:
|
||||||
std::string csv_line;
|
std::string csv_line;
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
s << line_data_;
|
s << line_data_;
|
||||||
for (unsigned i=0;i<iterations_;++i)
|
for (unsigned i = 0; i < iterations_; ++i)
|
||||||
{
|
{
|
||||||
std::getline(s,csv_line,newline);
|
std::getline(s, csv_line, newline);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class test2 : public benchmark::test_case
|
class test2 : public benchmark::test_case
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string line_data_;
|
std::string line_data_;
|
||||||
test2(mapnik::parameters const& params)
|
test2(mapnik::parameters const& params)
|
||||||
: test_case(params),
|
: test_case(params)
|
||||||
line_data_("this is one line\nand this is a second line\nand a third line")
|
, line_data_("this is one line\nand this is a second line\nand a third line")
|
||||||
{
|
{
|
||||||
boost::optional<std::string> line_data = params.get<std::string>("line");
|
auto line_data = params.get<std::string>("line");
|
||||||
if (line_data)
|
if (line_data)
|
||||||
{
|
{
|
||||||
line_data_ = *line_data;
|
line_data_ = *line_data;
|
||||||
|
@ -74,14 +72,15 @@ public:
|
||||||
std::string csv_line;
|
std::string csv_line;
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
s << line_data_;
|
s << line_data_;
|
||||||
csv_utils::getline_csv(s,csv_line,newline,quote);
|
csv_utils::getline_csv(s, csv_line, newline, quote);
|
||||||
if (csv_line != first)
|
if (csv_line != first)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::clog << "Error: the parsed line (" << csv_line << ") should be a subset of the original line (" << line_data_ << ") (ensure you pass a line with a \\n)\n";
|
std::clog << "Error: the parsed line (" << csv_line << ") should be a subset of the original line ("
|
||||||
|
<< line_data_ << ") (ensure you pass a line with a \\n)\n";
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -92,9 +91,9 @@ public:
|
||||||
std::string csv_line;
|
std::string csv_line;
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
s << line_data_;
|
s << line_data_;
|
||||||
for (unsigned i=0;i<iterations_;++i)
|
for (unsigned i = 0; i < iterations_; ++i)
|
||||||
{
|
{
|
||||||
csv_utils::getline_csv(s,csv_line,newline,quote);
|
csv_utils::getline_csv(s, csv_line, newline, quote);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -102,18 +101,19 @@ public:
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
mapnik::setup();
|
||||||
int return_value = 0;
|
int return_value = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mapnik::parameters params;
|
mapnik::parameters params;
|
||||||
benchmark::handle_args(argc,argv,params);
|
benchmark::handle_args(argc, argv, params);
|
||||||
{
|
{
|
||||||
test test_runner(params);
|
test test_runner(params);
|
||||||
return_value = return_value | run(test_runner,"std::getline");
|
return_value = return_value | run(test_runner, "std::getline");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
test2 test_runner2(params);
|
test2 test_runner2(params);
|
||||||
return_value = return_value | run(test_runner2,"csv_utils::getline_csv");
|
return_value = return_value | run(test_runner2, "csv_utils::getline_csv");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception const& ex)
|
catch (std::exception const& ex)
|
40
benchmark/src/test_marker_cache.cpp
Normal file
40
benchmark/src/test_marker_cache.cpp
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#include "bench_framework.hpp"
|
||||||
|
#include <mapnik/marker_cache.hpp>
|
||||||
|
|
||||||
|
class test : public benchmark::test_case
|
||||||
|
{
|
||||||
|
std::vector<std::string> images_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
test(mapnik::parameters const& params)
|
||||||
|
: test_case(params)
|
||||||
|
, images_{"./test/data/images/dummy.jpg",
|
||||||
|
"./test/data/images/dummy.jpeg",
|
||||||
|
"./test/data/images/dummy.png",
|
||||||
|
"./test/data/images/dummy.tif",
|
||||||
|
"./test/data/images/dummy.tiff",
|
||||||
|
//"./test/data/images/landusepattern.jpeg", // will fail since it is a png
|
||||||
|
//"./test/data/images/xcode-CgBI.png", // will fail since its an invalid png
|
||||||
|
"./test/data/svg/octocat.svg",
|
||||||
|
"./test/data/svg/place-of-worship-24.svg",
|
||||||
|
"./test/data/svg/point_sm.svg",
|
||||||
|
"./test/data/svg/point.svg",
|
||||||
|
"./test/data/svg/airfield-12.svg"}
|
||||||
|
{}
|
||||||
|
bool validate() const { return true; }
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
unsigned count = 0;
|
||||||
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
for (auto filename : images_)
|
||||||
|
{
|
||||||
|
auto marker = mapnik::marker_cache::instance().find(filename, true);
|
||||||
|
}
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
return (count == iterations_);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BENCHMARK(test, "marker cache")
|
|
@ -14,40 +14,38 @@
|
||||||
|
|
||||||
class test : public benchmark::test_case
|
class test : public benchmark::test_case
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
test(mapnik::parameters const& params)
|
test(mapnik::parameters const& params)
|
||||||
: test_case(params) {}
|
: test_case(params)
|
||||||
|
{}
|
||||||
|
|
||||||
bool validate() const
|
bool validate() const { return true; }
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
mapnik::Map m(256,256,"+init=epsg:3857");
|
mapnik::Map m(256, 256, "epsg:3857");
|
||||||
|
|
||||||
mapnik::parameters params;
|
mapnik::parameters params;
|
||||||
params["type"]="memory";
|
params["type"] = "memory";
|
||||||
auto ds = std::make_shared<mapnik::memory_datasource>(params);
|
auto ds = std::make_shared<mapnik::memory_datasource>(params);
|
||||||
// add whitespace to trigger phony "reprojection"
|
// add whitespace to trigger phony "reprojection"
|
||||||
mapnik::layer lay("layer",m.srs() + " ");
|
mapnik::layer lay("layer", m.srs() + " ");
|
||||||
lay.set_datasource(ds);
|
lay.set_datasource(ds);
|
||||||
lay.add_style("style");
|
lay.add_style("style");
|
||||||
m.add_layer(lay);
|
m.add_layer(lay);
|
||||||
// dummy style to ensure that layer is processed
|
// dummy style to ensure that layer is processed
|
||||||
m.insert_style("style",mapnik::feature_type_style());
|
m.insert_style("style", mapnik::feature_type_style());
|
||||||
// dummy bbox, but "valid" because minx and miny are less
|
// dummy bbox, but "valid" because minx and miny are less
|
||||||
// with an invalid bbox then layer.visible() returns false
|
// with an invalid bbox then layer.visible() returns false
|
||||||
// and the initial rendering setup is not run
|
// and the initial rendering setup is not run
|
||||||
m.zoom_to_box(mapnik::box2d<double>(-1,-1,0,0));
|
m.zoom_to_box(mapnik::box2d<double>(-1, -1, 0, 0));
|
||||||
for (unsigned i=0;i<iterations_;++i)
|
for (unsigned i = 0; i < iterations_; ++i)
|
||||||
{
|
{
|
||||||
mapnik::image_rgba8 im(256,256);
|
mapnik::image_rgba8 im(256, 256);
|
||||||
mapnik::agg_renderer<mapnik::image_rgba8> ren(m,im);
|
mapnik::agg_renderer<mapnik::image_rgba8> ren(m, im);
|
||||||
ren.apply();
|
ren.apply();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
BENCHMARK(test,"rendering with reprojection")
|
BENCHMARK(test, "rendering with reprojection")
|
|
@ -9,23 +9,25 @@ class test_static : public benchmark::test_case
|
||||||
{
|
{
|
||||||
double step_;
|
double step_;
|
||||||
std::uint8_t start_;
|
std::uint8_t start_;
|
||||||
public:
|
|
||||||
|
public:
|
||||||
test_static(mapnik::parameters const& params)
|
test_static(mapnik::parameters const& params)
|
||||||
: test_case(params),
|
: test_case(params)
|
||||||
step_(STEP_NUM),
|
, step_(STEP_NUM)
|
||||||
start_(START_NUM) {}
|
, start_(START_NUM)
|
||||||
bool validate() const
|
{}
|
||||||
{
|
bool validate() const { return true; }
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
double value_ = 0.0;
|
double value_ = 0.0;
|
||||||
std::uint8_t x;
|
std::uint8_t x;
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
double c = static_cast<double>(start_) * value_;
|
double c = static_cast<double>(start_) * value_;
|
||||||
if (c >= 256.0) c = 255.0;
|
if (c >= 256.0)
|
||||||
if (c < 0.0) c = 0.0;
|
c = 255.0;
|
||||||
|
if (c < 0.0)
|
||||||
|
c = 0.0;
|
||||||
x = static_cast<std::uint8_t>(c);
|
x = static_cast<std::uint8_t>(c);
|
||||||
value_ += step_;
|
value_ += step_;
|
||||||
}
|
}
|
||||||
|
@ -33,35 +35,36 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
using boost::numeric::positive_overflow;
|
|
||||||
using boost::numeric::negative_overflow;
|
using boost::numeric::negative_overflow;
|
||||||
|
using boost::numeric::positive_overflow;
|
||||||
|
|
||||||
class test_numeric : public benchmark::test_case
|
class test_numeric : public benchmark::test_case
|
||||||
{
|
{
|
||||||
double step_;
|
double step_;
|
||||||
std::uint8_t start_;
|
std::uint8_t start_;
|
||||||
public:
|
|
||||||
|
public:
|
||||||
test_numeric(mapnik::parameters const& params)
|
test_numeric(mapnik::parameters const& params)
|
||||||
: test_case(params),
|
: test_case(params)
|
||||||
step_(STEP_NUM),
|
, step_(STEP_NUM)
|
||||||
start_(START_NUM) {}
|
, start_(START_NUM)
|
||||||
bool validate() const
|
{}
|
||||||
{
|
bool validate() const { return true; }
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
double value_ = 0.0;
|
double value_ = 0.0;
|
||||||
std::uint8_t x;
|
std::uint8_t x;
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
x = boost::numeric_cast<std::uint8_t>(start_ * value_);
|
x = boost::numeric_cast<std::uint8_t>(start_ * value_);
|
||||||
}
|
}
|
||||||
catch(negative_overflow&)
|
catch (negative_overflow&)
|
||||||
{
|
{
|
||||||
x = std::numeric_limits<std::uint8_t>::min();
|
x = std::numeric_limits<std::uint8_t>::min();
|
||||||
}
|
}
|
||||||
catch(positive_overflow&)
|
catch (positive_overflow&)
|
||||||
{
|
{
|
||||||
x = std::numeric_limits<std::uint8_t>::max();
|
x = std::numeric_limits<std::uint8_t>::max();
|
||||||
}
|
}
|
||||||
|
@ -73,8 +76,6 @@ public:
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
return benchmark::sequencer(argc, argv)
|
mapnik::setup();
|
||||||
.run<test_static>("static_cast")
|
return benchmark::sequencer(argc, argv).run<test_static>("static_cast").run<test_numeric>("numeric_cast").done();
|
||||||
.run<test_numeric>("numeric_cast")
|
|
||||||
.done();
|
|
||||||
}
|
}
|
|
@ -14,31 +14,36 @@ struct fake_path
|
||||||
cont_type::iterator itr_;
|
cont_type::iterator itr_;
|
||||||
|
|
||||||
fake_path(std::initializer_list<double> l)
|
fake_path(std::initializer_list<double> l)
|
||||||
: fake_path(l.begin(), l.size()) {
|
: fake_path(l.begin(), l.size())
|
||||||
}
|
{}
|
||||||
|
|
||||||
fake_path(std::vector<double> const &v)
|
fake_path(std::vector<double> const& v)
|
||||||
: fake_path(v.begin(), v.size()) {
|
: fake_path(v.begin(), v.size())
|
||||||
}
|
{}
|
||||||
|
|
||||||
template <typename Itr>
|
template<typename Itr>
|
||||||
fake_path(Itr itr, size_t sz) {
|
fake_path(Itr itr, size_t sz)
|
||||||
|
{
|
||||||
size_t num_coords = sz >> 1;
|
size_t num_coords = sz >> 1;
|
||||||
vertices_.reserve(num_coords);
|
vertices_.reserve(num_coords);
|
||||||
|
|
||||||
for (size_t i = 0; i < num_coords; ++i) {
|
for (size_t i = 0; i < num_coords; ++i)
|
||||||
|
{
|
||||||
double x = *itr++;
|
double x = *itr++;
|
||||||
double y = *itr++;
|
double y = *itr++;
|
||||||
unsigned cmd = (i == 0) ? mapnik::SEG_MOVETO : mapnik::SEG_LINETO;
|
unsigned cmd = (i == 0) ? mapnik::SEG_MOVETO : mapnik::SEG_LINETO;
|
||||||
vertices_.push_back(std::make_tuple(x, y, cmd));
|
vertices_.push_back(std::make_tuple(x, y, cmd));
|
||||||
if (i == num_coords - 1) cmd = mapnik::SEG_END;
|
if (i == num_coords - 1)
|
||||||
|
cmd = mapnik::SEG_END;
|
||||||
vertices_.push_back(std::make_tuple(x, y, cmd));
|
vertices_.push_back(std::make_tuple(x, y, cmd));
|
||||||
}
|
}
|
||||||
itr_ = vertices_.begin();
|
itr_ = vertices_.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned vertex(double *x, double *y) {
|
unsigned vertex(double* x, double* y)
|
||||||
if (itr_ == vertices_.end()) {
|
{
|
||||||
|
if (itr_ == vertices_.end())
|
||||||
|
{
|
||||||
return mapnik::SEG_END;
|
return mapnik::SEG_END;
|
||||||
}
|
}
|
||||||
*x = std::get<0>(*itr_);
|
*x = std::get<0>(*itr_);
|
||||||
|
@ -48,33 +53,30 @@ struct fake_path
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rewind(unsigned) {
|
void rewind(unsigned) { itr_ = vertices_.begin(); }
|
||||||
itr_ = vertices_.begin();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class test_offset : public benchmark::test_case
|
class test_offset : public benchmark::test_case
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
test_offset(mapnik::parameters const& params)
|
test_offset(mapnik::parameters const& params)
|
||||||
: test_case(params) {}
|
: test_case(params)
|
||||||
bool validate() const
|
{}
|
||||||
{
|
bool validate() const { return true; }
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
std::vector<double> path;
|
std::vector<double> path;
|
||||||
int mysize = 2500;
|
int mysize = 2500;
|
||||||
int x1 = 0;
|
int x1 = 0;
|
||||||
path.reserve(mysize*2);
|
path.reserve(mysize * 2);
|
||||||
for( int i = 0; i < mysize; i++ )
|
for (int i = 0; i < mysize; i++)
|
||||||
{
|
{
|
||||||
path.push_back( i );
|
path.push_back(i);
|
||||||
path.push_back( 0 );
|
path.push_back(0);
|
||||||
}
|
}
|
||||||
fake_path fpath(path);
|
fake_path fpath(path);
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
mapnik::offset_converter<fake_path> off_path(fpath);
|
mapnik::offset_converter<fake_path> off_path(fpath);
|
||||||
off_path.set_offset(10);
|
off_path.set_offset(10);
|
||||||
unsigned cmd;
|
unsigned cmd;
|
||||||
|
@ -88,15 +90,15 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
mapnik::setup();
|
||||||
mapnik::parameters params;
|
mapnik::parameters params;
|
||||||
benchmark::handle_args(argc,argv,params);
|
benchmark::handle_args(argc, argv, params);
|
||||||
int return_value = 0;
|
int return_value = 0;
|
||||||
{
|
{
|
||||||
test_offset test_runner(params);
|
test_offset test_runner(params);
|
||||||
return_value = run(test_runner,"offset_test");
|
return_value = run(test_runner, "offset_test");
|
||||||
}
|
}
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
|
@ -4,23 +4,23 @@
|
||||||
class test : public benchmark::test_case
|
class test : public benchmark::test_case
|
||||||
{
|
{
|
||||||
mapnik::image_rgba8 im_;
|
mapnik::image_rgba8 im_;
|
||||||
public:
|
|
||||||
|
public:
|
||||||
test(mapnik::parameters const& params)
|
test(mapnik::parameters const& params)
|
||||||
: test_case(params),
|
: test_case(params)
|
||||||
im_(256,256) {}
|
, im_(256, 256)
|
||||||
bool validate() const
|
{}
|
||||||
{
|
bool validate() const { return true; }
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
std::string out;
|
std::string out;
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
out.clear();
|
out.clear();
|
||||||
out = mapnik::save_to_string(im_,"png8:m=h:z=1");
|
out = mapnik::save_to_string(im_, "png8:m=h:z=1");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
BENCHMARK(test,"encoding blank png")
|
BENCHMARK(test, "encoding blank png")
|
|
@ -1,37 +1,41 @@
|
||||||
#include "bench_framework.hpp"
|
#include "bench_framework.hpp"
|
||||||
#include "compare_images.hpp"
|
#include "compare_images.hpp"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class test : public benchmark::test_case
|
class test : public benchmark::test_case
|
||||||
{
|
{
|
||||||
std::shared_ptr<mapnik::image_rgba8> im_;
|
std::shared_ptr<mapnik::image_rgba8> im_;
|
||||||
public:
|
|
||||||
|
public:
|
||||||
test(mapnik::parameters const& params)
|
test(mapnik::parameters const& params)
|
||||||
: test_case(params) {
|
: test_case(params)
|
||||||
|
{
|
||||||
std::string filename("./benchmark/data/multicolor.png");
|
std::string filename("./benchmark/data/multicolor.png");
|
||||||
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(filename,"png"));
|
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(filename, "png"));
|
||||||
if (!reader.get())
|
if (!reader.get())
|
||||||
{
|
{
|
||||||
throw mapnik::image_reader_exception("Failed to load: " + filename);
|
throw mapnik::image_reader_exception("Failed to load: " + filename);
|
||||||
}
|
}
|
||||||
im_ = std::make_shared<mapnik::image_rgba8>(reader->width(),reader->height());
|
im_ = std::make_shared<mapnik::image_rgba8>(reader->width(), reader->height());
|
||||||
reader->read(0,0,*im_);
|
reader->read(0, 0, *im_);
|
||||||
}
|
}
|
||||||
bool validate() const
|
bool validate() const
|
||||||
{
|
{
|
||||||
std::string expected("./benchmark/data/multicolor-hextree-expected.png");
|
std::string expected("./benchmark/data/multicolor-hextree-expected.png");
|
||||||
std::string actual("./benchmark/data/multicolor-hextree-actual.png");
|
std::string actual("./benchmark/data/multicolor-hextree-actual.png");
|
||||||
mapnik::save_to_file(*im_,actual, "png8:m=h:z=1");
|
mapnik::save_to_file(*im_, actual, "png8:m=h:z=1");
|
||||||
return benchmark::compare_images(actual,expected);
|
return benchmark::compare_images(actual, expected);
|
||||||
}
|
}
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
std::string out;
|
std::string out;
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
out.clear();
|
out.clear();
|
||||||
out = mapnik::save_to_string(*im_,"png8:m=h:z=1");
|
out = mapnik::save_to_string(*im_, "png8:m=h:z=1");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
BENCHMARK(test,"encoding multicolor png")
|
BENCHMARK(test, "encoding multicolor png")
|
|
@ -39,30 +39,31 @@ void render(mapnik::geometry::multi_polygon<double> const& geom,
|
||||||
mapnik::box2d<double> const& extent,
|
mapnik::box2d<double> const& extent,
|
||||||
std::string const& name)
|
std::string const& name)
|
||||||
{
|
{
|
||||||
using path_type = mapnik::transform_path_adapter<mapnik::view_transform,mapnik::geometry::polygon_vertex_adapter<double>>;
|
using path_type =
|
||||||
|
mapnik::transform_path_adapter<mapnik::view_transform, mapnik::geometry::polygon_vertex_adapter<double>>;
|
||||||
using ren_base = agg::renderer_base<agg::pixfmt_rgba32_plain>;
|
using ren_base = agg::renderer_base<agg::pixfmt_rgba32_plain>;
|
||||||
using renderer = agg::renderer_scanline_aa_solid<ren_base>;
|
using renderer = agg::renderer_scanline_aa_solid<ren_base>;
|
||||||
mapnik::image_rgba8 im(256,256);
|
mapnik::image_rgba8 im(256, 256);
|
||||||
mapnik::fill(im, mapnik::color("white"));
|
mapnik::fill(im, mapnik::color("white"));
|
||||||
mapnik::box2d<double> padded_extent(155,134,665,466);//extent;
|
mapnik::box2d<double> padded_extent(155, 134, 665, 466); // extent;
|
||||||
padded_extent.pad(10);
|
padded_extent.pad(10);
|
||||||
mapnik::view_transform tr(im.width(),im.height(),padded_extent,0,0);
|
mapnik::view_transform tr(im.width(), im.height(), padded_extent, 0, 0);
|
||||||
agg::rendering_buffer buf(im.bytes(),im.width(),im.height(), im.row_size());
|
agg::rendering_buffer buf(im.bytes(), im.width(), im.height(), im.row_size());
|
||||||
agg::pixfmt_rgba32_plain pixf(buf);
|
agg::pixfmt_rgba32_plain pixf(buf);
|
||||||
ren_base renb(pixf);
|
ren_base renb(pixf);
|
||||||
renderer ren(renb);
|
renderer ren(renb);
|
||||||
mapnik::proj_transform prj_trans(mapnik::projection("+init=epsg:4326"),mapnik::projection("+init=epsg:4326"));
|
mapnik::proj_transform prj_trans(mapnik::projection("epsg:4326"), mapnik::projection("epsg:4326"));
|
||||||
ren.color(agg::rgba8(127,127,127,255));
|
ren.color(agg::rgba8(127, 127, 127, 255));
|
||||||
agg::rasterizer_scanline_aa<> ras;
|
agg::rasterizer_scanline_aa<> ras;
|
||||||
for (auto const& poly : geom)
|
for (auto const& poly : geom)
|
||||||
{
|
{
|
||||||
mapnik::geometry::polygon_vertex_adapter<double> va(poly);
|
mapnik::geometry::polygon_vertex_adapter<double> va(poly);
|
||||||
path_type path(tr,va,prj_trans);
|
path_type path(tr, va, prj_trans);
|
||||||
ras.add_path(path);
|
ras.add_path(path);
|
||||||
}
|
}
|
||||||
agg::scanline_u8 sl;
|
agg::scanline_u8 sl;
|
||||||
agg::render_scanlines(ras, sl, ren);
|
agg::render_scanlines(ras, sl, ren);
|
||||||
mapnik::save_to_file(im,name);
|
mapnik::save_to_file(im, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
class test1 : public benchmark::test_case
|
class test1 : public benchmark::test_case
|
||||||
|
@ -70,15 +71,15 @@ class test1 : public benchmark::test_case
|
||||||
std::string wkt_in_;
|
std::string wkt_in_;
|
||||||
mapnik::box2d<double> extent_;
|
mapnik::box2d<double> extent_;
|
||||||
std::string expected_;
|
std::string expected_;
|
||||||
public:
|
|
||||||
|
public:
|
||||||
using conv_clip = agg::conv_clip_polygon<mapnik::geometry::polygon_vertex_adapter<double>>;
|
using conv_clip = agg::conv_clip_polygon<mapnik::geometry::polygon_vertex_adapter<double>>;
|
||||||
test1(mapnik::parameters const& params,
|
test1(mapnik::parameters const& params, std::string const& wkt_in, mapnik::box2d<double> const& extent)
|
||||||
std::string const& wkt_in,
|
: test_case(params)
|
||||||
mapnik::box2d<double> const& extent)
|
, wkt_in_(wkt_in)
|
||||||
: test_case(params),
|
, extent_(extent)
|
||||||
wkt_in_(wkt_in),
|
, expected_("./benchmark/data/polygon_clipping_agg")
|
||||||
extent_(extent),
|
{}
|
||||||
expected_("./benchmark/data/polygon_clipping_agg") {}
|
|
||||||
bool validate() const
|
bool validate() const
|
||||||
{
|
{
|
||||||
mapnik::geometry::geometry<double> geom;
|
mapnik::geometry::geometry<double> geom;
|
||||||
|
@ -99,14 +100,8 @@ public:
|
||||||
mapnik::geometry::polygon<double> const& poly = mapnik::util::get<mapnik::geometry::polygon<double>>(geom);
|
mapnik::geometry::polygon<double> const& poly = mapnik::util::get<mapnik::geometry::polygon<double>>(geom);
|
||||||
mapnik::geometry::polygon_vertex_adapter<double> va(poly);
|
mapnik::geometry::polygon_vertex_adapter<double> va(poly);
|
||||||
|
|
||||||
|
|
||||||
conv_clip clipped(va);
|
conv_clip clipped(va);
|
||||||
clipped.clip_box(
|
clipped.clip_box(extent_.minx(), extent_.miny(), extent_.maxx(), extent_.maxy());
|
||||||
extent_.minx(),
|
|
||||||
extent_.miny(),
|
|
||||||
extent_.maxx(),
|
|
||||||
extent_.maxy());
|
|
||||||
|
|
||||||
|
|
||||||
clipped.rewind(0);
|
clipped.rewind(0);
|
||||||
mapnik::geometry::polygon<double> poly2;
|
mapnik::geometry::polygon<double> poly2;
|
||||||
|
@ -118,7 +113,8 @@ public:
|
||||||
{
|
{
|
||||||
if (cmd == mapnik::SEG_MOVETO)
|
if (cmd == mapnik::SEG_MOVETO)
|
||||||
{
|
{
|
||||||
x0 = x; y0 = y;
|
x0 = x;
|
||||||
|
y0 = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd == mapnik::SEG_CLOSE)
|
if (cmd == mapnik::SEG_CLOSE)
|
||||||
|
@ -126,7 +122,7 @@ public:
|
||||||
ring.emplace_back(x0, y0);
|
ring.emplace_back(x0, y0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ring.emplace_back(x,y);
|
ring.emplace_back(x, y);
|
||||||
}
|
}
|
||||||
poly2.push_back(std::move(ring));
|
poly2.push_back(std::move(ring));
|
||||||
// interior rings
|
// interior rings
|
||||||
|
@ -135,30 +131,31 @@ public:
|
||||||
{
|
{
|
||||||
if (cmd == mapnik::SEG_MOVETO)
|
if (cmd == mapnik::SEG_MOVETO)
|
||||||
{
|
{
|
||||||
x0 = x; y0 = y;
|
x0 = x;
|
||||||
|
y0 = y;
|
||||||
}
|
}
|
||||||
else if (cmd == mapnik::SEG_CLOSE)
|
else if (cmd == mapnik::SEG_CLOSE)
|
||||||
{
|
{
|
||||||
ring.emplace_back(x0,y0);
|
ring.emplace_back(x0, y0);
|
||||||
poly2.push_back(std::move(ring));
|
poly2.push_back(std::move(ring));
|
||||||
ring.clear();
|
ring.clear();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ring.emplace_back(x,y);
|
ring.emplace_back(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string expect = expected_+".png";
|
std::string expect = expected_ + ".png";
|
||||||
std::string actual = expected_+"_actual.png";
|
std::string actual = expected_ + "_actual.png";
|
||||||
mapnik::geometry::multi_polygon<double> mp;
|
mapnik::geometry::multi_polygon<double> mp;
|
||||||
mp.emplace_back(poly2);
|
mp.emplace_back(poly2);
|
||||||
auto env = mapnik::geometry::envelope(mp);
|
auto env = mapnik::geometry::envelope(mp);
|
||||||
if (!mapnik::util::exists(expect) || (std::getenv("UPDATE") != nullptr))
|
if (!mapnik::util::exists(expect) || (std::getenv("UPDATE") != nullptr))
|
||||||
{
|
{
|
||||||
std::clog << "generating expected image: " << expect << "\n";
|
std::clog << "generating expected image: " << expect << "\n";
|
||||||
render(mp,env,expect);
|
render(mp, env, expect);
|
||||||
}
|
}
|
||||||
render(mp,env,actual);
|
render(mp, env, actual);
|
||||||
return benchmark::compare_images(actual,expect);
|
return benchmark::compare_images(actual, expect);
|
||||||
}
|
}
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
|
@ -178,29 +175,28 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
for (unsigned i=0;i<iterations_;++i)
|
for (unsigned i = 0; i < iterations_; ++i)
|
||||||
{
|
{
|
||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
mapnik::geometry::polygon<double> const& poly = mapnik::util::get<mapnik::geometry::polygon<double>>(geom);
|
mapnik::geometry::polygon<double> const& poly = mapnik::util::get<mapnik::geometry::polygon<double>>(geom);
|
||||||
mapnik::geometry::polygon_vertex_adapter<double> va(poly);
|
mapnik::geometry::polygon_vertex_adapter<double> va(poly);
|
||||||
conv_clip clipped(va);
|
conv_clip clipped(va);
|
||||||
clipped.clip_box(
|
clipped.clip_box(extent_.minx(), extent_.miny(), extent_.maxx(), extent_.maxy());
|
||||||
extent_.minx(),
|
|
||||||
extent_.miny(),
|
|
||||||
extent_.maxx(),
|
|
||||||
extent_.maxy());
|
|
||||||
unsigned cmd;
|
unsigned cmd;
|
||||||
double x,y;
|
double x, y;
|
||||||
// NOTE: this rewind is critical otherwise
|
// NOTE: this rewind is critical otherwise
|
||||||
// agg_conv_adapter_vpgen will give garbage
|
// agg_conv_adapter_vpgen will give garbage
|
||||||
// values for the first vertex
|
// values for the first vertex
|
||||||
clipped.rewind(0);
|
clipped.rewind(0);
|
||||||
while ((cmd = clipped.vertex(&x, &y)) != mapnik::SEG_END) {
|
while ((cmd = clipped.vertex(&x, &y)) != mapnik::SEG_END)
|
||||||
|
{
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
unsigned expected_count = 30;
|
unsigned expected_count = 30;
|
||||||
if (count != expected_count) {
|
if (count != expected_count)
|
||||||
std::clog << "test1: clipping failed: processed " << count << " verticies but expected " << expected_count << "\n";
|
{
|
||||||
|
std::clog << "test1: clipping failed: processed " << count << " verticies but expected "
|
||||||
|
<< expected_count << "\n";
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,20 +204,19 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class test3 : public benchmark::test_case
|
class test3 : public benchmark::test_case
|
||||||
{
|
{
|
||||||
std::string wkt_in_;
|
std::string wkt_in_;
|
||||||
mapnik::box2d<double> extent_;
|
mapnik::box2d<double> extent_;
|
||||||
std::string expected_;
|
std::string expected_;
|
||||||
public:
|
|
||||||
test3(mapnik::parameters const& params,
|
public:
|
||||||
std::string const& wkt_in,
|
test3(mapnik::parameters const& params, std::string const& wkt_in, mapnik::box2d<double> const& extent)
|
||||||
mapnik::box2d<double> const& extent)
|
: test_case(params)
|
||||||
: test_case(params),
|
, wkt_in_(wkt_in)
|
||||||
wkt_in_(wkt_in),
|
, extent_(extent)
|
||||||
extent_(extent),
|
, expected_("./benchmark/data/polygon_clipping_boost")
|
||||||
expected_("./benchmark/data/polygon_clipping_boost") {}
|
{}
|
||||||
bool validate() const
|
bool validate() const
|
||||||
{
|
{
|
||||||
mapnik::geometry::geometry<double> geom;
|
mapnik::geometry::geometry<double> geom;
|
||||||
|
@ -234,12 +229,12 @@ public:
|
||||||
std::clog << "empty geom!\n";
|
std::clog << "empty geom!\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!geom.is<mapnik::geometry::polygon<double> >())
|
if (!geom.is<mapnik::geometry::polygon<double>>())
|
||||||
{
|
{
|
||||||
std::clog << "not a polygon!\n";
|
std::clog << "not a polygon!\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mapnik::geometry::polygon<double> & poly = mapnik::util::get<mapnik::geometry::polygon<double> >(geom);
|
mapnik::geometry::polygon<double>& poly = mapnik::util::get<mapnik::geometry::polygon<double>>(geom);
|
||||||
mapnik::geometry::correct(poly);
|
mapnik::geometry::correct(poly);
|
||||||
|
|
||||||
mapnik::geometry::linear_ring<double> bbox;
|
mapnik::geometry::linear_ring<double> bbox;
|
||||||
|
@ -249,15 +244,15 @@ public:
|
||||||
bbox.emplace_back(extent_.maxx(), extent_.miny());
|
bbox.emplace_back(extent_.maxx(), extent_.miny());
|
||||||
bbox.emplace_back(extent_.minx(), extent_.miny());
|
bbox.emplace_back(extent_.minx(), extent_.miny());
|
||||||
|
|
||||||
std::deque<mapnik::geometry::polygon<double> > result;
|
std::deque<mapnik::geometry::polygon<double>> result;
|
||||||
boost::geometry::intersection(bbox, poly, result);
|
boost::geometry::intersection(bbox, poly, result);
|
||||||
|
|
||||||
std::string expect = expected_+".png";
|
std::string expect = expected_ + ".png";
|
||||||
std::string actual = expected_+"_actual.png";
|
std::string actual = expected_ + "_actual.png";
|
||||||
mapnik::geometry::multi_polygon<double> mp;
|
mapnik::geometry::multi_polygon<double> mp;
|
||||||
for (auto const& _geom: result)
|
for (auto const& _geom : result)
|
||||||
{
|
{
|
||||||
//std::clog << boost::geometry::dsv(geom) << "\n";
|
// std::clog << boost::geometry::dsv(geom) << "\n";
|
||||||
mp.emplace_back(_geom);
|
mp.emplace_back(_geom);
|
||||||
}
|
}
|
||||||
mapnik::geometry::geometry<double> geom2(mp);
|
mapnik::geometry::geometry<double> geom2(mp);
|
||||||
|
@ -265,10 +260,10 @@ public:
|
||||||
if (!mapnik::util::exists(expect) || (std::getenv("UPDATE") != nullptr))
|
if (!mapnik::util::exists(expect) || (std::getenv("UPDATE") != nullptr))
|
||||||
{
|
{
|
||||||
std::clog << "generating expected image: " << expect << "\n";
|
std::clog << "generating expected image: " << expect << "\n";
|
||||||
render(mp,env,expect);
|
render(mp, env, expect);
|
||||||
}
|
}
|
||||||
render(mp,env,actual);
|
render(mp, env, actual);
|
||||||
return benchmark::compare_images(actual,expect);
|
return benchmark::compare_images(actual, expect);
|
||||||
}
|
}
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
|
@ -282,12 +277,12 @@ public:
|
||||||
std::clog << "empty geom!\n";
|
std::clog << "empty geom!\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!geom.is<mapnik::geometry::polygon<double> >())
|
if (!geom.is<mapnik::geometry::polygon<double>>())
|
||||||
{
|
{
|
||||||
std::clog << "not a polygon!\n";
|
std::clog << "not a polygon!\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mapnik::geometry::polygon<double> & poly = mapnik::util::get<mapnik::geometry::polygon<double> >(geom);
|
mapnik::geometry::polygon<double>& poly = mapnik::util::get<mapnik::geometry::polygon<double>>(geom);
|
||||||
mapnik::geometry::correct(poly);
|
mapnik::geometry::correct(poly);
|
||||||
|
|
||||||
mapnik::geometry::linear_ring<double> bbox;
|
mapnik::geometry::linear_ring<double> bbox;
|
||||||
|
@ -298,22 +293,25 @@ public:
|
||||||
bbox.emplace_back(extent_.minx(), extent_.miny());
|
bbox.emplace_back(extent_.minx(), extent_.miny());
|
||||||
|
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
for (unsigned i=0;i<iterations_;++i)
|
for (unsigned i = 0; i < iterations_; ++i)
|
||||||
{
|
{
|
||||||
std::deque<mapnik::geometry::polygon<double> > result;
|
std::deque<mapnik::geometry::polygon<double>> result;
|
||||||
boost::geometry::intersection(bbox, poly, result);
|
boost::geometry::intersection(bbox, poly, result);
|
||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
for (auto const& _geom : result)
|
for (auto const& _geom : result)
|
||||||
{
|
{
|
||||||
mapnik::geometry::polygon_vertex_adapter<double> va(_geom);
|
mapnik::geometry::polygon_vertex_adapter<double> va(_geom);
|
||||||
unsigned cmd;
|
unsigned cmd;
|
||||||
double x,y;
|
double x, y;
|
||||||
while ((cmd = va.vertex(&x, &y)) != mapnik::SEG_END) {
|
while ((cmd = va.vertex(&x, &y)) != mapnik::SEG_END)
|
||||||
|
{
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
unsigned expected_count = 29;
|
unsigned expected_count = 29;
|
||||||
if (count != expected_count) {
|
if (count != expected_count)
|
||||||
std::clog << "test3: clipping failed: processed " << count << " verticies but expected " << expected_count << "\n";
|
{
|
||||||
|
std::clog << "test3: clipping failed: processed " << count << " verticies but expected "
|
||||||
|
<< expected_count << "\n";
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -500,8 +498,8 @@ public:
|
||||||
}
|
}
|
||||||
unsigned expected_count = 29;
|
unsigned expected_count = 29;
|
||||||
if (count != expected_count) {
|
if (count != expected_count) {
|
||||||
std::clog << "test3: clipping failed: processed " << count << " verticies but expected " << expected_count << "\n";
|
std::clog << "test3: clipping failed: processed " << count << " verticies but expected " <<
|
||||||
valid = false;
|
expected_count << "\n"; valid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -512,14 +510,18 @@ public:
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
mapnik::setup();
|
||||||
mapnik::parameters params;
|
mapnik::parameters params;
|
||||||
benchmark::handle_args(argc,argv,params);
|
benchmark::handle_args(argc, argv, params);
|
||||||
|
|
||||||
// polygon/rect clipping
|
// polygon/rect clipping
|
||||||
// IN : POLYGON ((155 203, 233 454, 315 340, 421 446, 463 324, 559 466, 665 253, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 155 203),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249 334, 229 191, 313 190))
|
// IN : POLYGON ((155 203, 233 454, 315 340, 421 446, 463 324, 559 466, 665 253, 528 178, 394 229, 329 138, 212 134,
|
||||||
// RECT : POLYGON ((181 106, 181 470, 631 470, 631 106, 181 106))
|
// 183 228, 200 264, 155 203),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343
|
||||||
// OUT (expected)
|
// 287, 249 334, 229 191, 313 190)) RECT : POLYGON ((181 106, 181 470, 631 470, 631 106, 181 106)) OUT (expected)
|
||||||
// POLYGON ((181 286.6666666666667, 233 454, 315 340, 421 446, 463 324, 559 466, 631 321.3207547169811, 631 234.38686131386862, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 181 238.24444444444444, 181 286.6666666666667),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249 334, 229 191, 313 190))
|
// POLYGON ((181 286.6666666666667, 233 454, 315 340, 421 446, 463 324, 559 466, 631 321.3207547169811, 631
|
||||||
|
// 234.38686131386862, 528 178, 394 229, 329 138, 212 134, 183 228, 200 264, 181 238.24444444444444, 181
|
||||||
|
// 286.6666666666667),(313 190, 440 256, 470 248, 510 305, 533 237, 613 263, 553 397, 455 262, 405 378, 343 287, 249
|
||||||
|
// 334, 229 191, 313 190))
|
||||||
#if 0
|
#if 0
|
||||||
mapnik::box2d<double> clipping_box(181,106,631,470);
|
mapnik::box2d<double> clipping_box(181,106,631,470);
|
||||||
std::string filename_("./benchmark/data/polygon.wkt");
|
std::string filename_("./benchmark/data/polygon.wkt");
|
||||||
|
@ -544,5 +546,5 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
#endif
|
#endif
|
||||||
return 0;// return_value;
|
return 0; // return_value;
|
||||||
}
|
}
|
59
benchmark/src/test_polygon_clipping_rendering.cpp
Normal file
59
benchmark/src/test_polygon_clipping_rendering.cpp
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
#include "bench_framework.hpp"
|
||||||
|
#include <mapnik/map.hpp>
|
||||||
|
#include <mapnik/load_map.hpp>
|
||||||
|
#include <mapnik/agg_renderer.hpp>
|
||||||
|
#include <mapnik/datasource_cache.hpp>
|
||||||
|
|
||||||
|
class test : public benchmark::test_case
|
||||||
|
{
|
||||||
|
std::string xml_;
|
||||||
|
mapnik::box2d<double> extent_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
test(mapnik::parameters const& params, std::string const& xml, mapnik::box2d<double> const& extent)
|
||||||
|
: test_case(params)
|
||||||
|
, xml_(xml)
|
||||||
|
, extent_(extent)
|
||||||
|
{}
|
||||||
|
bool validate() const
|
||||||
|
{
|
||||||
|
mapnik::Map m(256, 256);
|
||||||
|
mapnik::load_map(m, xml_);
|
||||||
|
m.zoom_to_box(extent_);
|
||||||
|
mapnik::image_rgba8 im(m.width(), m.height());
|
||||||
|
mapnik::agg_renderer<mapnik::image_rgba8> ren(m, im);
|
||||||
|
ren.apply();
|
||||||
|
// mapnik::save_to_file(im.data(),"test.png");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
mapnik::Map m(256, 256);
|
||||||
|
mapnik::load_map(m, xml_);
|
||||||
|
m.zoom_to_box(extent_);
|
||||||
|
for (unsigned i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
mapnik::image_rgba8 im(m.width(), m.height());
|
||||||
|
mapnik::agg_renderer<mapnik::image_rgba8> ren(m, im);
|
||||||
|
ren.apply();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
mapnik::setup();
|
||||||
|
mapnik::parameters params;
|
||||||
|
benchmark::handle_args(argc, argv, params);
|
||||||
|
mapnik::datasource_cache::instance().register_datasources("./plugins/input/");
|
||||||
|
mapnik::box2d<double> z1(-20037508.3428, -8317435.0606, 20037508.3428, 18399242.7298);
|
||||||
|
// bbox for 16/10491/22911.png
|
||||||
|
mapnik::box2d<double> z16(-13622912.929097254, 6026906.8062295765, -13621689.93664469, 6028129.79868214);
|
||||||
|
return benchmark::sequencer(argc, argv)
|
||||||
|
.run<test>("polygon clip render z1", "benchmark/data/polygon_rendering_clip.xml", z1)
|
||||||
|
.run<test>("polygon noclip render z1", "benchmark/data/polygon_rendering_no_clip.xml", z1)
|
||||||
|
.run<test>("polygon clip render z16", "benchmark/data/polygon_rendering_clip.xml", z16)
|
||||||
|
.run<test>("polygon noclip render z16", "benchmark/data/polygon_rendering_no_clip.xml", z16)
|
||||||
|
.done();
|
||||||
|
}
|
77
benchmark/src/test_proj_transform1.cpp
Normal file
77
benchmark/src/test_proj_transform1.cpp
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
#include "bench_framework.hpp"
|
||||||
|
#include <mapnik/geometry/box2d.hpp>
|
||||||
|
#include <mapnik/projection.hpp>
|
||||||
|
#include <mapnik/proj_transform.hpp>
|
||||||
|
|
||||||
|
class test : public benchmark::test_case
|
||||||
|
{
|
||||||
|
std::string src_;
|
||||||
|
std::string dest_;
|
||||||
|
mapnik::box2d<double> from_;
|
||||||
|
mapnik::box2d<double> to_;
|
||||||
|
bool defer_proj_init_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
test(mapnik::parameters const& params,
|
||||||
|
std::string const& src,
|
||||||
|
std::string const& dest,
|
||||||
|
mapnik::box2d<double> const& from,
|
||||||
|
mapnik::box2d<double> const& to,
|
||||||
|
bool defer_proj)
|
||||||
|
: test_case(params)
|
||||||
|
, src_(src)
|
||||||
|
, dest_(dest)
|
||||||
|
, from_(from)
|
||||||
|
, to_(to)
|
||||||
|
, defer_proj_init_(defer_proj)
|
||||||
|
{}
|
||||||
|
bool validate() const
|
||||||
|
{
|
||||||
|
mapnik::projection src(src_, defer_proj_init_);
|
||||||
|
mapnik::projection dest(dest_, defer_proj_init_);
|
||||||
|
mapnik::proj_transform tr(src, dest);
|
||||||
|
mapnik::box2d<double> bbox = from_;
|
||||||
|
if (!tr.forward(bbox))
|
||||||
|
return false;
|
||||||
|
return ((std::fabs(bbox.minx() - to_.minx()) < .5) && (std::fabs(bbox.maxx() - to_.maxx()) < .5) &&
|
||||||
|
(std::fabs(bbox.miny() - to_.miny()) < .5) && (std::fabs(bbox.maxy() - to_.maxy()) < .5));
|
||||||
|
}
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
mapnik::projection src(src_, defer_proj_init_);
|
||||||
|
mapnik::projection dest(dest_, defer_proj_init_);
|
||||||
|
mapnik::proj_transform tr(src, dest);
|
||||||
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
for (int j = -180; j < 180; j = j + 5)
|
||||||
|
{
|
||||||
|
for (int k = -85; k < 85; k = k + 5)
|
||||||
|
{
|
||||||
|
mapnik::box2d<double> box(j, k, j, k);
|
||||||
|
if (!tr.forward(box))
|
||||||
|
throw std::runtime_error("could not transform coords");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// echo -180 -60 | cs2cs -f "%.10f" epsg:4326 +to epsg:3857
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
mapnik::setup();
|
||||||
|
mapnik::box2d<double> from(-180, -80, 180, 80);
|
||||||
|
mapnik::box2d<double> to(-20037508.3427892476, -15538711.0963092316, 20037508.3427892476, 15538711.0963092316);
|
||||||
|
std::string from_str("epsg:4326");
|
||||||
|
std::string to_str("epsg:3857");
|
||||||
|
std::string from_str2("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");
|
||||||
|
std::string to_str2("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m "
|
||||||
|
"+nadgrids=@null +wktext +no_defs +over");
|
||||||
|
return benchmark::sequencer(argc, argv)
|
||||||
|
.run<test>("lonlat->merc epsg (internal)", from_str, to_str, from, to, true)
|
||||||
|
.run<test>("lonlat->merc literal (libproj)", from_str2, to_str2, from, to, true)
|
||||||
|
.run<test>("merc->lonlat epsg (internal)", to_str, from_str, to, from, true)
|
||||||
|
.run<test>("merc->lonlat literal (libproj)", to_str2, from_str2, to, from, true)
|
||||||
|
.done();
|
||||||
|
}
|
|
@ -6,43 +6,41 @@ using quad_tree_type = mapnik::quad_tree<std::size_t>;
|
||||||
|
|
||||||
class test : public benchmark::test_case
|
class test : public benchmark::test_case
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
test(mapnik::parameters const& params)
|
test(mapnik::parameters const& params)
|
||||||
: test_case(params) {}
|
: test_case(params)
|
||||||
|
{}
|
||||||
|
|
||||||
bool validate() const
|
bool validate() const { return true; }
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
std::random_device rd;
|
std::random_device rd;
|
||||||
std::default_random_engine engine(rd());
|
std::default_random_engine engine(rd());
|
||||||
std::uniform_int_distribution<int> uniform_dist(0, 2048);
|
std::uniform_int_distribution<int> uniform_dist(0, 2048);
|
||||||
quad_tree_type tree(mapnik::box2d<double>(0,0,2048,2048));
|
quad_tree_type tree(mapnik::box2d<double>(0, 0, 2048, 2048));
|
||||||
//populate
|
// populate
|
||||||
for (size_t i = 0; i < iterations_; ++i)
|
for (size_t i = 0; i < iterations_; ++i)
|
||||||
{
|
{
|
||||||
int cx = uniform_dist(engine);
|
int cx = uniform_dist(engine);
|
||||||
int cy = uniform_dist(engine);
|
int cy = uniform_dist(engine);
|
||||||
int sx = 0.2 * uniform_dist(engine);
|
int sx = 0.2 * uniform_dist(engine);
|
||||||
int sy = 0.2 * uniform_dist(engine);
|
int sy = 0.2 * uniform_dist(engine);
|
||||||
mapnik::box2d<double> box(cx - sx,cy - sy, cx + sx, cy + sy);
|
mapnik::box2d<double> box(cx - sx, cy - sy, cx + sx, cy + sy);
|
||||||
tree.insert(i, box);
|
tree.insert(i, box);
|
||||||
}
|
}
|
||||||
// bounding box query
|
// bounding box query
|
||||||
std::size_t count=0;
|
std::size_t count = 0;
|
||||||
for (size_t i = 0; i < iterations_; ++i)
|
for (size_t i = 0; i < iterations_; ++i)
|
||||||
{
|
{
|
||||||
int cx = uniform_dist(engine);
|
int cx = uniform_dist(engine);
|
||||||
int cy = uniform_dist(engine);
|
int cy = uniform_dist(engine);
|
||||||
int sx = 0.4 * uniform_dist(engine);
|
int sx = 0.4 * uniform_dist(engine);
|
||||||
int sy = 0.4 * uniform_dist(engine);
|
int sy = 0.4 * uniform_dist(engine);
|
||||||
mapnik::box2d<double> box(cx - sx,cy - sy, cx + sx, cy + sy);
|
mapnik::box2d<double> box(cx - sx, cy - sy, cx + sx, cy + sy);
|
||||||
auto itr = tree.query_in_box(box);
|
auto itr = tree.query_in_box(box);
|
||||||
auto end = tree.query_end();
|
auto end = tree.query_end();
|
||||||
for ( ;itr != end; ++itr)
|
for (; itr != end; ++itr)
|
||||||
{
|
{
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
@ -51,4 +49,4 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
BENCHMARK(test,"quad_tree creation")
|
BENCHMARK(test, "quad_tree creation")
|
|
@ -15,24 +15,25 @@ class test : public benchmark::test_case
|
||||||
mapnik::value_integer height_;
|
mapnik::value_integer height_;
|
||||||
double scale_factor_;
|
double scale_factor_;
|
||||||
std::string preview_;
|
std::string preview_;
|
||||||
public:
|
|
||||||
|
public:
|
||||||
test(mapnik::parameters const& params)
|
test(mapnik::parameters const& params)
|
||||||
: test_case(params),
|
: test_case(params)
|
||||||
xml_(),
|
, xml_()
|
||||||
extent_(),
|
, extent_()
|
||||||
width_(*params.get<mapnik::value_integer>("width",256)),
|
, width_(*params.get<mapnik::value_integer>("width", 256))
|
||||||
height_(*params.get<mapnik::value_integer>("height",256)),
|
, height_(*params.get<mapnik::value_integer>("height", 256))
|
||||||
scale_factor_(*params.get<mapnik::value_double>("scale_factor",1.0)),
|
, scale_factor_(*params.get<mapnik::value_double>("scale_factor", 1.0))
|
||||||
preview_(*params.get<std::string>("preview",""))
|
, preview_(*params.get<std::string>("preview", ""))
|
||||||
{
|
{
|
||||||
boost::optional<std::string> map = params.get<std::string>("map");
|
const auto map = params.get<std::string>("map");
|
||||||
if (!map)
|
if (!map)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("please provide a --map <path to xml> arg");
|
throw std::runtime_error("please provide a --map <path to xml> arg");
|
||||||
}
|
}
|
||||||
xml_ = *map;
|
xml_ = *map;
|
||||||
|
|
||||||
boost::optional<std::string> ext = params.get<std::string>("extent");
|
const auto ext = params.get<std::string>("extent");
|
||||||
if (ext && !ext->empty())
|
if (ext && !ext->empty())
|
||||||
{
|
{
|
||||||
if (!extent_.from_string(*ext))
|
if (!extent_.from_string(*ext))
|
||||||
|
@ -43,67 +44,74 @@ public:
|
||||||
{
|
{
|
||||||
throw std::runtime_error("please provide a --extent=<minx,miny,maxx,maxy> arg");
|
throw std::runtime_error("please provide a --extent=<minx,miny,maxx,maxy> arg");
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
bool validate() const
|
bool validate() const
|
||||||
{
|
{
|
||||||
mapnik::Map m(width_,height_);
|
mapnik::Map m(width_, height_);
|
||||||
mapnik::load_map(m,xml_,true);
|
mapnik::load_map(m, xml_, true);
|
||||||
if (extent_.valid()) {
|
if (extent_.valid())
|
||||||
|
{
|
||||||
m.zoom_to_box(extent_);
|
m.zoom_to_box(extent_);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m.zoom_all();
|
m.zoom_all();
|
||||||
}
|
}
|
||||||
mapnik::image_rgba8 im(m.width(),m.height());
|
mapnik::image_rgba8 im(m.width(), m.height());
|
||||||
mapnik::agg_renderer<mapnik::image_rgba8> ren(m,im,scale_factor_);
|
mapnik::agg_renderer<mapnik::image_rgba8> ren(m, im, scale_factor_);
|
||||||
ren.apply();
|
ren.apply();
|
||||||
if (!preview_.empty()) {
|
if (!preview_.empty())
|
||||||
|
{
|
||||||
std::clog << "preview available at " << preview_ << "\n";
|
std::clog << "preview available at " << preview_ << "\n";
|
||||||
mapnik::save_to_file(im,preview_);
|
mapnik::save_to_file(im, preview_);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
if (!preview_.empty()) {
|
if (!preview_.empty())
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mapnik::Map m(width_,height_);
|
mapnik::Map m(width_, height_);
|
||||||
mapnik::load_map(m,xml_);
|
mapnik::load_map(m, xml_);
|
||||||
if (extent_.valid()) {
|
if (extent_.valid())
|
||||||
|
{
|
||||||
m.zoom_to_box(extent_);
|
m.zoom_to_box(extent_);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m.zoom_all();
|
m.zoom_all();
|
||||||
}
|
}
|
||||||
for (unsigned i=0;i<iterations_;++i)
|
for (unsigned i = 0; i < iterations_; ++i)
|
||||||
{
|
{
|
||||||
mapnik::image_rgba8 im(m.width(),m.height());
|
mapnik::image_rgba8 im(m.width(), m.height());
|
||||||
mapnik::agg_renderer<mapnik::image_rgba8> ren(m,im,scale_factor_);
|
mapnik::agg_renderer<mapnik::image_rgba8> ren(m, im, scale_factor_);
|
||||||
ren.apply();
|
ren.apply();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
mapnik::setup();
|
||||||
int return_value = 0;
|
int return_value = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mapnik::parameters params;
|
mapnik::parameters params;
|
||||||
benchmark::handle_args(argc,argv,params);
|
benchmark::handle_args(argc, argv, params);
|
||||||
boost::optional<std::string> name = params.get<std::string>("name");
|
const auto name = params.get<std::string>("name");
|
||||||
if (!name)
|
if (!name)
|
||||||
{
|
{
|
||||||
std::clog << "please provide a name for this test\n";
|
std::clog << "please provide a name for this test\n";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
mapnik::freetype_engine::register_fonts("./fonts/",true);
|
mapnik::freetype_engine::register_fonts("./fonts/", true);
|
||||||
mapnik::datasource_cache::instance().register_datasources("./plugins/input/");
|
mapnik::datasource_cache::instance().register_datasources("./plugins/input/");
|
||||||
{
|
{
|
||||||
test test_runner(params);
|
test test_runner(params);
|
||||||
return_value = run(test_runner,*name);
|
return_value = run(test_runner, *name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception const& ex)
|
catch (std::exception const& ex)
|
|
@ -12,14 +12,15 @@
|
||||||
#include <mapnik/datasource_cache.hpp>
|
#include <mapnik/datasource_cache.hpp>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
template <typename Renderer> void process_layers(Renderer & ren,
|
template<typename Renderer>
|
||||||
|
void process_layers(Renderer& ren,
|
||||||
mapnik::request const& m_req,
|
mapnik::request const& m_req,
|
||||||
mapnik::projection const& map_proj,
|
mapnik::projection const& map_proj,
|
||||||
std::vector<mapnik::layer> const& layers,
|
std::vector<mapnik::layer> const& layers,
|
||||||
double scale_denom)
|
double scale_denom)
|
||||||
{
|
{
|
||||||
unsigned layers_size = layers.size();
|
unsigned layers_size = layers.size();
|
||||||
for (unsigned i=0; i < layers_size; ++i)
|
for (unsigned i = 0; i < layers_size; ++i)
|
||||||
{
|
{
|
||||||
mapnik::layer const& lyr = layers[i];
|
mapnik::layer const& lyr = layers[i];
|
||||||
if (lyr.visible(scale_denom))
|
if (lyr.visible(scale_denom))
|
||||||
|
@ -50,27 +51,28 @@ class test : public benchmark::test_case
|
||||||
double scale_factor_;
|
double scale_factor_;
|
||||||
std::string preview_;
|
std::string preview_;
|
||||||
mutable mapnik::image_rgba8 im_;
|
mutable mapnik::image_rgba8 im_;
|
||||||
public:
|
|
||||||
|
public:
|
||||||
test(mapnik::parameters const& params)
|
test(mapnik::parameters const& params)
|
||||||
: test_case(params),
|
: test_case(params)
|
||||||
xml_(),
|
, xml_()
|
||||||
extent_(),
|
, extent_()
|
||||||
width_(*params.get<mapnik::value_integer>("width",256)),
|
, width_(*params.get<mapnik::value_integer>("width", 256))
|
||||||
height_(*params.get<mapnik::value_integer>("height",256)),
|
, height_(*params.get<mapnik::value_integer>("height", 256))
|
||||||
m_(new mapnik::Map(width_,height_)),
|
, m_(new mapnik::Map(width_, height_))
|
||||||
scale_factor_(*params.get<mapnik::value_double>("scale_factor",2.0)),
|
, scale_factor_(*params.get<mapnik::value_double>("scale_factor", 2.0))
|
||||||
preview_(*params.get<std::string>("preview","")),
|
, preview_(*params.get<std::string>("preview", ""))
|
||||||
im_(m_->width(),m_->height())
|
, im_(m_->width(), m_->height())
|
||||||
{
|
{
|
||||||
boost::optional<std::string> map = params.get<std::string>("map");
|
const auto map = params.get<std::string>("map");
|
||||||
if (!map)
|
if (!map)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("please provide a --map=<path to xml> arg");
|
throw std::runtime_error("please provide a --map=<path to xml> arg");
|
||||||
}
|
}
|
||||||
xml_ = *map;
|
xml_ = *map;
|
||||||
|
|
||||||
boost::optional<std::string> ext = params.get<std::string>("extent");
|
auto ext = params.get<std::string>("extent");
|
||||||
mapnik::load_map(*m_,xml_,true);
|
mapnik::load_map(*m_, xml_, true);
|
||||||
if (ext && !ext->empty())
|
if (ext && !ext->empty())
|
||||||
{
|
{
|
||||||
if (!extent_.from_string(*ext))
|
if (!extent_.from_string(*ext))
|
||||||
|
@ -87,42 +89,44 @@ public:
|
||||||
|
|
||||||
bool validate() const
|
bool validate() const
|
||||||
{
|
{
|
||||||
mapnik::request m_req(width_,height_,extent_);
|
mapnik::request m_req(width_, height_, extent_);
|
||||||
mapnik::attributes variables;
|
mapnik::attributes variables;
|
||||||
m_req.set_buffer_size(m_->buffer_size());
|
m_req.set_buffer_size(m_->buffer_size());
|
||||||
mapnik::projection map_proj(m_->srs(),true);
|
mapnik::projection map_proj(m_->srs(), true);
|
||||||
double scale_denom = mapnik::scale_denominator(m_req.scale(),map_proj.is_geographic());
|
double scale_denom = mapnik::scale_denominator(m_req.scale(), map_proj.is_geographic());
|
||||||
scale_denom *= scale_factor_;
|
scale_denom *= scale_factor_;
|
||||||
mapnik::agg_renderer<mapnik::image_rgba8> ren(*m_,m_req,variables,im_,scale_factor_);
|
mapnik::agg_renderer<mapnik::image_rgba8> ren(*m_, m_req, variables, im_, scale_factor_);
|
||||||
ren.start_map_processing(*m_);
|
ren.start_map_processing(*m_);
|
||||||
std::vector<mapnik::layer> const& layers = m_->layers();
|
std::vector<mapnik::layer> const& layers = m_->layers();
|
||||||
process_layers(ren,m_req,map_proj,layers,scale_denom);
|
process_layers(ren, m_req, map_proj, layers, scale_denom);
|
||||||
ren.end_map_processing(*m_);
|
ren.end_map_processing(*m_);
|
||||||
if (!preview_.empty()) {
|
if (!preview_.empty())
|
||||||
|
{
|
||||||
std::clog << "preview available at " << preview_ << "\n";
|
std::clog << "preview available at " << preview_ << "\n";
|
||||||
mapnik::save_to_file(im_,preview_);
|
mapnik::save_to_file(im_, preview_);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
if (!preview_.empty()) {
|
if (!preview_.empty())
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (unsigned i=0;i<iterations_;++i)
|
for (unsigned i = 0; i < iterations_; ++i)
|
||||||
{
|
{
|
||||||
mapnik::request m_req(width_,height_,extent_);
|
mapnik::request m_req(width_, height_, extent_);
|
||||||
mapnik::image_rgba8 im(m_->width(),m_->height());
|
mapnik::image_rgba8 im(m_->width(), m_->height());
|
||||||
mapnik::attributes variables;
|
mapnik::attributes variables;
|
||||||
m_req.set_buffer_size(m_->buffer_size());
|
m_req.set_buffer_size(m_->buffer_size());
|
||||||
mapnik::projection map_proj(m_->srs(),true);
|
mapnik::projection map_proj(m_->srs(), true);
|
||||||
double scale_denom = mapnik::scale_denominator(m_req.scale(),map_proj.is_geographic());
|
double scale_denom = mapnik::scale_denominator(m_req.scale(), map_proj.is_geographic());
|
||||||
scale_denom *= scale_factor_;
|
scale_denom *= scale_factor_;
|
||||||
mapnik::agg_renderer<mapnik::image_rgba8> ren(*m_,m_req,variables,im,scale_factor_);
|
mapnik::agg_renderer<mapnik::image_rgba8> ren(*m_, m_req, variables, im, scale_factor_);
|
||||||
ren.start_map_processing(*m_);
|
ren.start_map_processing(*m_);
|
||||||
std::vector<mapnik::layer> const& layers = m_->layers();
|
std::vector<mapnik::layer> const& layers = m_->layers();
|
||||||
process_layers(ren,m_req,map_proj,layers,scale_denom);
|
process_layers(ren, m_req, map_proj, layers, scale_denom);
|
||||||
ren.end_map_processing(*m_);
|
ren.end_map_processing(*m_);
|
||||||
bool diff = false;
|
bool diff = false;
|
||||||
mapnik::image_rgba8 const& dest = im;
|
mapnik::image_rgba8 const& dest = im;
|
||||||
|
@ -133,34 +137,36 @@ public:
|
||||||
const unsigned int* row_to = dest.get_row(y);
|
const unsigned int* row_to = dest.get_row(y);
|
||||||
for (unsigned int x = 0; x < width_; ++x)
|
for (unsigned int x = 0; x < width_; ++x)
|
||||||
{
|
{
|
||||||
if (row_from[x] != row_to[x]) diff = true;
|
if (row_from[x] != row_to[x])
|
||||||
|
diff = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (diff) throw std::runtime_error("images differ");
|
if (diff)
|
||||||
|
throw std::runtime_error("images differ");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
mapnik::setup();
|
||||||
int return_value = 0;
|
int return_value = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mapnik::parameters params;
|
mapnik::parameters params;
|
||||||
benchmark::handle_args(argc,argv,params);
|
benchmark::handle_args(argc, argv, params);
|
||||||
boost::optional<std::string> name = params.get<std::string>("name");
|
const auto name = params.get<std::string>("name");
|
||||||
if (!name)
|
if (!name)
|
||||||
{
|
{
|
||||||
std::clog << "please provide a name for this test\n";
|
std::clog << "please provide a name for this test\n";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
mapnik::freetype_engine::register_fonts("./fonts/",true);
|
mapnik::freetype_engine::register_fonts("./fonts/", true);
|
||||||
mapnik::datasource_cache::instance().register_datasources("./plugins/input/");
|
mapnik::datasource_cache::instance().register_datasources("./plugins/input/");
|
||||||
{
|
{
|
||||||
test test_runner(params);
|
test test_runner(params);
|
||||||
return_value = run(test_runner,*name);
|
return_value = run(test_runner, *name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception const& ex)
|
catch (std::exception const& ex)
|
34
benchmark/src/test_to_bool.cpp
Normal file
34
benchmark/src/test_to_bool.cpp
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#include "bench_framework.hpp"
|
||||||
|
#include <mapnik/util/conversions.hpp>
|
||||||
|
|
||||||
|
class test : public benchmark::test_case
|
||||||
|
{
|
||||||
|
std::string value_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
test(mapnik::parameters const& params)
|
||||||
|
: test_case(params)
|
||||||
|
, value_("true")
|
||||||
|
{}
|
||||||
|
bool validate() const
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
mapnik::util::string2bool(value_.data(), value_.data() + value_.size(), result);
|
||||||
|
if (!result)
|
||||||
|
return result;
|
||||||
|
mapnik::util::string2bool(value_, result);
|
||||||
|
return (result == true);
|
||||||
|
}
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
mapnik::util::string2bool(value_, result);
|
||||||
|
mapnik::util::string2bool(value_.data(), value_.data() + value_.size(), result);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BENCHMARK(test, "string->bool")
|
39
benchmark/src/test_to_double.cpp
Normal file
39
benchmark/src/test_to_double.cpp
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#include "bench_framework.hpp"
|
||||||
|
#include <mapnik/util/conversions.hpp>
|
||||||
|
|
||||||
|
class test : public benchmark::test_case
|
||||||
|
{
|
||||||
|
std::string value_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
test(mapnik::parameters const& params)
|
||||||
|
: test_case(params)
|
||||||
|
, value_("1.23456789")
|
||||||
|
{}
|
||||||
|
bool validate() const
|
||||||
|
{
|
||||||
|
double result = 0;
|
||||||
|
if (!mapnik::util::string2double(value_.data(), value_.data() + value_.size(), result))
|
||||||
|
return false;
|
||||||
|
if (result != 1.23456789)
|
||||||
|
return false;
|
||||||
|
result = 0;
|
||||||
|
if (!mapnik::util::string2double(value_, result))
|
||||||
|
return false;
|
||||||
|
if (result != 1.23456789)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
double result = 0;
|
||||||
|
mapnik::util::string2double(value_, result);
|
||||||
|
mapnik::util::string2double(value_.data(), value_.data() + value_.size(), result);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BENCHMARK(test, "string->double")
|
39
benchmark/src/test_to_int.cpp
Normal file
39
benchmark/src/test_to_int.cpp
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#include "bench_framework.hpp"
|
||||||
|
#include <mapnik/util/conversions.hpp>
|
||||||
|
|
||||||
|
class test : public benchmark::test_case
|
||||||
|
{
|
||||||
|
std::string value_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
test(mapnik::parameters const& params)
|
||||||
|
: test_case(params)
|
||||||
|
, value_("123456789")
|
||||||
|
{}
|
||||||
|
bool validate() const
|
||||||
|
{
|
||||||
|
mapnik::value_integer result = 0;
|
||||||
|
if (!mapnik::util::string2int(value_.data(), value_.data() + value_.size(), result))
|
||||||
|
return false;
|
||||||
|
if (result != 123456789)
|
||||||
|
return false;
|
||||||
|
result = 0;
|
||||||
|
if (!mapnik::util::string2int(value_, result))
|
||||||
|
return false;
|
||||||
|
if (result != 123456789)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool operator()() const
|
||||||
|
{
|
||||||
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
|
mapnik::value_integer result = 0;
|
||||||
|
mapnik::util::string2int(value_, result);
|
||||||
|
mapnik::util::string2int(value_.data(), value_.data() + value_.size(), result);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BENCHMARK(test, "string->int")
|
|
@ -4,25 +4,28 @@
|
||||||
class test : public benchmark::test_case
|
class test : public benchmark::test_case
|
||||||
{
|
{
|
||||||
double value_;
|
double value_;
|
||||||
public:
|
|
||||||
|
public:
|
||||||
test(mapnik::parameters const& params)
|
test(mapnik::parameters const& params)
|
||||||
: test_case(params),
|
: test_case(params)
|
||||||
value_(-0.1234) {}
|
, value_(-0.1234)
|
||||||
|
{}
|
||||||
bool validate() const
|
bool validate() const
|
||||||
{
|
{
|
||||||
std::string s;
|
std::string s;
|
||||||
mapnik::util::to_string(s,value_);
|
mapnik::util::to_string(s, value_);
|
||||||
return (s == "-0.1234");
|
return (s == "-0.1234");
|
||||||
}
|
}
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
std::string out;
|
std::string out;
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
out.clear();
|
out.clear();
|
||||||
mapnik::util::to_string(out,value_);
|
mapnik::util::to_string(out, value_);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
BENCHMARK(test,"to_string double->string")
|
BENCHMARK(test, "to_string double->string")
|
|
@ -4,10 +4,12 @@
|
||||||
class test : public benchmark::test_case
|
class test : public benchmark::test_case
|
||||||
{
|
{
|
||||||
double value_;
|
double value_;
|
||||||
public:
|
|
||||||
|
public:
|
||||||
test(mapnik::parameters const& params)
|
test(mapnik::parameters const& params)
|
||||||
: test_case(params),
|
: test_case(params)
|
||||||
value_(-0.1234) {}
|
, value_(-0.1234)
|
||||||
|
{}
|
||||||
bool validate() const
|
bool validate() const
|
||||||
{
|
{
|
||||||
std::ostringstream s;
|
std::ostringstream s;
|
||||||
|
@ -17,7 +19,8 @@ public:
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
std::string out;
|
std::string out;
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
std::ostringstream s;
|
std::ostringstream s;
|
||||||
s << value_;
|
s << value_;
|
||||||
out = s.str();
|
out = s.str();
|
||||||
|
@ -26,4 +29,4 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
BENCHMARK(test,"ostringstream double->string")
|
BENCHMARK(test, "ostringstream double->string")
|
|
@ -1,33 +1,40 @@
|
||||||
#include "bench_framework.hpp"
|
#include "bench_framework.hpp"
|
||||||
#include <mapnik/unicode.hpp>
|
#include <mapnik/unicode.hpp>
|
||||||
|
#include <mapnik/util/from_u8string.hpp>
|
||||||
#include <mapnik/value.hpp>
|
#include <mapnik/value.hpp>
|
||||||
#include <boost/locale.hpp>
|
#include <boost/locale.hpp>
|
||||||
#ifndef __linux__
|
#ifndef __linux__
|
||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using mapnik::util::from_u8string;
|
||||||
|
|
||||||
|
#ifndef __linux__
|
||||||
class test : public benchmark::test_case
|
class test : public benchmark::test_case
|
||||||
{
|
{
|
||||||
std::string utf8_;
|
std::string utf8_;
|
||||||
public:
|
|
||||||
|
public:
|
||||||
test(mapnik::parameters const& params)
|
test(mapnik::parameters const& params)
|
||||||
: test_case(params),
|
: test_case(params)
|
||||||
utf8_(u8"שלום") {}
|
, utf8_(from_u8string(u8"שלום"))
|
||||||
|
{}
|
||||||
bool validate() const
|
bool validate() const
|
||||||
{
|
{
|
||||||
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> utf32conv;
|
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> utf32conv;
|
||||||
std::u32string utf32 = utf32conv.from_bytes(utf8_);
|
std::u32string utf32 = utf32conv.from_bytes(utf8_);
|
||||||
if (utf32.size() != 4) return false;
|
if (utf32.size() != 4)
|
||||||
if (utf32[0] != 0x5e9 &&
|
return false;
|
||||||
utf32[1] != 0x5dc &&
|
if (utf32[0] != 0x5e9 && utf32[1] != 0x5dc && utf32[2] != 0x5d5 && utf32[3] != 0x5dd)
|
||||||
utf32[2] != 0x5d5 &&
|
return false;
|
||||||
utf32[3] != 0x5dd) return false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
std::u32string utf32;
|
std::u32string utf32;
|
||||||
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> utf32conv;
|
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> utf32conv;
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
utf32 = utf32conv.from_bytes(utf8_);
|
utf32 = utf32conv.from_bytes(utf8_);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -39,24 +46,26 @@ public:
|
||||||
class test2 : public benchmark::test_case
|
class test2 : public benchmark::test_case
|
||||||
{
|
{
|
||||||
std::string utf8_;
|
std::string utf8_;
|
||||||
public:
|
|
||||||
|
public:
|
||||||
test2(mapnik::parameters const& params)
|
test2(mapnik::parameters const& params)
|
||||||
: test_case(params),
|
: test_case(params)
|
||||||
utf8_(u8"שלום") {}
|
, utf8_(from_u8string(u8"שלום"))
|
||||||
|
{}
|
||||||
bool validate() const
|
bool validate() const
|
||||||
{
|
{
|
||||||
std::u32string utf32 = boost::locale::conv::utf_to_utf<char32_t>(utf8_);
|
std::u32string utf32 = boost::locale::conv::utf_to_utf<char32_t>(utf8_);
|
||||||
if (utf32.size() != 4) return false;
|
if (utf32.size() != 4)
|
||||||
if (utf32[0] != 0x5e9 &&
|
return false;
|
||||||
utf32[1] != 0x5dc &&
|
if (utf32[0] != 0x5e9 && utf32[1] != 0x5dc && utf32[2] != 0x5d5 && utf32[3] != 0x5dd)
|
||||||
utf32[2] != 0x5d5 &&
|
return false;
|
||||||
utf32[3] != 0x5dd) return false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
std::u32string utf32;
|
std::u32string utf32;
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
|
{
|
||||||
utf32 = boost::locale::conv::utf_to_utf<char32_t>(utf8_);
|
utf32 = boost::locale::conv::utf_to_utf<char32_t>(utf8_);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -66,28 +75,30 @@ public:
|
||||||
class test3 : public benchmark::test_case
|
class test3 : public benchmark::test_case
|
||||||
{
|
{
|
||||||
std::string utf8_;
|
std::string utf8_;
|
||||||
public:
|
|
||||||
|
public:
|
||||||
test3(mapnik::parameters const& params)
|
test3(mapnik::parameters const& params)
|
||||||
: test_case(params),
|
: test_case(params)
|
||||||
utf8_(u8"שלום") {}
|
, utf8_(from_u8string(u8"שלום"))
|
||||||
|
{}
|
||||||
bool validate() const
|
bool validate() const
|
||||||
{
|
{
|
||||||
mapnik::transcoder tr_("utf-8");
|
mapnik::transcoder tr_("utf-8");
|
||||||
mapnik::value_unicode_string utf32 = tr_.transcode(utf8_.data(),utf8_.size());
|
mapnik::value_unicode_string utf32 = tr_.transcode(utf8_.data(), utf8_.size());
|
||||||
//std::u32string utf32 = boost::locale::conv::utf_to_utf<char32_t>(utf8_);
|
// std::u32string utf32 = boost::locale::conv::utf_to_utf<char32_t>(utf8_);
|
||||||
if (utf32.length() != 4) return false;
|
if (utf32.length() != 4)
|
||||||
if (utf32[0] != 0x5e9 &&
|
return false;
|
||||||
utf32[1] != 0x5dc &&
|
if (utf32[0] != 0x5e9 && utf32[1] != 0x5dc && utf32[2] != 0x5d5 && utf32[3] != 0x5dd)
|
||||||
utf32[2] != 0x5d5 &&
|
return false;
|
||||||
utf32[3] != 0x5dd) return false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool operator()() const
|
bool operator()() const
|
||||||
{
|
{
|
||||||
mapnik::transcoder tr_("utf-8");
|
mapnik::transcoder tr_("utf-8");
|
||||||
mapnik::value_unicode_string utf32;
|
mapnik::value_unicode_string utf32;
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
for (std::size_t i = 0; i < iterations_; ++i)
|
||||||
utf32 = tr_.transcode(utf8_.data(),utf8_.size());
|
{
|
||||||
|
utf32 = tr_.transcode(utf8_.data(), utf8_.size());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -95,18 +106,19 @@ public:
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
mapnik::setup();
|
||||||
mapnik::parameters params;
|
mapnik::parameters params;
|
||||||
benchmark::handle_args(argc,argv,params);
|
benchmark::handle_args(argc, argv, params);
|
||||||
int return_value = 0;
|
int return_value = 0;
|
||||||
#ifndef __linux__
|
#ifndef __linux__
|
||||||
test test_runner(params);
|
test test_runner(params);
|
||||||
return_value = return_value | run(test_runner,"utf encode std::codecvt");
|
return_value = return_value | run(test_runner, "utf encode std::codecvt");
|
||||||
#else
|
#else
|
||||||
std::clog << "skipping 'utf encode std::codecvt' test since <codecvt> is not supported on __linux__\n";
|
std::clog << "skipping 'utf encode std::codecvt' test since <codecvt> is not supported on __linux__\n";
|
||||||
#endif
|
#endif
|
||||||
test2 test_runner2(params);
|
test2 test_runner2(params);
|
||||||
return_value = return_value | run(test_runner2,"utf encode boost::locale");
|
return_value = return_value | run(test_runner2, "utf encode boost::locale");
|
||||||
test3 test_runner3(params);
|
test3 test_runner3(params);
|
||||||
return_value = return_value | run(test_runner3,"utf encode ICU");
|
return_value = return_value | run(test_runner3, "utf encode ICU");
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
|
@ -2,16 +2,12 @@
|
||||||
|
|
||||||
class test : public benchmark::test_case
|
class test : public benchmark::test_case
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
test(mapnik::parameters const& params)
|
test(mapnik::parameters const& params)
|
||||||
: test_case(params) {}
|
: test_case(params)
|
||||||
bool validate() const
|
{}
|
||||||
{
|
bool validate() const { return true; }
|
||||||
return true;
|
void operator()() const {}
|
||||||
}
|
|
||||||
void operator()() const
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
BENCHMARK(test,"test name")
|
BENCHMARK(test, "test name")
|
||||||
|
|
|
@ -1,379 +0,0 @@
|
||||||
#include "bench_framework.hpp"
|
|
||||||
#include <cstring>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <deque>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <array>
|
|
||||||
#include <valarray>
|
|
||||||
#include <boost/version.hpp>
|
|
||||||
#if BOOST_VERSION >= 105400
|
|
||||||
#include <boost/container/static_vector.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// http://stackoverflow.com/questions/17347254/why-is-allocation-and-deallocation-of-stdvector-slower-than-dynamic-array-on-m
|
|
||||||
|
|
||||||
#define FULL_ZERO_CHECK
|
|
||||||
|
|
||||||
inline void ensure_zero(uint8_t * data, uint32_t size) {
|
|
||||||
#ifdef FULL_ZERO_CHECK
|
|
||||||
for (std::size_t i=0;i<size;++i) {
|
|
||||||
if (data[i] != 0) {
|
|
||||||
throw std::runtime_error("found non zero value");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (data[0] != 0) {
|
|
||||||
throw std::runtime_error("found non zero value");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
class test1 : public benchmark::test_case
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
uint32_t size_;
|
|
||||||
std::vector<uint8_t> array_;
|
|
||||||
test1(mapnik::parameters const& params)
|
|
||||||
: test_case(params),
|
|
||||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
|
||||||
array_(size_,0) { }
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
|
||||||
// NOTE: sizeof(uint8_t) == 1
|
|
||||||
uint8_t *data = (uint8_t *)malloc(sizeof(uint8_t)*size_);
|
|
||||||
memcpy(data, &array_[0], size_);
|
|
||||||
ensure_zero(data,size_);
|
|
||||||
free(data);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class test1b : public benchmark::test_case
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
uint32_t size_;
|
|
||||||
std::vector<uint8_t> array_;
|
|
||||||
test1b(mapnik::parameters const& params)
|
|
||||||
: test_case(params),
|
|
||||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
|
||||||
array_(size_,0) { }
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
|
||||||
// NOTE: sizeof(uint8_t) == 1
|
|
||||||
uint8_t *data = (uint8_t *)malloc(sizeof(uint8_t)*size_);
|
|
||||||
memset(data, 0, sizeof(uint8_t)*size_);
|
|
||||||
ensure_zero(data,size_);
|
|
||||||
free(data);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class test1c : public benchmark::test_case
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
uint32_t size_;
|
|
||||||
std::vector<uint8_t> array_;
|
|
||||||
test1c(mapnik::parameters const& params)
|
|
||||||
: test_case(params),
|
|
||||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
|
||||||
array_(size_,0) { }
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
|
||||||
uint8_t *data = static_cast<uint8_t *>(::operator new(sizeof(uint8_t) * size_));
|
|
||||||
std::fill(data,data + size_,0);
|
|
||||||
ensure_zero(data,size_);
|
|
||||||
::operator delete(data);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class test2 : public benchmark::test_case
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
uint32_t size_;
|
|
||||||
std::vector<uint8_t> array_;
|
|
||||||
test2(mapnik::parameters const& params)
|
|
||||||
: test_case(params),
|
|
||||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
|
||||||
array_(size_,0) { }
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
|
||||||
uint8_t * data = static_cast<uint8_t*>(::operator new(sizeof(uint8_t)*size_));
|
|
||||||
memcpy(data, &array_[0], size_);
|
|
||||||
ensure_zero(data,size_);
|
|
||||||
::operator delete(data),data=0;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class test3 : public benchmark::test_case
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
uint32_t size_;
|
|
||||||
std::vector<uint8_t> array_;
|
|
||||||
test3(mapnik::parameters const& params)
|
|
||||||
: test_case(params),
|
|
||||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
|
||||||
array_(size_,0) { }
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
|
||||||
std::vector<uint8_t> data(size_);
|
|
||||||
ensure_zero(&data[0],data.size());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class test3b : public benchmark::test_case
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
uint32_t size_;
|
|
||||||
std::vector<uint8_t> array_;
|
|
||||||
test3b(mapnik::parameters const& params)
|
|
||||||
: test_case(params),
|
|
||||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
|
||||||
array_(size_,0) { }
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
|
||||||
std::vector<uint8_t> data(0);
|
|
||||||
data.resize(size_,0);
|
|
||||||
ensure_zero(&data[0],data.size());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class test3c : public benchmark::test_case
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
uint32_t size_;
|
|
||||||
std::vector<uint8_t> array_;
|
|
||||||
test3c(mapnik::parameters const& params)
|
|
||||||
: test_case(params),
|
|
||||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
|
||||||
array_(size_,0) { }
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
|
||||||
std::vector<uint8_t> data(0);
|
|
||||||
data.assign(size_,0);
|
|
||||||
ensure_zero(&data[0],data.size());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class test3d : public benchmark::test_case
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
uint32_t size_;
|
|
||||||
std::vector<uint8_t> array_;
|
|
||||||
test3d(mapnik::parameters const& params)
|
|
||||||
: test_case(params),
|
|
||||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
|
||||||
array_(size_,0) { }
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
|
||||||
std::deque<uint8_t> data(size_);
|
|
||||||
for (std::size_t i=0;i<size_;++i) {
|
|
||||||
if (data[i] != 0) {
|
|
||||||
throw std::runtime_error("found non zero value");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class test4 : public benchmark::test_case
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
uint32_t size_;
|
|
||||||
std::vector<uint8_t> array_;
|
|
||||||
test4(mapnik::parameters const& params)
|
|
||||||
: test_case(params),
|
|
||||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
|
||||||
array_(size_,0) { }
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
|
||||||
uint8_t *data = (uint8_t *)calloc(size_,sizeof(uint8_t));
|
|
||||||
ensure_zero(data,size_);
|
|
||||||
free(data);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class test5 : public benchmark::test_case
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
uint32_t size_;
|
|
||||||
std::vector<uint8_t> array_;
|
|
||||||
test5(mapnik::parameters const& params)
|
|
||||||
: test_case(params),
|
|
||||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
|
||||||
array_(size_,0) { }
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
|
||||||
std::string data(array_.begin(),array_.end());
|
|
||||||
ensure_zero((uint8_t *)&data[0],size_);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class test5b : public benchmark::test_case
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
uint32_t size_;
|
|
||||||
std::vector<char> array_;
|
|
||||||
test5b(mapnik::parameters const& params)
|
|
||||||
: test_case(params),
|
|
||||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
|
||||||
array_(size_,0) { }
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
|
||||||
std::string data(&array_[0],array_.size());
|
|
||||||
ensure_zero((uint8_t *)&data[0],size_);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// C++14 dynarray<T>
|
|
||||||
// http://isocpp.org/blog/2013/04/trip-report-iso-c-spring-2013-meeting
|
|
||||||
// http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130909/088700.html
|
|
||||||
// http://stackoverflow.com/questions/17303902/any-alternative-to-stddynarray-presently-available
|
|
||||||
|
|
||||||
class test6 : public benchmark::test_case
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
uint32_t size_;
|
|
||||||
std::vector<uint8_t> array_;
|
|
||||||
test6(mapnik::parameters const& params)
|
|
||||||
: test_case(params),
|
|
||||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
|
||||||
array_(size_,0) { }
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
|
||||||
std::valarray<uint8_t> data(static_cast<uint8_t>(0),static_cast<size_t>(size_));
|
|
||||||
ensure_zero(&data[0],size_);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#if BOOST_VERSION >= 105400
|
|
||||||
// http://i42.co.uk/stuff/vecarray.htm
|
|
||||||
// http://www.boost.org/doc/libs/1_54_0/doc/html/boost/container/static_vector.html
|
|
||||||
|
|
||||||
class test7 : public benchmark::test_case
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
uint32_t size_;
|
|
||||||
std::vector<uint8_t> array_;
|
|
||||||
test7(mapnik::parameters const& params)
|
|
||||||
: test_case(params),
|
|
||||||
size_(*params.get<mapnik::value_integer>("size",256*256)),
|
|
||||||
array_(size_,0) { }
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
|
||||||
boost::container::static_vector<uint8_t,256*256> data(size_,0);
|
|
||||||
ensure_zero(&data[0],size_);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
return benchmark::sequencer(argc, argv)
|
|
||||||
.run<test4>("calloc")
|
|
||||||
.run<test1>("malloc/memcpy")
|
|
||||||
.run<test1b>("malloc/memset")
|
|
||||||
.run<test1c>("operator new/std::fill")
|
|
||||||
.run<test2>("operator new/memcpy")
|
|
||||||
.run<test3>("vector(N)")
|
|
||||||
.run<test3b>("vector/resize")
|
|
||||||
.run<test3c>("vector/assign")
|
|
||||||
.run<test3d>("deque(N)")
|
|
||||||
.run<test5>("std::string range")
|
|
||||||
.run<test5b>("std::string &[0]")
|
|
||||||
.run<test6>("valarray")
|
|
||||||
#if BOOST_VERSION >= 105400
|
|
||||||
.run<test7>("static_vector")
|
|
||||||
#endif
|
|
||||||
.done();
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
#include "bench_framework.hpp"
|
|
||||||
#include <mapnik/marker_cache.hpp>
|
|
||||||
|
|
||||||
class test : public benchmark::test_case
|
|
||||||
{
|
|
||||||
std::vector<std::string> images_;
|
|
||||||
public:
|
|
||||||
test(mapnik::parameters const& params)
|
|
||||||
: test_case(params),
|
|
||||||
images_{
|
|
||||||
"./test/data/images/dummy.jpg",
|
|
||||||
"./test/data/images/dummy.jpeg",
|
|
||||||
"./test/data/images/dummy.png",
|
|
||||||
"./test/data/images/dummy.tif",
|
|
||||||
"./test/data/images/dummy.tiff",
|
|
||||||
//"./test/data/images/landusepattern.jpeg", // will fail since it is a png
|
|
||||||
//"./test/data/images/xcode-CgBI.png", // will fail since its an invalid png
|
|
||||||
"./test/data/svg/octocat.svg",
|
|
||||||
"./test/data/svg/place-of-worship-24.svg",
|
|
||||||
"./test/data/svg/point_sm.svg",
|
|
||||||
"./test/data/svg/point.svg",
|
|
||||||
"./test/data/svg/airfield-12.svg"
|
|
||||||
} {}
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
unsigned count = 0;
|
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
|
||||||
for (auto filename : images_)
|
|
||||||
{
|
|
||||||
auto marker = mapnik::marker_cache::instance().find(filename,true);
|
|
||||||
}
|
|
||||||
++count;
|
|
||||||
}
|
|
||||||
return (count == iterations_);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
BENCHMARK(test,"marker cache")
|
|
|
@ -1,60 +0,0 @@
|
||||||
#include "bench_framework.hpp"
|
|
||||||
#include <mapnik/map.hpp>
|
|
||||||
#include <mapnik/load_map.hpp>
|
|
||||||
#include <mapnik/agg_renderer.hpp>
|
|
||||||
#include <mapnik/datasource_cache.hpp>
|
|
||||||
|
|
||||||
class test : public benchmark::test_case
|
|
||||||
{
|
|
||||||
std::string xml_;
|
|
||||||
mapnik::box2d<double> extent_;
|
|
||||||
public:
|
|
||||||
test(mapnik::parameters const& params,
|
|
||||||
std::string const& xml,
|
|
||||||
mapnik::box2d<double> const& extent)
|
|
||||||
: test_case(params),
|
|
||||||
xml_(xml),
|
|
||||||
extent_(extent)
|
|
||||||
{}
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
mapnik::Map m(256,256);
|
|
||||||
mapnik::load_map(m,xml_);
|
|
||||||
m.zoom_to_box(extent_);
|
|
||||||
mapnik::image_rgba8 im(m.width(),m.height());
|
|
||||||
mapnik::agg_renderer<mapnik::image_rgba8> ren(m,im);
|
|
||||||
ren.apply();
|
|
||||||
//mapnik::save_to_file(im.data(),"test.png");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
mapnik::Map m(256,256);
|
|
||||||
mapnik::load_map(m,xml_);
|
|
||||||
m.zoom_to_box(extent_);
|
|
||||||
for (unsigned i=0;i<iterations_;++i)
|
|
||||||
{
|
|
||||||
mapnik::image_rgba8 im(m.width(),m.height());
|
|
||||||
mapnik::agg_renderer<mapnik::image_rgba8> ren(m,im);
|
|
||||||
ren.apply();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
mapnik::parameters params;
|
|
||||||
benchmark::handle_args(argc,argv,params);
|
|
||||||
mapnik::datasource_cache::instance().register_datasources("./plugins/input/");
|
|
||||||
mapnik::box2d<double> z1(-20037508.3428,-8317435.0606,20037508.3428,18399242.7298);
|
|
||||||
// bbox for 16/10491/22911.png
|
|
||||||
mapnik::box2d<double> z16(-13622912.929097254,6026906.8062295765,-13621689.93664469,6028129.79868214);
|
|
||||||
return benchmark::sequencer(argc, argv)
|
|
||||||
.run<test>("polygon clip render z1", "benchmark/data/polygon_rendering_clip.xml", z1)
|
|
||||||
.run<test>("polygon noclip render z1", "benchmark/data/polygon_rendering_no_clip.xml", z1)
|
|
||||||
.run<test>("polygon clip render z16", "benchmark/data/polygon_rendering_clip.xml", z16)
|
|
||||||
.run<test>("polygon noclip render z16", "benchmark/data/polygon_rendering_no_clip.xml", z16)
|
|
||||||
.done();
|
|
||||||
}
|
|
|
@ -1,74 +0,0 @@
|
||||||
#include "bench_framework.hpp"
|
|
||||||
#include <mapnik/geometry/box2d.hpp>
|
|
||||||
#include <mapnik/projection.hpp>
|
|
||||||
#include <mapnik/proj_transform.hpp>
|
|
||||||
|
|
||||||
class test : public benchmark::test_case
|
|
||||||
{
|
|
||||||
std::string src_;
|
|
||||||
std::string dest_;
|
|
||||||
mapnik::box2d<double> from_;
|
|
||||||
mapnik::box2d<double> to_;
|
|
||||||
bool defer_proj4_init_;
|
|
||||||
public:
|
|
||||||
test(mapnik::parameters const& params,
|
|
||||||
std::string const& src,
|
|
||||||
std::string const& dest,
|
|
||||||
mapnik::box2d<double> const& from,
|
|
||||||
mapnik::box2d<double> const& to,
|
|
||||||
bool defer_proj)
|
|
||||||
: test_case(params),
|
|
||||||
src_(src),
|
|
||||||
dest_(dest),
|
|
||||||
from_(from),
|
|
||||||
to_(to),
|
|
||||||
defer_proj4_init_(defer_proj) {}
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
mapnik::projection src(src_,defer_proj4_init_);
|
|
||||||
mapnik::projection dest(dest_,defer_proj4_init_);
|
|
||||||
mapnik::proj_transform tr(src,dest);
|
|
||||||
mapnik::box2d<double> bbox = from_;
|
|
||||||
if (!tr.forward(bbox)) return false;
|
|
||||||
return ((std::fabs(bbox.minx() - to_.minx()) < .5) &&
|
|
||||||
(std::fabs(bbox.maxx() - to_.maxx()) < .5) &&
|
|
||||||
(std::fabs(bbox.miny() - to_.miny()) < .5) &&
|
|
||||||
(std::fabs(bbox.maxy() - to_.maxy()) < .5)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
for (std::size_t i=0;i<iterations_;++i)
|
|
||||||
{
|
|
||||||
for (int j=-180;j<180;j=j+5)
|
|
||||||
{
|
|
||||||
for (int k=-85;k<85;k=k+5)
|
|
||||||
{
|
|
||||||
mapnik::projection src(src_,defer_proj4_init_);
|
|
||||||
mapnik::projection dest(dest_,defer_proj4_init_);
|
|
||||||
mapnik::proj_transform tr(src,dest);
|
|
||||||
mapnik::box2d<double> box(j,k,j,k);
|
|
||||||
if (!tr.forward(box)) throw std::runtime_error("could not transform coords");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// echo -180 -60 | cs2cs -f "%.10f" +init=epsg:4326 +to +init=epsg:3857
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
mapnik::box2d<double> from(-180,-80,180,80);
|
|
||||||
mapnik::box2d<double> to(-20037508.3427892476,-15538711.0963092316,20037508.3427892476,15538711.0963092316);
|
|
||||||
std::string from_str("+init=epsg:4326");
|
|
||||||
std::string to_str("+init=epsg:3857");
|
|
||||||
std::string from_str2("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");
|
|
||||||
std::string to_str2("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over");
|
|
||||||
return benchmark::sequencer(argc, argv)
|
|
||||||
.run<test>("lonlat->merc epsg", from_str, to_str, from, to, true)
|
|
||||||
.run<test>("lonlat->merc literal", from_str2, to_str2, from, to, true)
|
|
||||||
.run<test>("merc->lonlat epsg", to_str, from_str, to, from, true)
|
|
||||||
.run<test>("merc->lonlat literal", to_str2, from_str2, to, from, true)
|
|
||||||
.done();
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
#include "bench_framework.hpp"
|
|
||||||
#include <mapnik/util/conversions.hpp>
|
|
||||||
|
|
||||||
class test : public benchmark::test_case
|
|
||||||
{
|
|
||||||
std::string value_;
|
|
||||||
public:
|
|
||||||
test(mapnik::parameters const& params)
|
|
||||||
: test_case(params),
|
|
||||||
value_("true") {}
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
bool result = false;
|
|
||||||
mapnik::util::string2bool(value_.data(),value_.data()+value_.size(),result);
|
|
||||||
if (!result) return result;
|
|
||||||
mapnik::util::string2bool(value_,result);
|
|
||||||
return (result == true);
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
|
||||||
bool result = false;
|
|
||||||
mapnik::util::string2bool(value_,result);
|
|
||||||
mapnik::util::string2bool(value_.data(),value_.data()+value_.size(),result);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
BENCHMARK(test,"string->bool")
|
|
|
@ -1,32 +0,0 @@
|
||||||
#include "bench_framework.hpp"
|
|
||||||
#include <mapnik/util/conversions.hpp>
|
|
||||||
|
|
||||||
class test : public benchmark::test_case
|
|
||||||
{
|
|
||||||
std::string value_;
|
|
||||||
public:
|
|
||||||
test(mapnik::parameters const& params)
|
|
||||||
: test_case(params),
|
|
||||||
value_("1.23456789") {}
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
double result = 0;
|
|
||||||
if (!mapnik::util::string2double(value_.data(),value_.data()+value_.size(),result)) return false;
|
|
||||||
if (result != 1.23456789) return false;
|
|
||||||
result = 0;
|
|
||||||
if (!mapnik::util::string2double(value_,result)) return false;
|
|
||||||
if (result != 1.23456789) return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
|
||||||
double result = 0;
|
|
||||||
mapnik::util::string2double(value_,result);
|
|
||||||
mapnik::util::string2double(value_.data(),value_.data()+value_.size(),result);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
BENCHMARK(test,"string->double")
|
|
|
@ -1,32 +0,0 @@
|
||||||
#include "bench_framework.hpp"
|
|
||||||
#include <mapnik/util/conversions.hpp>
|
|
||||||
|
|
||||||
class test : public benchmark::test_case
|
|
||||||
{
|
|
||||||
std::string value_;
|
|
||||||
public:
|
|
||||||
test(mapnik::parameters const& params)
|
|
||||||
: test_case(params),
|
|
||||||
value_("123456789") {}
|
|
||||||
bool validate() const
|
|
||||||
{
|
|
||||||
mapnik::value_integer result = 0;
|
|
||||||
if (!mapnik::util::string2int(value_.data(),value_.data()+value_.size(),result)) return false;
|
|
||||||
if (result != 123456789) return false;
|
|
||||||
result = 0;
|
|
||||||
if (!mapnik::util::string2int(value_,result)) return false;
|
|
||||||
if (result != 123456789) return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool operator()() const
|
|
||||||
{
|
|
||||||
for (std::size_t i=0;i<iterations_;++i) {
|
|
||||||
mapnik::value_integer result = 0;
|
|
||||||
mapnik::util::string2int(value_,result);
|
|
||||||
mapnik::util::string2int(value_.data(),value_.data()+value_.size(),result);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
BENCHMARK(test,"string->int")
|
|
|
@ -3,8 +3,8 @@ import random
|
||||||
|
|
||||||
im = mapnik.Image(256,256)
|
im = mapnik.Image(256,256)
|
||||||
|
|
||||||
for x in xrange(0,im.width()):
|
for x in range(im.width()):
|
||||||
for y in xrange(0,im.height()):
|
for y in range(im.height()):
|
||||||
r = int(random.random() * 255)
|
r = int(random.random() * 255)
|
||||||
g = random.random() * 255
|
g = random.random() * 255
|
||||||
b = random.random() * 255
|
b = random.random() * 255
|
||||||
|
|
153
bootstrap.sh
153
bootstrap.sh
|
@ -1,153 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -eu
|
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
: '
|
|
||||||
|
|
||||||
todo
|
|
||||||
|
|
||||||
- docs for base setup: sudo apt-get -y install zlib1g-dev make git
|
|
||||||
- shrink icu data
|
|
||||||
'
|
|
||||||
|
|
||||||
MASON_VERSION="v0.11.1"
|
|
||||||
|
|
||||||
function setup_mason() {
|
|
||||||
if [[ ! -d ./.mason ]]; then
|
|
||||||
git clone https://github.com/mapbox/mason.git ./.mason
|
|
||||||
(cd ./.mason && git checkout ${MASON_VERSION})
|
|
||||||
else
|
|
||||||
echo "Updating to latest mason"
|
|
||||||
(cd ./.mason && git fetch && git checkout ${MASON_VERSION} && git pull origin ${MASON_VERSION})
|
|
||||||
fi
|
|
||||||
export PATH=$(pwd)/.mason:$PATH
|
|
||||||
export CXX=${CXX:-clang++}
|
|
||||||
export CC=${CC:-clang}
|
|
||||||
}
|
|
||||||
|
|
||||||
function install() {
|
|
||||||
MASON_PLATFORM_ID=$(mason env MASON_PLATFORM_ID)
|
|
||||||
if [[ ! -d ./mason_packages/${MASON_PLATFORM_ID}/${1}/${2} ]]; then
|
|
||||||
mason install $1 $2
|
|
||||||
if [[ ${3:-false} != false ]]; then
|
|
||||||
LA_FILE=$(mason prefix $1 $2)/lib/$3.la
|
|
||||||
if [[ -f ${LA_FILE} ]]; then
|
|
||||||
perl -i -p -e 's:\Q$ENV{HOME}/build/mapbox/mason\E:$ENV{PWD}:g' ${LA_FILE}
|
|
||||||
else
|
|
||||||
echo "$LA_FILE not found"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
# the rm here is to workaround https://github.com/mapbox/mason/issues/230
|
|
||||||
rm -f ./mason_packages/.link/mason.ini
|
|
||||||
mason link $1 $2
|
|
||||||
}
|
|
||||||
|
|
||||||
ICU_VERSION="57.1"
|
|
||||||
|
|
||||||
function install_mason_deps() {
|
|
||||||
install ccache 3.3.1
|
|
||||||
install zlib 1.2.8
|
|
||||||
install jpeg_turbo 1.5.1 libjpeg
|
|
||||||
install libpng 1.6.28 libpng
|
|
||||||
install libtiff 4.0.7 libtiff
|
|
||||||
install libpq 9.6.2
|
|
||||||
install sqlite 3.17.0 libsqlite3
|
|
||||||
install expat 2.2.0 libexpat
|
|
||||||
install icu ${ICU_VERSION}
|
|
||||||
install proj 4.9.3 libproj
|
|
||||||
install pixman 0.34.0 libpixman-1
|
|
||||||
install cairo 1.14.8 libcairo
|
|
||||||
install protobuf 3.2.0
|
|
||||||
# technically protobuf is not a mapnik core dep, but installing
|
|
||||||
# here by default helps make mapnik-vector-tile builds easier
|
|
||||||
install webp 0.6.0 libwebp
|
|
||||||
install libgdal 2.1.3 libgdal
|
|
||||||
install boost 1.63.0
|
|
||||||
install boost_libsystem 1.63.0
|
|
||||||
install boost_libfilesystem 1.63.0
|
|
||||||
install boost_libprogram_options 1.63.0
|
|
||||||
install boost_libregex_icu57 1.63.0
|
|
||||||
# technically boost thread and python are not a core dep, but installing
|
|
||||||
# here by default helps make python-mapnik builds easier
|
|
||||||
install boost_libthread 1.63.0
|
|
||||||
install boost_libpython 1.63.0
|
|
||||||
install freetype 2.7.1 libfreetype
|
|
||||||
install harfbuzz 1.4.4-ft libharfbuzz
|
|
||||||
}
|
|
||||||
|
|
||||||
MASON_LINKED_ABS=$(pwd)/mason_packages/.link
|
|
||||||
MASON_LINKED_REL=./mason_packages/.link
|
|
||||||
export C_INCLUDE_PATH="${MASON_LINKED_ABS}/include"
|
|
||||||
export CPLUS_INCLUDE_PATH="${MASON_LINKED_ABS}/include"
|
|
||||||
export LIBRARY_PATH="${MASON_LINKED_ABS}/lib"
|
|
||||||
|
|
||||||
function make_config() {
|
|
||||||
echo "
|
|
||||||
CXX = '$CXX'
|
|
||||||
CC = '$CC'
|
|
||||||
CUSTOM_CXXFLAGS = '-D_GLIBCXX_USE_CXX11_ABI=0'
|
|
||||||
RUNTIME_LINK = 'static'
|
|
||||||
INPUT_PLUGINS = 'all'
|
|
||||||
PATH = '${MASON_LINKED_REL}/bin'
|
|
||||||
PKG_CONFIG_PATH = '${MASON_LINKED_REL}/lib/pkgconfig'
|
|
||||||
PATH_REMOVE = '/usr:/usr/local'
|
|
||||||
PATH_REPLACE = '$HOME/build/mapbox/mason/mason_packages:./mason_packages'
|
|
||||||
BOOST_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
||||||
BOOST_LIBS = '${MASON_LINKED_REL}/lib'
|
|
||||||
ICU_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
||||||
ICU_LIBS = '${MASON_LINKED_REL}/lib'
|
|
||||||
HB_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
||||||
HB_LIBS = '${MASON_LINKED_REL}/lib'
|
|
||||||
PNG_INCLUDES = '${MASON_LINKED_REL}/include/libpng16'
|
|
||||||
PNG_LIBS = '${MASON_LINKED_REL}/lib'
|
|
||||||
JPEG_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
||||||
JPEG_LIBS = '${MASON_LINKED_REL}/lib'
|
|
||||||
TIFF_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
||||||
TIFF_LIBS = '${MASON_LINKED_REL}/lib'
|
|
||||||
WEBP_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
||||||
WEBP_LIBS = '${MASON_LINKED_REL}/lib'
|
|
||||||
PROJ_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
||||||
PROJ_LIBS = '${MASON_LINKED_REL}/lib'
|
|
||||||
PG_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
||||||
PG_LIBS = '${MASON_LINKED_REL}/lib'
|
|
||||||
FREETYPE_INCLUDES = '${MASON_LINKED_REL}/include/freetype2'
|
|
||||||
FREETYPE_LIBS = '${MASON_LINKED_REL}/lib'
|
|
||||||
SVG_RENDERER = True
|
|
||||||
CAIRO_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
||||||
CAIRO_LIBS = '${MASON_LINKED_REL}/lib'
|
|
||||||
SQLITE_INCLUDES = '${MASON_LINKED_REL}/include'
|
|
||||||
SQLITE_LIBS = '${MASON_LINKED_REL}/lib'
|
|
||||||
BENCHMARK = True
|
|
||||||
CPP_TESTS = True
|
|
||||||
PGSQL2SQLITE = True
|
|
||||||
XMLPARSER = 'ptree'
|
|
||||||
SVG2PNG = True
|
|
||||||
"
|
|
||||||
}
|
|
||||||
|
|
||||||
# NOTE: the `mapnik-settings.env` is used by test/run (which is run by `make test`)
|
|
||||||
function setup_runtime_settings() {
|
|
||||||
echo "export PROJ_LIB=${MASON_LINKED_ABS}/share/proj" > mapnik-settings.env
|
|
||||||
echo "export ICU_DATA=${MASON_LINKED_ABS}/share/icu/${ICU_VERSION}" >> mapnik-settings.env
|
|
||||||
echo "export GDAL_DATA=${MASON_LINKED_ABS}/share/gdal" >> mapnik-settings.env
|
|
||||||
source mapnik-settings.env
|
|
||||||
}
|
|
||||||
|
|
||||||
function main() {
|
|
||||||
setup_mason
|
|
||||||
install_mason_deps
|
|
||||||
make_config > ./config.py
|
|
||||||
setup_runtime_settings
|
|
||||||
echo "Ready, now run:"
|
|
||||||
echo ""
|
|
||||||
echo " ./configure && make"
|
|
||||||
}
|
|
||||||
|
|
||||||
main
|
|
||||||
|
|
||||||
# allow sourcing of script without
|
|
||||||
# causing the terminal to bail on error
|
|
||||||
set +eu
|
|
||||||
set +o pipefail
|
|
41
circle.yml
41
circle.yml
|
@ -1,41 +0,0 @@
|
||||||
machine:
|
|
||||||
xcode:
|
|
||||||
version: 7.3
|
|
||||||
environment:
|
|
||||||
XCODE_SCHEME: "no"
|
|
||||||
XCODE_WORKSPACE: "no"
|
|
||||||
JOBS: 8
|
|
||||||
CCACHE_TEMPDIR: /tmp/.ccache-temp
|
|
||||||
CCACHE_COMPRESS: 1
|
|
||||||
LLVM_VERSION: 3.9.1
|
|
||||||
|
|
||||||
checkout:
|
|
||||||
post:
|
|
||||||
- git submodule update --init
|
|
||||||
|
|
||||||
dependencies:
|
|
||||||
cache_directories:
|
|
||||||
- "~/.ccache"
|
|
||||||
- "~/.apt-cache"
|
|
||||||
pre:
|
|
||||||
# https://discuss.circleci.com/t/add-ability-to-cache-apt-get-programs/598/3
|
|
||||||
- sudo rm -rf /var/cache/apt/archives && sudo ln -s ~/.apt-cache /var/cache/apt/archives && mkdir -p ~/.apt-cache/partial
|
|
||||||
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
|
||||||
override:
|
|
||||||
- sudo apt-get update -y
|
|
||||||
- sudo apt-get install -y libstdc++-5-dev xutils-dev
|
|
||||||
|
|
||||||
database:
|
|
||||||
pre:
|
|
||||||
- ./bootstrap.sh
|
|
||||||
- ./.mason/mason install clang++ ${LLVM_VERSION}
|
|
||||||
- ./.mason/mason link clang++ ${LLVM_VERSION}
|
|
||||||
- ./configure CC="$(pwd)/mason_packages/.link/bin/clang" CXX="$(pwd)/mason_packages/.link/bin/ccache $(pwd)/mason_packages/.link/bin/clang++ -Qunused-arguments"
|
|
||||||
- make
|
|
||||||
override:
|
|
||||||
- psql -c 'create database template_postgis;'
|
|
||||||
- psql -c 'create extension postgis;' -d template_postgis
|
|
||||||
|
|
||||||
test:
|
|
||||||
override:
|
|
||||||
- make test
|
|
23
cmake/CheckBoostRegexIcu.cmake
Normal file
23
cmake/CheckBoostRegexIcu.cmake
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
include(CheckCXXSourceRuns)
|
||||||
|
|
||||||
|
function(check_boost_regex)
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES ICU::uc ICU::data ICU::i18n Boost::headers Boost::regex)
|
||||||
|
check_cxx_source_runs([[
|
||||||
|
#include <boost/regex/icu.hpp>
|
||||||
|
#include <unicode/unistr.h>
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
U_NAMESPACE_QUALIFIER UnicodeString ustr;
|
||||||
|
try {
|
||||||
|
boost::u32regex pattern = boost::make_u32regex(ustr);
|
||||||
|
}
|
||||||
|
// an exception is fine, still indicates support is
|
||||||
|
// likely compiled into regex
|
||||||
|
catch (...) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
]] BOOST_REGEX_HAS_ICU)
|
||||||
|
set(BOOST_REGEX_HAS_ICU ${BOOST_REGEX_HAS_ICU} PARENT_SCOPE)
|
||||||
|
endfunction(check_boost_regex)
|
14
cmake/GetVersion.cmake
Normal file
14
cmake/GetVersion.cmake
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
macro(get_mapnik_version)
|
||||||
|
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/include/mapnik/version.hpp VERSION_FILE)
|
||||||
|
|
||||||
|
string(REGEX MATCH "MAPNIK_MAJOR_VERSION ([0-9]*)" _ ${VERSION_FILE})
|
||||||
|
set(MAPNIK_MAJOR_VERSION ${CMAKE_MATCH_1})
|
||||||
|
|
||||||
|
string(REGEX MATCH "MAPNIK_MINOR_VERSION ([0-9]*)" _ ${VERSION_FILE})
|
||||||
|
set(MAPNIK_MINOR_VERSION ${CMAKE_MATCH_1})
|
||||||
|
|
||||||
|
string(REGEX MATCH "MAPNIK_PATCH_VERSION ([0-9]*)" _ ${VERSION_FILE})
|
||||||
|
set(MAPNIK_PATCH_VERSION ${CMAKE_MATCH_1})
|
||||||
|
|
||||||
|
set(MAPNIK_VERSION ${MAPNIK_MAJOR_VERSION}.${MAPNIK_MINOR_VERSION}.${MAPNIK_PATCH_VERSION})
|
||||||
|
endmacro()
|
68
cmake/MapnikExport.cmake
Normal file
68
cmake/MapnikExport.cmake
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
|
||||||
|
### exports mapnik cmake config files (mapnikConfigVersion and mapnikConfig)
|
||||||
|
function(mapnik_export_cmake_config)
|
||||||
|
# export mapnik configuration
|
||||||
|
write_basic_package_version_file(
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfigVersion.cmake"
|
||||||
|
VERSION ${MAPNIK_VERSION}
|
||||||
|
COMPATIBILITY ExactVersion
|
||||||
|
)
|
||||||
|
get_property(MAPNIK_UTILITIES GLOBAL PROPERTY MAPNIK_UTILITIES)
|
||||||
|
|
||||||
|
# generate all find_dependency and pkg_config calls
|
||||||
|
set(mapnik_find_deps)
|
||||||
|
foreach(dep IN LISTS mapnik_deps)
|
||||||
|
set(ver_comment "# ${dep} used with version ${mapnik_${dep}_version}")
|
||||||
|
set(mapnik_find_deps "${mapnik_find_deps}\n${ver_comment}\n")
|
||||||
|
if(mapnik_${dep}_find_args)
|
||||||
|
list(REMOVE_DUPLICATES mapnik_${dep}_find_args)
|
||||||
|
list(JOIN mapnik_${dep}_find_args " " m_args_joined)
|
||||||
|
set(mapnik_find_deps "${mapnik_find_deps}find_dependency(${dep} ${m_args_joined})")
|
||||||
|
else()
|
||||||
|
list(JOIN mapnik_${dep}_pkg_args " " m_args_joined)
|
||||||
|
set(mapnik_find_deps "${mapnik_find_deps}pkg_check_modules(${dep} ${m_args_joined})")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/mapnikConfig.cmake.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfig.cmake"
|
||||||
|
INSTALL_DESTINATION ${MAPNIK_CMAKE_DIR}
|
||||||
|
PATH_VARS MAPNIK_INCLUDE_DIR PLUGINS_INSTALL_DIR FONTS_INSTALL_DIR mapnik_find_deps MAPNIK_UTILITIES
|
||||||
|
NO_CHECK_REQUIRED_COMPONENTS_MACRO
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfig.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfigVersion.cmake"
|
||||||
|
DESTINATION ${MAPNIK_CMAKE_DIR}
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
mapnik_export_cmake_config()
|
||||||
|
|
||||||
|
install(EXPORT MapnikTargets
|
||||||
|
DESTINATION ${MAPNIK_CMAKE_DIR}
|
||||||
|
FILE mapnikTargets.cmake
|
||||||
|
NAMESPACE mapnik::
|
||||||
|
)
|
||||||
|
|
||||||
|
### install plugin cmake config files ###
|
||||||
|
# Create configuration dependend files for the plugin install dirs.
|
||||||
|
# some package managers are using different paths per configuration.
|
||||||
|
string(TOLOWER "${CMAKE_BUILD_TYPE}" _build_type)
|
||||||
|
string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type_l)
|
||||||
|
set(m_mapnik_plugin_file_name mapnikPlugins-${_build_type})
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${m_mapnik_plugin_file_name}.cmake.in" "set(MAPNIK_PLUGINS_DIR_${_build_type_l} \"@PACKAGE_PLUGINS_INSTALL_DIR@\" CACHE STRING \"\")\n")
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
configure_package_config_file(
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${m_mapnik_plugin_file_name}.cmake.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${m_mapnik_plugin_file_name}.cmake"
|
||||||
|
PATH_VARS PLUGINS_INSTALL_DIR
|
||||||
|
INSTALL_DESTINATION ${MAPNIK_CMAKE_DIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES "${CMAKE_CURRENT_BINARY_DIR}/${m_mapnik_plugin_file_name}.cmake"
|
||||||
|
DESTINATION ${MAPNIK_CMAKE_DIR}
|
||||||
|
)
|
92
cmake/MapnikExportPkgConfig.cmake
Normal file
92
cmake/MapnikExportPkgConfig.cmake
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
function(create_pkg_config_file _target _lib_name _description)
|
||||||
|
string(CONFIGURE [[
|
||||||
|
prefix=@CMAKE_INSTALL_PREFIX@
|
||||||
|
exec_prefix=${prefix}
|
||||||
|
includedir=${prefix}/include
|
||||||
|
libdir=${exec_prefix}/@MAPNIK_LIB_DIR@
|
||||||
|
|
||||||
|
Name: @_lib_name@
|
||||||
|
Description: @_description@
|
||||||
|
Version: @MAPNIK_VERSION@
|
||||||
|
Libs: -L"${libdir}" -l$<TARGET_FILE_BASE_NAME:@_target@>$<TARGET_PROPERTY:@_target@,$<CONFIG>_POSTFIX>
|
||||||
|
Cflags: -I"${includedir}" -I"${includedir}/mapnik" ]]
|
||||||
|
_contents @ONLY)
|
||||||
|
|
||||||
|
file(GENERATE
|
||||||
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_lib_name}-$<CONFIG>.pc
|
||||||
|
CONTENT "${_contents}"
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/${_lib_name}-$<CONFIG>.pc
|
||||||
|
DESTINATION ${MAPNIK_PKGCONF_DIR}
|
||||||
|
RENAME ${_lib_name}.pc
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(create_pkg_config_file_mapnik _lib_name _description)
|
||||||
|
get_target_property(m_compile_defs core INTERFACE_COMPILE_DEFINITIONS)
|
||||||
|
string(JOIN " -D" m_str_compile_defs ${m_compile_defs})
|
||||||
|
if(m_str_compile_defs)
|
||||||
|
set(m_str_compile_defs "-D${m_str_compile_defs}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(m_requires
|
||||||
|
libmapnikwkt
|
||||||
|
libmapnikjson
|
||||||
|
icu-uc
|
||||||
|
icu-i18n
|
||||||
|
harfbuzz
|
||||||
|
freetype2
|
||||||
|
)
|
||||||
|
if(USE_LIBXML2)
|
||||||
|
list(APPEND m_requires libxml-2.0)
|
||||||
|
endif()
|
||||||
|
if(USE_PNG)
|
||||||
|
list(APPEND m_requires libpng)
|
||||||
|
endif()
|
||||||
|
if(USE_JPEG)
|
||||||
|
list(APPEND m_requires libjpeg)
|
||||||
|
endif()
|
||||||
|
if(USE_TIFF)
|
||||||
|
list(APPEND m_requires libtiff-4)
|
||||||
|
endif()
|
||||||
|
if(USE_WEBP)
|
||||||
|
list(APPEND m_requires libwebp)
|
||||||
|
endif()
|
||||||
|
if(USE_CAIRO)
|
||||||
|
list(APPEND m_requires cairo)
|
||||||
|
endif()
|
||||||
|
if(USE_PROJ)
|
||||||
|
list(APPEND m_requires "proj >= ${PROJ_MIN_VERSION}")
|
||||||
|
endif()
|
||||||
|
string(JOIN " " m_requires ${m_requires})
|
||||||
|
string(CONFIGURE [[
|
||||||
|
prefix=@CMAKE_INSTALL_PREFIX@
|
||||||
|
exec_prefix=${prefix}
|
||||||
|
includedir=${prefix}/include
|
||||||
|
libdir=${exec_prefix}/@MAPNIK_LIB_DIR@
|
||||||
|
fonts_dir=${prefix}/@FONTS_INSTALL_DIR@
|
||||||
|
plugins_dir=${prefix}/@PLUGINS_INSTALL_DIR@
|
||||||
|
|
||||||
|
Name: @_lib_name@
|
||||||
|
Description: @_description@
|
||||||
|
Version: @MAPNIK_VERSION@
|
||||||
|
Requires: @m_requires@
|
||||||
|
Libs: -L"${libdir}" -l$<TARGET_FILE_BASE_NAME:mapnik>$<TARGET_PROPERTY:mapnik,$<CONFIG>_POSTFIX>
|
||||||
|
Cflags: -I"${includedir}" -I"${includedir}/mapnik" -I"${includedir}/mapnik/agg" @m_str_compile_defs@]]
|
||||||
|
_contents @ONLY)
|
||||||
|
file(GENERATE
|
||||||
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_lib_name}-$<CONFIG>.pc
|
||||||
|
CONTENT "${_contents}"
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/${_lib_name}-$<CONFIG>.pc
|
||||||
|
DESTINATION ${MAPNIK_PKGCONF_DIR}
|
||||||
|
RENAME ${_lib_name}.pc
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
create_pkg_config_file(wkt libmapnikwkt "wkt library")
|
||||||
|
create_pkg_config_file(json libmapnikjson "json library")
|
||||||
|
create_pkg_config_file_mapnik("libmapnik" "mapnik library")
|
64
cmake/MapnikFindPackage.cmake
Normal file
64
cmake/MapnikFindPackage.cmake
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
function(mapnik_set_dep_version dep var)
|
||||||
|
string(TOUPPER ${dep} m_package_name_upc)
|
||||||
|
set(m_package_name ${dep})
|
||||||
|
if(${m_package_name}_VERSION_STRING)
|
||||||
|
set(${var} ${${m_package_name}_VERSION_STRING} PARENT_SCOPE)
|
||||||
|
elseif(${m_package_name}_VERSION)
|
||||||
|
set(${var} ${${m_package_name}_VERSION} PARENT_SCOPE)
|
||||||
|
elseif(${m_package_name_upc}_VERSION_STRING)
|
||||||
|
set(${var} ${${m_package_name_upc}_VERSION_STRING} PARENT_SCOPE)
|
||||||
|
elseif(${m_package_name_upc}_VERSION)
|
||||||
|
set(${var} ${${m_package_name_upc}_VERSION} PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(mapnik_print_package_info dep)
|
||||||
|
message(STATUS "Using ${dep} version: ${mapnik_${dep}_version}")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
macro(mapnik_find_package dep)
|
||||||
|
find_package(${dep} ${ARGN})
|
||||||
|
if(${dep}_FOUND)
|
||||||
|
list(APPEND mapnik_deps ${dep})
|
||||||
|
|
||||||
|
if(mapnik_${dep}_find_args)
|
||||||
|
list(APPEND mapnik_${dep}_find_args ${ARGN})
|
||||||
|
else()
|
||||||
|
set(mapnik_${dep}_find_args ${ARGN})
|
||||||
|
endif()
|
||||||
|
mapnik_set_dep_version(${dep} mapnik_${dep}_version)
|
||||||
|
|
||||||
|
mapnik_print_package_info(${dep})
|
||||||
|
else()
|
||||||
|
message(STATUS "not found: ${dep}")
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
macro(mapnik_pkg_check_modules dep)
|
||||||
|
pkg_check_modules(${dep} ${ARGN})
|
||||||
|
if(${dep}_FOUND)
|
||||||
|
list(APPEND mapnik_deps ${dep})
|
||||||
|
|
||||||
|
set(mapnik_${dep}_pkg_args ${ARGN})
|
||||||
|
mapnik_set_dep_version(${dep} mapnik_${dep}_version)
|
||||||
|
|
||||||
|
mapnik_print_package_info(${dep})
|
||||||
|
else()
|
||||||
|
message(STATUS "not found: ${dep}")
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
macro(mapnik_find_threads)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
if(CMAKE_THREAD_LIBS_INIT)
|
||||||
|
message(STATUS "Using Threads (system libraries)")
|
||||||
|
elseif(CMAKE_USE_WIN32_THREADS_INIT)
|
||||||
|
message(STATUS "Using Threads (win32 threads)")
|
||||||
|
elseif(CMAKE_USE_PTHREADS_INIT)
|
||||||
|
message(STATUS "Using Threads (pthread)")
|
||||||
|
elseif(CMAKE_HP_PTHREADS_INIT)
|
||||||
|
message(STATUS "Using Threads (HP thread)")
|
||||||
|
else()
|
||||||
|
message(STATUS "Using Threads (unknown backend)")
|
||||||
|
endif()
|
||||||
|
endmacro()
|
98
cmake/MapnikInstall.cmake
Normal file
98
cmake/MapnikInstall.cmake
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
#
|
||||||
|
# Install library targets that consuming users need.
|
||||||
|
#
|
||||||
|
function(mapnik_install _target)
|
||||||
|
install(TARGETS ${_target}
|
||||||
|
EXPORT MapnikTargets
|
||||||
|
INCLUDES DESTINATION ${MAPNIK_INCLUDE_DIR}
|
||||||
|
RUNTIME DESTINATION ${MAPNIK_BIN_DIR}
|
||||||
|
COMPONENT MapnikRuntime
|
||||||
|
LIBRARY DESTINATION ${MAPNIK_LIB_DIR}
|
||||||
|
COMPONENT MapnikRuntime
|
||||||
|
NAMELINK_COMPONENT MapnikDevelopment
|
||||||
|
ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR}
|
||||||
|
COMPONENT MapnikDevelopment
|
||||||
|
)
|
||||||
|
get_target_property(TARGET_TYPE "${_target}" TYPE)
|
||||||
|
if (TARGET_TYPE STREQUAL "SHARED_LIBRARY")
|
||||||
|
set_property(GLOBAL APPEND PROPERTY TARGETS ${_target})
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Install plugins
|
||||||
|
#
|
||||||
|
function(mapnik_install_plugin _target)
|
||||||
|
if(NOT BUILD_SHARED_PLUGINS)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
install(TARGETS ${_target}
|
||||||
|
RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR}
|
||||||
|
COMPONENT MapnikPluginRuntime
|
||||||
|
LIBRARY DESTINATION ${PLUGINS_INSTALL_DIR}
|
||||||
|
COMPONENT MapnikPluginRuntime
|
||||||
|
NAMELINK_COMPONENT MapnikPluginDevelopment
|
||||||
|
ARCHIVE DESTINATION ${PLUGINS_INSTALL_DIR}
|
||||||
|
COMPONENT MapnikPluginDevelopment
|
||||||
|
)
|
||||||
|
set_property(GLOBAL APPEND PROPERTY PLUGINS ${_target})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Install executables. These are available via COMPONENTS in find_package
|
||||||
|
#
|
||||||
|
function(mapnik_install_utility _target)
|
||||||
|
set(_target_name "mapnikUtilityTargets_${_target}")
|
||||||
|
install(TARGETS ${_target}
|
||||||
|
EXPORT ${_target_name}
|
||||||
|
INCLUDES DESTINATION ${MAPNIK_INCLUDE_DIR}
|
||||||
|
RUNTIME DESTINATION ${MAPNIK_BIN_DIR}
|
||||||
|
COMPONENT MapnikRuntime
|
||||||
|
LIBRARY DESTINATION ${MAPNIK_LIB_DIR}
|
||||||
|
COMPONENT MapnikRuntime
|
||||||
|
NAMELINK_COMPONENT MapnikDevelopment
|
||||||
|
ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR}
|
||||||
|
COMPONENT MapnikDevelopment
|
||||||
|
)
|
||||||
|
install(EXPORT ${_target_name}
|
||||||
|
FILE ${_target_name}.cmake
|
||||||
|
NAMESPACE mapnik::
|
||||||
|
DESTINATION ${MAPNIK_CMAKE_DIR}
|
||||||
|
)
|
||||||
|
set_property(GLOBAL APPEND PROPERTY MAPNIK_UTILITIES ${_target})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(mapnik_install_targets)
|
||||||
|
if(INSTALL_DEPENDENCIES AND WIN32)
|
||||||
|
# https://cmake.org/cmake/help/latest/policy/CMP0087.html
|
||||||
|
cmake_policy(SET CMP0087 NEW)
|
||||||
|
get_property(_installed_utilities GLOBAL PROPERTY MAPNIK_UTILITIES)
|
||||||
|
get_property(_installed_targets GLOBAL PROPERTY TARGETS)
|
||||||
|
get_property(_installed_plugins GLOBAL PROPERTY PLUGINS)
|
||||||
|
set(_internal_executables "")
|
||||||
|
set(_internal_libraries "")
|
||||||
|
|
||||||
|
foreach(_target IN LISTS _installed_utilities)
|
||||||
|
list(APPEND _internal_executables "\${CMAKE_INSTALL_PREFIX}/${MAPNIK_BIN_DIR}/$<TARGET_FILE_NAME:${_target}>")
|
||||||
|
endforeach()
|
||||||
|
foreach(_target IN LISTS _installed_targets)
|
||||||
|
list(APPEND _internal_libraries "\${CMAKE_INSTALL_PREFIX}/${MAPNIK_BIN_DIR}/$<TARGET_FILE_NAME:${_target}>")
|
||||||
|
endforeach()
|
||||||
|
foreach(_target IN LISTS _installed_plugins)
|
||||||
|
list(APPEND _internal_libraries "\${CMAKE_INSTALL_PREFIX}/${PLUGINS_INSTALL_DIR}/$<TARGET_FILE_NAME:${_target}>")
|
||||||
|
endforeach()
|
||||||
|
# all other executables get auto detected and fixed.
|
||||||
|
if(_internal_executables)
|
||||||
|
list(GET _internal_executables 0 _internal_executables)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
INSTALL(CODE "
|
||||||
|
message(STATUS \"internal_executables: ${_internal_executables}\")
|
||||||
|
message(STATUS \"internal_libraries: ${_internal_libraries}\")
|
||||||
|
message(STATUS \"ADDITIONAL_LIBARIES_PATHS: ${ADDITIONAL_LIBARIES_PATHS}\")
|
||||||
|
|
||||||
|
include(BundleUtilities)
|
||||||
|
fixup_bundle(\"${_internal_executables}\" \"${_internal_libraries}\" \"${ADDITIONAL_LIBARIES_PATHS}\")
|
||||||
|
" COMPONENT MapnikRuntime)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
3
cmake/MapnikMinimumVersions.cmake
Normal file
3
cmake/MapnikMinimumVersions.cmake
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
set(BOOST_MIN_VERSION 1.73)
|
||||||
|
set(HARFBUZZ_MIN_VERSION 0.9.34)
|
||||||
|
set(PROJ_MIN_VERSION 7.2.0)
|
4
cmake/MapnikOption.cmake
Normal file
4
cmake/MapnikOption.cmake
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
macro(mapnik_option option_name option_description option_default_value)
|
||||||
|
option(${option_name} "${option_description}" ${option_default_value})
|
||||||
|
add_feature_info(${option_name} ${option_name} "${option_description}")
|
||||||
|
endmacro()
|
16
cmake/clang-format.cmake
Normal file
16
cmake/clang-format.cmake
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
function(format_dir dir)
|
||||||
|
file(GLOB_RECURSE sources
|
||||||
|
"${dir}/*.cpp"
|
||||||
|
"${dir}/*.hpp"
|
||||||
|
)
|
||||||
|
execute_process(COMMAND clang-format -style=file -i ${sources})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
format_dir(benchmark)
|
||||||
|
format_dir(demo)
|
||||||
|
format_dir(include)
|
||||||
|
format_dir(plugins)
|
||||||
|
format_dir(src)
|
||||||
|
format_dir(test)
|
||||||
|
format_dir(utils)
|
52
cmake/mapnikConfig.cmake.in
Normal file
52
cmake/mapnikConfig.cmake.in
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
set_and_check(MAPNIK_INCLUDE_DIR "@PACKAGE_MAPNIK_INCLUDE_DIR@" CACHE STRING "")
|
||||||
|
set_and_check(MAPNIK_FONTS_DIR "@PACKAGE_FONTS_INSTALL_DIR@" CACHE STRING "")
|
||||||
|
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/Modules/")
|
||||||
|
|
||||||
|
include(CMakeFindDependencyMacro)
|
||||||
|
|
||||||
|
find_dependency(Threads REQUIRED)
|
||||||
|
@mapnik_find_deps@
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/mapnikTargets.cmake")
|
||||||
|
|
||||||
|
set(_supported_components @MAPNIK_UTILITIES@)
|
||||||
|
foreach(_comp ${mapnik_FIND_COMPONENTS})
|
||||||
|
if (NOT _comp IN_LIST _supported_components)
|
||||||
|
set(mapnik_FOUND False)
|
||||||
|
set(mapnik_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
|
||||||
|
endif()
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/mapnikUtilityTargets_${_comp}.cmake")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
|
||||||
|
get_filename_component(_plugin_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
|
file(GLOB CONFIG_FILES "${_plugin_dir}/mapnikPlugins-*.cmake")
|
||||||
|
foreach(f ${CONFIG_FILES})
|
||||||
|
include(${f})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
function(mapnik_find_plugin_dir PLUGIN_DIR)
|
||||||
|
string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type_l)
|
||||||
|
set(_plugin_dir "${MAPNIK_PLUGINS_DIR_${_build_type_l}}")
|
||||||
|
# only release has more then one configuration
|
||||||
|
if(NOT _plugin_dir)
|
||||||
|
set(_all_rel_cfgs RELEASE RELWITHDEBINFO MINSIZEREL)
|
||||||
|
list(FIND _all_rel_cfgs ${_build_type_l} _is_rel_cfg)
|
||||||
|
# check if the current configuration is a known release configuration
|
||||||
|
if(${_is_rel_cfg} GREATER_EQUAL 0)
|
||||||
|
foreach(_rel_cfg IN LISTS _all_rel_cfgs)
|
||||||
|
set(_plugin_dir "${MAPNIK_PLUGINS_DIR_${_rel_cfg}}")
|
||||||
|
if(_plugin_dir)
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if(NOT _plugin_dir)
|
||||||
|
message(WARNING "Could not find a plugin install dir for configuration ${_build_type_l}")
|
||||||
|
endif()
|
||||||
|
set(${PLUGIN_DIR} ${_plugin_dir} PARENT_SCOPE)
|
||||||
|
endfunction()
|
18
cmake/pack.cmake
Normal file
18
cmake/pack.cmake
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
include(InstallRequiredSystemLibraries)
|
||||||
|
set(CPACK_PACKAGE_NAME "mapnik")
|
||||||
|
set(CPACK_PACKAGE_CONTACT "ubuntu-mathis@outlook.com")
|
||||||
|
set(CPACK_PACKAGE_HOMEPAGE_URL "https://mapnik.org")
|
||||||
|
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
|
||||||
|
set(CPACK_SOURCE_GENERATOR "TGZ")
|
||||||
|
set(CPACK_GENERATOR "DEB;TGZ")
|
||||||
|
set(CPACK_SOURCE_IGNORE_FILES
|
||||||
|
\\.git/
|
||||||
|
build/
|
||||||
|
".*~$"
|
||||||
|
out/
|
||||||
|
\\.vs/
|
||||||
|
\\.vscode/
|
||||||
|
)
|
||||||
|
set(CPACK_VERBATIM_VARIABLES YES)
|
||||||
|
|
||||||
|
include(CPack)
|
33
configure
vendored
33
configure
vendored
|
@ -1,5 +1,32 @@
|
||||||
#!/bin/sh
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
PYTHON=${PYTHON:-python}
|
set -eu
|
||||||
|
|
||||||
$PYTHON scons/scons.py --implicit-deps-changed configure "$@"
|
: ${PYTHON:=python}
|
||||||
|
|
||||||
|
# Only some shells (Bash and Z shell) support arrays. Therefore,
|
||||||
|
# the following code provides an alternative for users calling the script
|
||||||
|
# with shells other than Bash or Z shell (e.g. Debian users using Dash).
|
||||||
|
THE_SHELL=$(basename $SHELL)
|
||||||
|
if [ "$THE_SHELL" != "bash" ] && [ "$THE_SHELL" != "zsh" ]; then
|
||||||
|
if [ -f mapnik-settings.env ]; then
|
||||||
|
echo "WARNING: Reading from mapnik-settings.env is supported with Bash or Z shell only."
|
||||||
|
fi
|
||||||
|
$PYTHON scons/scons.py --implicit-deps-changed configure "$@"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# mapnik-settings.env is an optional file to store
|
||||||
|
# environment variables that should be used before
|
||||||
|
# running tests like PROJ_LIB, GDAL_DATA, and ICU_DATA
|
||||||
|
# These do not normally need to be set except when
|
||||||
|
# building against binary versions of dependencies like
|
||||||
|
# done via bootstrap.sh
|
||||||
|
|
||||||
|
if [ -f mapnik-settings.env ]; then
|
||||||
|
echo "Inheriting from mapnik-settings.env"
|
||||||
|
. ./mapnik-settings.env
|
||||||
|
VARS=( $(cat mapnik-settings.env) )
|
||||||
|
fi
|
||||||
|
|
||||||
|
$PYTHON scons/scons.py --implicit-deps-changed configure ${VARS[*]:-} "$@"
|
||||||
|
|
7
demo/CMakeLists.txt
Normal file
7
demo/CMakeLists.txt
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
if(BUILD_DEMO_VIEWER)
|
||||||
|
add_subdirectory(viewer)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(BUILD_DEMO_CPP)
|
||||||
|
add_subdirectory(c++)
|
||||||
|
endif()
|
6
demo/c++/CMakeLists.txt
Normal file
6
demo/c++/CMakeLists.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
add_executable(mapnik-demo rundemo.cpp)
|
||||||
|
target_link_libraries(mapnik-demo PRIVATE
|
||||||
|
mapnik::agg
|
||||||
|
mapnik::mapnik
|
||||||
|
ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?)
|
||||||
|
)
|
|
@ -41,7 +41,7 @@ if env['HAS_CAIRO']:
|
||||||
demo_env.Append(CPPDEFINES = '-DHAVE_CAIRO')
|
demo_env.Append(CPPDEFINES = '-DHAVE_CAIRO')
|
||||||
|
|
||||||
libraries = [env['MAPNIK_NAME']]
|
libraries = [env['MAPNIK_NAME']]
|
||||||
libraries.extend(copy(env['LIBMAPNIK_LIBS']))
|
libraries.extend([copy(env['LIBMAPNIK_LIBS']), 'sqlite3', 'pthread'])
|
||||||
rundemo = demo_env.Program('rundemo', source, LIBS=libraries)
|
rundemo = demo_env.Program('rundemo', source, LIBS=libraries)
|
||||||
|
|
||||||
Depends(rundemo, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))
|
Depends(rundemo, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -20,6 +20,7 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <mapnik/mapnik.hpp>
|
||||||
#include <mapnik/map.hpp>
|
#include <mapnik/map.hpp>
|
||||||
#include <mapnik/layer.hpp>
|
#include <mapnik/layer.hpp>
|
||||||
#include <mapnik/rule.hpp>
|
#include <mapnik/rule.hpp>
|
||||||
|
@ -45,19 +46,21 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
int main ( int, char** )
|
|
||||||
{
|
{
|
||||||
using namespace mapnik;
|
using namespace mapnik;
|
||||||
const std::string srs_lcc="+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs";
|
const std::string srs_lcc =
|
||||||
const std::string srs_merc="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over";
|
"+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs";
|
||||||
|
const std::string srs_merc = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 "
|
||||||
try {
|
"+units=m +nadgrids=@null +wktext +no_defs +over";
|
||||||
|
mapnik::setup();
|
||||||
|
try
|
||||||
|
{
|
||||||
std::cout << " running demo ... \n";
|
std::cout << " running demo ... \n";
|
||||||
datasource_cache::instance().register_datasources("plugins/input/");
|
datasource_cache::instance().register_datasources("plugins/input/");
|
||||||
freetype_engine::register_font("fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSans.ttf");
|
freetype_engine::register_font("fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSans.ttf");
|
||||||
|
|
||||||
Map m(800,600);
|
Map m(800, 600);
|
||||||
m.set_background(parse_color("white"));
|
m.set_background(parse_color("white"));
|
||||||
m.set_srs(srs_merc);
|
m.set_srs(srs_merc);
|
||||||
// create styles
|
// create styles
|
||||||
|
@ -93,13 +96,13 @@ int main ( int, char** )
|
||||||
rule r;
|
rule r;
|
||||||
{
|
{
|
||||||
line_symbolizer line_sym;
|
line_symbolizer line_sym;
|
||||||
put(line_sym,keys::stroke,color(0,0,0));
|
put(line_sym, keys::stroke, color(0, 0, 0));
|
||||||
put(line_sym,keys::stroke_width,1.0);
|
put(line_sym, keys::stroke_width, 1.0);
|
||||||
dash_array dash;
|
dash_array dash;
|
||||||
dash.emplace_back(8,4);
|
dash.emplace_back(8, 4);
|
||||||
dash.emplace_back(2,2);
|
dash.emplace_back(2, 2);
|
||||||
dash.emplace_back(2,2);
|
dash.emplace_back(2, 2);
|
||||||
put(line_sym,keys::stroke_dasharray,dash);
|
put(line_sym, keys::stroke_dasharray, dash);
|
||||||
r.append(std::move(line_sym));
|
r.append(std::move(line_sym));
|
||||||
}
|
}
|
||||||
provlines_style.add_rule(std::move(r));
|
provlines_style.add_rule(std::move(r));
|
||||||
|
@ -127,10 +130,10 @@ int main ( int, char** )
|
||||||
r.set_filter(parse_expression("[CLASS] = 3 or [CLASS] = 4"));
|
r.set_filter(parse_expression("[CLASS] = 3 or [CLASS] = 4"));
|
||||||
{
|
{
|
||||||
line_symbolizer line_sym;
|
line_symbolizer line_sym;
|
||||||
put(line_sym,keys::stroke,color(171,158,137));
|
put(line_sym, keys::stroke, color(171, 158, 137));
|
||||||
put(line_sym,keys::stroke_width,2.0);
|
put(line_sym, keys::stroke_width, 2.0);
|
||||||
put(line_sym,keys::stroke_linecap,ROUND_CAP);
|
put(line_sym, keys::stroke_linecap, line_cap_enum::ROUND_CAP);
|
||||||
put(line_sym,keys::stroke_linejoin,ROUND_JOIN);
|
put(line_sym, keys::stroke_linejoin, line_join_enum::ROUND_JOIN);
|
||||||
r.append(std::move(line_sym));
|
r.append(std::move(line_sym));
|
||||||
}
|
}
|
||||||
roads34_style.add_rule(std::move(r));
|
roads34_style.add_rule(std::move(r));
|
||||||
|
@ -144,10 +147,10 @@ int main ( int, char** )
|
||||||
r.set_filter(parse_expression("[CLASS] = 2"));
|
r.set_filter(parse_expression("[CLASS] = 2"));
|
||||||
{
|
{
|
||||||
line_symbolizer line_sym;
|
line_symbolizer line_sym;
|
||||||
put(line_sym,keys::stroke,color(171,158,137));
|
put(line_sym, keys::stroke, color(171, 158, 137));
|
||||||
put(line_sym,keys::stroke_width,4.0);
|
put(line_sym, keys::stroke_width, 4.0);
|
||||||
put(line_sym,keys::stroke_linecap,ROUND_CAP);
|
put(line_sym, keys::stroke_linecap, line_cap_enum::ROUND_CAP);
|
||||||
put(line_sym,keys::stroke_linejoin,ROUND_JOIN);
|
put(line_sym, keys::stroke_linejoin, line_join_enum::ROUND_JOIN);
|
||||||
r.append(std::move(line_sym));
|
r.append(std::move(line_sym));
|
||||||
}
|
}
|
||||||
roads2_style_1.add_rule(std::move(r));
|
roads2_style_1.add_rule(std::move(r));
|
||||||
|
@ -160,10 +163,10 @@ int main ( int, char** )
|
||||||
r.set_filter(parse_expression("[CLASS] = 2"));
|
r.set_filter(parse_expression("[CLASS] = 2"));
|
||||||
{
|
{
|
||||||
line_symbolizer line_sym;
|
line_symbolizer line_sym;
|
||||||
put(line_sym,keys::stroke,color(255,250,115));
|
put(line_sym, keys::stroke, color(255, 250, 115));
|
||||||
put(line_sym,keys::stroke_width,2.0);
|
put(line_sym, keys::stroke_width, 2.0);
|
||||||
put(line_sym,keys::stroke_linecap,ROUND_CAP);
|
put(line_sym, keys::stroke_linecap, line_cap_enum::ROUND_CAP);
|
||||||
put(line_sym,keys::stroke_linejoin,ROUND_JOIN);
|
put(line_sym, keys::stroke_linejoin, line_join_enum::ROUND_JOIN);
|
||||||
r.append(std::move(line_sym));
|
r.append(std::move(line_sym));
|
||||||
}
|
}
|
||||||
roads2_style_2.add_rule(std::move(r));
|
roads2_style_2.add_rule(std::move(r));
|
||||||
|
@ -177,10 +180,10 @@ int main ( int, char** )
|
||||||
r.set_filter(parse_expression("[CLASS] = 1"));
|
r.set_filter(parse_expression("[CLASS] = 1"));
|
||||||
{
|
{
|
||||||
line_symbolizer line_sym;
|
line_symbolizer line_sym;
|
||||||
put(line_sym,keys::stroke,color(188,149,28));
|
put(line_sym, keys::stroke, color(188, 149, 28));
|
||||||
put(line_sym,keys::stroke_width,7.0);
|
put(line_sym, keys::stroke_width, 7.0);
|
||||||
put(line_sym,keys::stroke_linecap,ROUND_CAP);
|
put(line_sym, keys::stroke_linecap, line_cap_enum::ROUND_CAP);
|
||||||
put(line_sym,keys::stroke_linejoin,ROUND_JOIN);
|
put(line_sym, keys::stroke_linejoin, line_join_enum::ROUND_JOIN);
|
||||||
r.append(std::move(line_sym));
|
r.append(std::move(line_sym));
|
||||||
}
|
}
|
||||||
roads1_style_1.add_rule(std::move(r));
|
roads1_style_1.add_rule(std::move(r));
|
||||||
|
@ -193,10 +196,10 @@ int main ( int, char** )
|
||||||
r.set_filter(parse_expression("[CLASS] = 1"));
|
r.set_filter(parse_expression("[CLASS] = 1"));
|
||||||
{
|
{
|
||||||
line_symbolizer line_sym;
|
line_symbolizer line_sym;
|
||||||
put(line_sym,keys::stroke,color(242,191,36));
|
put(line_sym, keys::stroke, color(242, 191, 36));
|
||||||
put(line_sym,keys::stroke_width,5.0);
|
put(line_sym, keys::stroke_width, 5.0);
|
||||||
put(line_sym,keys::stroke_linecap,ROUND_CAP);
|
put(line_sym, keys::stroke_linecap, line_cap_enum::ROUND_CAP);
|
||||||
put(line_sym,keys::stroke_linejoin,ROUND_JOIN);
|
put(line_sym, keys::stroke_linejoin, line_join_enum::ROUND_JOIN);
|
||||||
r.append(std::move(line_sym));
|
r.append(std::move(line_sym));
|
||||||
}
|
}
|
||||||
roads1_style_2.add_rule(std::move(r));
|
roads1_style_2.add_rule(std::move(r));
|
||||||
|
@ -212,10 +215,11 @@ int main ( int, char** )
|
||||||
text_placements_ptr placement_finder = std::make_shared<text_placements_dummy>();
|
text_placements_ptr placement_finder = std::make_shared<text_placements_dummy>();
|
||||||
placement_finder->defaults.format_defaults.face_name = "DejaVu Sans Book";
|
placement_finder->defaults.format_defaults.face_name = "DejaVu Sans Book";
|
||||||
placement_finder->defaults.format_defaults.text_size = 10.0;
|
placement_finder->defaults.format_defaults.text_size = 10.0;
|
||||||
placement_finder->defaults.format_defaults.fill = color(0,0,0);
|
placement_finder->defaults.format_defaults.fill = color(0, 0, 0);
|
||||||
placement_finder->defaults.format_defaults.halo_fill = color(255,255,200);
|
placement_finder->defaults.format_defaults.halo_fill = color(255, 255, 200);
|
||||||
placement_finder->defaults.format_defaults.halo_radius = 1.0;
|
placement_finder->defaults.format_defaults.halo_radius = 1.0;
|
||||||
placement_finder->defaults.set_format_tree(std::make_shared<mapnik::formatting::text_node>(parse_expression("[GEONAME]")));
|
placement_finder->defaults.set_format_tree(
|
||||||
|
std::make_shared<mapnik::formatting::text_node>(parse_expression("[GEONAME]")));
|
||||||
put<text_placements_ptr>(text_sym, keys::text_placements_, placement_finder);
|
put<text_placements_ptr>(text_sym, keys::text_placements_, placement_finder);
|
||||||
r.append(std::move(text_sym));
|
r.append(std::move(text_sym));
|
||||||
}
|
}
|
||||||
|
@ -228,9 +232,9 @@ int main ( int, char** )
|
||||||
// Provincial polygons
|
// Provincial polygons
|
||||||
{
|
{
|
||||||
parameters p;
|
parameters p;
|
||||||
p["type"]="shape";
|
p["type"] = "shape";
|
||||||
p["file"]="demo/data/boundaries";
|
p["file"] = "demo/data/boundaries";
|
||||||
p["encoding"]="utf8";
|
p["encoding"] = "utf8";
|
||||||
|
|
||||||
layer lyr("Provinces");
|
layer lyr("Provinces");
|
||||||
lyr.set_datasource(datasource_cache::instance().create(p));
|
lyr.set_datasource(datasource_cache::instance().create(p));
|
||||||
|
@ -242,8 +246,8 @@ int main ( int, char** )
|
||||||
// Drainage
|
// Drainage
|
||||||
{
|
{
|
||||||
parameters p;
|
parameters p;
|
||||||
p["type"]="shape";
|
p["type"] = "shape";
|
||||||
p["file"]="demo/data/qcdrainage";
|
p["file"] = "demo/data/qcdrainage";
|
||||||
layer lyr("Quebec Hydrography");
|
layer lyr("Quebec Hydrography");
|
||||||
lyr.set_datasource(datasource_cache::instance().create(p));
|
lyr.set_datasource(datasource_cache::instance().create(p));
|
||||||
lyr.set_srs(srs_lcc);
|
lyr.set_srs(srs_lcc);
|
||||||
|
@ -253,8 +257,8 @@ int main ( int, char** )
|
||||||
|
|
||||||
{
|
{
|
||||||
parameters p;
|
parameters p;
|
||||||
p["type"]="shape";
|
p["type"] = "shape";
|
||||||
p["file"]="demo/data/ontdrainage";
|
p["file"] = "demo/data/ontdrainage";
|
||||||
layer lyr("Ontario Hydrography");
|
layer lyr("Ontario Hydrography");
|
||||||
lyr.set_datasource(datasource_cache::instance().create(p));
|
lyr.set_datasource(datasource_cache::instance().create(p));
|
||||||
lyr.set_srs(srs_lcc);
|
lyr.set_srs(srs_lcc);
|
||||||
|
@ -265,8 +269,8 @@ int main ( int, char** )
|
||||||
// Provincial boundaries
|
// Provincial boundaries
|
||||||
{
|
{
|
||||||
parameters p;
|
parameters p;
|
||||||
p["type"]="shape";
|
p["type"] = "shape";
|
||||||
p["file"]="demo/data/boundaries_l";
|
p["file"] = "demo/data/boundaries_l";
|
||||||
layer lyr("Provincial borders");
|
layer lyr("Provincial borders");
|
||||||
lyr.set_srs(srs_lcc);
|
lyr.set_srs(srs_lcc);
|
||||||
lyr.set_datasource(datasource_cache::instance().create(p));
|
lyr.set_datasource(datasource_cache::instance().create(p));
|
||||||
|
@ -277,8 +281,8 @@ int main ( int, char** )
|
||||||
// Roads
|
// Roads
|
||||||
{
|
{
|
||||||
parameters p;
|
parameters p;
|
||||||
p["type"]="shape";
|
p["type"] = "shape";
|
||||||
p["file"]="demo/data/roads";
|
p["file"] = "demo/data/roads";
|
||||||
layer lyr("Roads");
|
layer lyr("Roads");
|
||||||
lyr.set_srs(srs_lcc);
|
lyr.set_srs(srs_lcc);
|
||||||
lyr.set_datasource(datasource_cache::instance().create(p));
|
lyr.set_datasource(datasource_cache::instance().create(p));
|
||||||
|
@ -293,8 +297,8 @@ int main ( int, char** )
|
||||||
// popplaces
|
// popplaces
|
||||||
{
|
{
|
||||||
parameters p;
|
parameters p;
|
||||||
p["type"]="shape";
|
p["type"] = "shape";
|
||||||
p["file"]="demo/data/popplaces";
|
p["file"] = "demo/data/popplaces";
|
||||||
p["encoding"] = "utf8";
|
p["encoding"] = "utf8";
|
||||||
layer lyr("Populated Places");
|
layer lyr("Populated Places");
|
||||||
lyr.set_srs(srs_lcc);
|
lyr.set_srs(srs_lcc);
|
||||||
|
@ -303,28 +307,28 @@ int main ( int, char** )
|
||||||
m.add_layer(lyr);
|
m.add_layer(lyr);
|
||||||
}
|
}
|
||||||
|
|
||||||
m.zoom_to_box(box2d<double>(-8024477.28459,5445190.38849,-7381388.20071,5662941.44855));
|
m.zoom_to_box(box2d<double>(-8024477.28459, 5445190.38849, -7381388.20071, 5662941.44855));
|
||||||
|
|
||||||
image_rgba8 buf(m.width(),m.height());
|
image_rgba8 buf(m.width(), m.height());
|
||||||
agg_renderer<image_rgba8> ren(m,buf);
|
agg_renderer<image_rgba8> ren(m, buf);
|
||||||
ren.apply();
|
ren.apply();
|
||||||
std::string msg("These maps have been rendered using AGG in the current directory:\n");
|
std::string msg("These maps have been rendered using AGG in the current directory:\n");
|
||||||
#ifdef HAVE_JPEG
|
#ifdef HAVE_JPEG
|
||||||
save_to_file(buf,"demo.jpg","jpeg");
|
save_to_file(buf, "demo.jpg", "jpeg");
|
||||||
msg += "- demo.jpg\n";
|
msg += "- demo.jpg\n";
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_PNG
|
#ifdef HAVE_PNG
|
||||||
save_to_file(buf,"demo.png","png");
|
save_to_file(buf, "demo.png", "png");
|
||||||
save_to_file(buf,"demo256.png","png8");
|
save_to_file(buf, "demo256.png", "png8");
|
||||||
msg += "- demo.png\n";
|
msg += "- demo.png\n";
|
||||||
msg += "- demo256.png\n";
|
msg += "- demo256.png\n";
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_TIFF
|
#ifdef HAVE_TIFF
|
||||||
save_to_file(buf,"demo.tif","tiff");
|
save_to_file(buf, "demo.tif", "tiff");
|
||||||
msg += "- demo.tif\n";
|
msg += "- demo.tif\n";
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_WEBP
|
#ifdef HAVE_WEBP
|
||||||
save_to_file(buf,"demo.webp","webp");
|
save_to_file(buf, "demo.webp", "webp");
|
||||||
msg += "- demo.webp\n";
|
msg += "- demo.webp\n";
|
||||||
#endif
|
#endif
|
||||||
msg += "Have a look!\n";
|
msg += "Have a look!\n";
|
||||||
|
@ -332,8 +336,8 @@ int main ( int, char** )
|
||||||
|
|
||||||
#if defined(HAVE_CAIRO)
|
#if defined(HAVE_CAIRO)
|
||||||
// save to pdf/svg files
|
// save to pdf/svg files
|
||||||
save_to_cairo_file(m,"cairo-demo.pdf");
|
save_to_cairo_file(m, "cairo-demo.pdf");
|
||||||
save_to_cairo_file(m,"cairo-demo.svg");
|
save_to_cairo_file(m, "cairo-demo.svg");
|
||||||
|
|
||||||
/* we could also do:
|
/* we could also do:
|
||||||
|
|
||||||
|
@ -342,20 +346,20 @@ int main ( int, char** )
|
||||||
but instead let's build up a surface for more flexibility
|
but instead let's build up a surface for more flexibility
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cairo_surface_ptr image_surface(
|
cairo_surface_ptr image_surface(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, m.width(), m.height()),
|
||||||
cairo_image_surface_create(CAIRO_FORMAT_ARGB32,m.width(),m.height()),
|
|
||||||
cairo_surface_closer());
|
cairo_surface_closer());
|
||||||
double scale_factor = 1.0;
|
double scale_factor = 1.0;
|
||||||
cairo_ptr image_context(create_context(image_surface));
|
cairo_ptr image_context(create_context(image_surface));
|
||||||
mapnik::cairo_renderer<cairo_ptr> png_render(m,image_context,scale_factor);
|
mapnik::cairo_renderer<cairo_ptr> png_render(m, image_context, scale_factor);
|
||||||
png_render.apply();
|
png_render.apply();
|
||||||
// we can now write to png with cairo functionality
|
// we can now write to png with cairo functionality
|
||||||
cairo_surface_write_to_png(&*image_surface, "cairo-demo.png");
|
cairo_surface_write_to_png(&*image_surface, "cairo-demo.png");
|
||||||
// but we can also benefit from quantization by converting
|
// but we can also benefit from quantization by converting
|
||||||
// to a mapnik image object and then saving that
|
// to a mapnik image object and then saving that
|
||||||
mapnik::image_rgba8 im_data(cairo_image_surface_get_width(&*image_surface), cairo_image_surface_get_height(&*image_surface));
|
mapnik::image_rgba8 im_data(cairo_image_surface_get_width(&*image_surface),
|
||||||
|
cairo_image_surface_get_height(&*image_surface));
|
||||||
cairo_image_to_rgba8(im_data, image_surface);
|
cairo_image_to_rgba8(im_data, image_surface);
|
||||||
save_to_file(im_data, "cairo-demo256.png","png8");
|
save_to_file(im_data, "cairo-demo256.png", "png8");
|
||||||
cairo_surface_finish(&*image_surface);
|
cairo_surface_finish(&*image_surface);
|
||||||
|
|
||||||
std::cout << "Three maps have been rendered using Cairo in the current directory:\n"
|
std::cout << "Three maps have been rendered using Cairo in the current directory:\n"
|
||||||
|
@ -368,12 +372,12 @@ int main ( int, char** )
|
||||||
// save map definition (data + style)
|
// save map definition (data + style)
|
||||||
save_map(m, "map.xml");
|
save_map(m, "map.xml");
|
||||||
}
|
}
|
||||||
catch ( std::exception const& ex )
|
catch (std::exception const& ex)
|
||||||
{
|
{
|
||||||
std::cerr << "### std::exception: " << ex.what() << std::endl;
|
std::cerr << "### std::exception: " << ex.what() << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
catch ( ... )
|
catch (...)
|
||||||
{
|
{
|
||||||
std::cerr << "### Unknown exception." << std::endl;
|
std::cerr << "### Unknown exception." << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
64
demo/viewer/CMakeLists.txt
Normal file
64
demo/viewer/CMakeLists.txt
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
|
||||||
|
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
|
||||||
|
|
||||||
|
set(PROJECT_SOURCES
|
||||||
|
about_dialog.cpp
|
||||||
|
info_dialog.cpp
|
||||||
|
layerdelegate.cpp
|
||||||
|
layerlistmodel.cpp
|
||||||
|
layerwidget.cpp
|
||||||
|
layer_info_dialog.cpp
|
||||||
|
main.cpp
|
||||||
|
mainwindow.cpp
|
||||||
|
mapwidget.cpp
|
||||||
|
styles_model.cpp
|
||||||
|
forms/about.ui
|
||||||
|
forms/info.ui
|
||||||
|
forms/layer_info.ui
|
||||||
|
mapnik_viewer.qrc
|
||||||
|
)
|
||||||
|
|
||||||
|
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||||
|
qt_add_executable(mapnik-viewer
|
||||||
|
MANUAL_FINALIZATION
|
||||||
|
${PROJECT_SOURCES}
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
if(ANDROID)
|
||||||
|
add_library(mapnik-viewer SHARED
|
||||||
|
${PROJECT_SOURCES}
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
add_executable(mapnik-viewer
|
||||||
|
${PROJECT_SOURCES}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set_target_properties(mapnik-viewer PROPERTIES
|
||||||
|
AUTOUIC_SEARCH_PATHS forms
|
||||||
|
AUTORCC ON
|
||||||
|
AUTOUIC ON
|
||||||
|
AUTOMOC ON
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(mapnik-viewer PRIVATE
|
||||||
|
Qt${QT_VERSION_MAJOR}::Widgets
|
||||||
|
mapnik::agg
|
||||||
|
mapnik::mapnik
|
||||||
|
ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?)
|
||||||
|
)
|
||||||
|
|
||||||
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini
|
||||||
|
"[mapnik]
|
||||||
|
plugins_dir=${PLUGINS_INSTALL_DIR}
|
||||||
|
fonts/1/dir=${FONTS_INSTALL_DIR}
|
||||||
|
fonts/size=1"
|
||||||
|
)
|
||||||
|
|
||||||
|
if(QT_VERSION_MAJOR EQUAL 6)
|
||||||
|
qt_finalize_executable(mapnik-viewer)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini DESTINATION bin)
|
||||||
|
mapnik_install_utility(mapnik-viewer)
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,11 +17,9 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "about_dialog.hpp"
|
#include "about_dialog.hpp"
|
||||||
|
|
||||||
|
about_dialog::about_dialog(QWidget* parent)
|
||||||
about_dialog::about_dialog(QWidget *parent)
|
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,8 +17,6 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if !defined ABOUT_DIALOG_HPP
|
#if !defined ABOUT_DIALOG_HPP
|
||||||
#define ABOUT_DIALOG_HPP
|
#define ABOUT_DIALOG_HPP
|
||||||
|
|
||||||
|
@ -28,11 +26,11 @@
|
||||||
class about_dialog : public QDialog
|
class about_dialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
about_dialog(QWidget * parent = 0);
|
about_dialog(QWidget* parent = 0);
|
||||||
private:
|
|
||||||
|
private:
|
||||||
Ui::Dialog ui;
|
Ui::Dialog ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // ABOUT_DIALOG_HPP
|
||||||
#endif //ABOUT_DIALOG_HPP
|
|
||||||
|
|
|
@ -43,5 +43,5 @@ ini = ini_template % locals()
|
||||||
open('viewer.ini','w').write(ini)
|
open('viewer.ini','w').write(ini)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.chmod('viewer.ini',0666)
|
os.chmod('viewer.ini',0o666)
|
||||||
except: pass
|
except: pass
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,24 +17,22 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "info_dialog.hpp"
|
#include "info_dialog.hpp"
|
||||||
|
|
||||||
|
info_dialog::info_dialog(QVector<QPair<QString, QString>> const& info, QWidget* parent)
|
||||||
info_dialog::info_dialog(QVector<QPair<QString,QString> > const& info, QWidget *parent)
|
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
ui.tableWidget->setHorizontalHeaderItem(0,new QTableWidgetItem("Name"));
|
ui.tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem("Name"));
|
||||||
ui.tableWidget->setHorizontalHeaderItem(1,new QTableWidgetItem("Value"));
|
ui.tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem("Value"));
|
||||||
|
|
||||||
ui.tableWidget->setRowCount(info.size());
|
ui.tableWidget->setRowCount(info.size());
|
||||||
ui.tableWidget->setColumnCount(2);
|
ui.tableWidget->setColumnCount(2);
|
||||||
for (int i=0;i<info.size();++i)
|
for (int i = 0; i < info.size(); ++i)
|
||||||
{
|
{
|
||||||
QTableWidgetItem *keyItem = new QTableWidgetItem(info[i].first);
|
QTableWidgetItem* keyItem = new QTableWidgetItem(info[i].first);
|
||||||
QTableWidgetItem *valueItem = new QTableWidgetItem(info[i].second);
|
QTableWidgetItem* valueItem = new QTableWidgetItem(info[i].second);
|
||||||
ui.tableWidget->setItem(i,0,keyItem);
|
ui.tableWidget->setItem(i, 0, keyItem);
|
||||||
ui.tableWidget->setItem(i,1,valueItem);
|
ui.tableWidget->setItem(i, 1, valueItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,8 +17,6 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef INFO_DIALOG_HPP
|
#ifndef INFO_DIALOG_HPP
|
||||||
#define INFO_DIALOG_HPP
|
#define INFO_DIALOG_HPP
|
||||||
|
|
||||||
|
@ -29,10 +27,10 @@ class info_dialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
info_dialog(QVector<QPair<QString,QString> > const& info,QWidget * parent = 0);
|
info_dialog(QVector<QPair<QString, QString>> const& info, QWidget* parent = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::InfoDialog ui;
|
Ui::InfoDialog ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // INFO_DIALOG_HPP
|
||||||
#endif //INFO_DIALOG_HPP
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,7 +17,6 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "layer_info_dialog.hpp"
|
#include "layer_info_dialog.hpp"
|
||||||
|
|
||||||
// mapnik
|
// mapnik
|
||||||
|
@ -26,14 +25,13 @@
|
||||||
#include <mapnik/params_impl.hpp>
|
#include <mapnik/params_impl.hpp>
|
||||||
#include <mapnik/layer.hpp>
|
#include <mapnik/layer.hpp>
|
||||||
|
|
||||||
|
layer_info_dialog::layer_info_dialog(mapnik::layer& lay, QWidget* parent)
|
||||||
layer_info_dialog::layer_info_dialog(mapnik::layer& lay, QWidget *parent)
|
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
ui.tableWidget->setHorizontalHeaderItem(0,new QTableWidgetItem("Name"));
|
ui.tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem("Name"));
|
||||||
ui.tableWidget->setHorizontalHeaderItem(1,new QTableWidgetItem("Value"));
|
ui.tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem("Value"));
|
||||||
|
|
||||||
// Layer name
|
// Layer name
|
||||||
ui.layerNameEdit->setText(QString(lay.name().c_str()));
|
ui.layerNameEdit->setText(QString(lay.name().c_str()));
|
||||||
|
@ -50,17 +48,17 @@ layer_info_dialog::layer_info_dialog(mapnik::layer& lay, QWidget *parent)
|
||||||
ui.tableWidget->setColumnCount(2);
|
ui.tableWidget->setColumnCount(2);
|
||||||
|
|
||||||
mapnik::parameters::const_iterator pos;
|
mapnik::parameters::const_iterator pos;
|
||||||
int index=0;
|
int index = 0;
|
||||||
for (pos = ps.begin();pos != ps.end();++pos)
|
for (pos = ps.begin(); pos != ps.end(); ++pos)
|
||||||
{
|
{
|
||||||
boost::optional<std::string> result;
|
std::optional<std::string> result;
|
||||||
mapnik::util::apply_visitor(mapnik::value_extractor_visitor<std::string>(result),pos->second);
|
mapnik::util::apply_visitor(mapnik::value_extractor_visitor<std::string>(result), pos->second);
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
QTableWidgetItem *keyItem = new QTableWidgetItem(QString(pos->first.c_str()));
|
QTableWidgetItem* keyItem = new QTableWidgetItem(QString(pos->first.c_str()));
|
||||||
QTableWidgetItem *valueItem = new QTableWidgetItem(QString((*result).c_str()));
|
QTableWidgetItem* valueItem = new QTableWidgetItem(QString((*result).c_str()));
|
||||||
ui.tableWidget->setItem(index,0,keyItem);
|
ui.tableWidget->setItem(index, 0, keyItem);
|
||||||
ui.tableWidget->setItem(index,1,valueItem);
|
ui.tableWidget->setItem(index, 1, valueItem);
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,16 +17,13 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef LAYER_INFO_DIALOG_HPP
|
#ifndef LAYER_INFO_DIALOG_HPP
|
||||||
#define LAYER_INFO_DIALOG_HPP
|
#define LAYER_INFO_DIALOG_HPP
|
||||||
|
|
||||||
#include "ui_layer_info.h"
|
#include "ui_layer_info.h"
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik {
|
||||||
{
|
|
||||||
class layer;
|
class layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,11 +31,11 @@ class layer_info_dialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
layer_info_dialog(mapnik::layer& l, QWidget * parent = 0);
|
layer_info_dialog(mapnik::layer& l, QWidget* parent = 0);
|
||||||
Ui::LayerInfoDialog& getUI();
|
Ui::LayerInfoDialog& getUI();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::LayerInfoDialog ui;
|
Ui::LayerInfoDialog ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // LAYER_INFO_DIALOG_HPP
|
||||||
#endif //LAYER_INFO_DIALOG_HPP
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,38 +17,32 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "layerdelegate.hpp"
|
#include "layerdelegate.hpp"
|
||||||
|
|
||||||
LayerDelegate::LayerDelegate(QObject *parent)
|
LayerDelegate::LayerDelegate(QObject* parent)
|
||||||
: QAbstractItemDelegate(parent)
|
: QAbstractItemDelegate(parent)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
void LayerDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
void LayerDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||||
const QModelIndex &index) const
|
|
||||||
{
|
{
|
||||||
painter->setRenderHint(QPainter::Antialiasing);
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
painter->setPen(QPen(QColor(255,0,0),1));
|
painter->setPen(QPen(QColor(255, 0, 0), 1));
|
||||||
|
|
||||||
if (option.state & QStyle::State_Selected)
|
if (option.state & QStyle::State_Selected)
|
||||||
painter->setBrush(QBrush(QColor(0, 0, 255, 64)));
|
painter->setBrush(QBrush(QColor(0, 0, 255, 64)));
|
||||||
else
|
else
|
||||||
painter->setBrush(QBrush(QColor(255, 0, 0, 64)));
|
painter->setBrush(QBrush(QColor(255, 0, 0, 64)));
|
||||||
|
|
||||||
|
painter->drawRoundedRect(option.rect, 4, 4);
|
||||||
painter->drawRoundRect(option.rect,4,4);
|
|
||||||
|
|
||||||
if (option.state & QStyle::State_Selected)
|
if (option.state & QStyle::State_Selected)
|
||||||
painter->setBrush(option.palette.highlightedText());
|
painter->setBrush(option.palette.highlightedText());
|
||||||
else
|
else
|
||||||
painter->setBrush(QBrush(QColor(255, 120, 0, 127)));
|
painter->setBrush(QBrush(QColor(255, 120, 0, 127)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize LayerDelegate::sizeHint(const QStyleOptionViewItem & /* option */,
|
QSize LayerDelegate::sizeHint(const QStyleOptionViewItem& /* option */, const QModelIndex& /* index */) const
|
||||||
const QModelIndex & /* index */) const
|
|
||||||
{
|
{
|
||||||
return QSize(120,24);
|
return QSize(120, 24);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -33,12 +33,10 @@ class LayerDelegate : public QAbstractItemDelegate
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LayerDelegate(QObject *parent = 0);
|
LayerDelegate(QObject* parent = 0);
|
||||||
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||||
const QModelIndex &index) const;
|
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||||
QSize sizeHint(const QStyleOptionViewItem &option,
|
|
||||||
const QModelIndex &index ) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //LAYER_DELEGATE_HPP
|
#endif // LAYER_DELEGATE_HPP
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,27 +17,26 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "layerlistmodel.hpp"
|
#include "layerlistmodel.hpp"
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
#include <QBrush>
|
||||||
#include <iostream>
|
|
||||||
#include <mapnik/layer.hpp>
|
#include <mapnik/layer.hpp>
|
||||||
|
|
||||||
using mapnik::Map;
|
using mapnik::Map;
|
||||||
|
|
||||||
LayerListModel::LayerListModel(std::shared_ptr<Map> map,QObject *parent)
|
LayerListModel::LayerListModel(std::shared_ptr<Map> map, QObject* parent)
|
||||||
: QAbstractListModel(parent),
|
: QAbstractListModel(parent)
|
||||||
map_(map) {}
|
, map_(map)
|
||||||
|
{}
|
||||||
|
|
||||||
int LayerListModel::rowCount(QModelIndex const&) const
|
int LayerListModel::rowCount(QModelIndex const&) const
|
||||||
{
|
{
|
||||||
if (map_) return map_->layers().size();
|
if (map_)
|
||||||
|
return map_->layers().size();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant LayerListModel::data(QModelIndex const& index,int role) const
|
QVariant LayerListModel::data(QModelIndex const& index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid() || !map_)
|
if (!index.isValid() || !map_)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@ -64,14 +63,20 @@ QVariant LayerListModel::data(QModelIndex const& index,int role) const
|
||||||
else
|
else
|
||||||
return QVariant(Qt::Unchecked);
|
return QVariant(Qt::Unchecked);
|
||||||
}
|
}
|
||||||
|
else if (role == Qt::ForegroundRole)
|
||||||
|
{
|
||||||
|
if (map_->layers().at(index.row()).active())
|
||||||
|
return QBrush(QColor("black"));
|
||||||
|
else
|
||||||
|
return QBrush(QColor("lightgrey"));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant LayerListModel::headerData(int section, Qt::Orientation orientation,
|
QVariant LayerListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
int role) const
|
|
||||||
{
|
{
|
||||||
if (role != Qt::DisplayRole)
|
if (role != Qt::DisplayRole)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@ -82,15 +87,15 @@ QVariant LayerListModel::headerData(int section, Qt::Orientation orientation,
|
||||||
return QString("TODO Row %1").arg(section);
|
return QString("TODO Row %1").arg(section);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LayerListModel::setData(const QModelIndex &index,
|
bool LayerListModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||||
const QVariant &value, int role)
|
|
||||||
{
|
{
|
||||||
if (!map_) return false;
|
if (!map_)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (index.isValid() && role == Qt::CheckStateRole)
|
if (index.isValid() && role == Qt::CheckStateRole)
|
||||||
{
|
{
|
||||||
int status = value.toInt();
|
int status = value.toInt();
|
||||||
std::vector<mapnik::layer> & layers = const_cast<std::vector<mapnik::layer>& >(map_->layers());
|
std::vector<mapnik::layer>& layers = const_cast<std::vector<mapnik::layer>&>(map_->layers());
|
||||||
layers.at(index.row()).set_active(status);
|
layers.at(index.row()).set_active(status);
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
return true;
|
return true;
|
||||||
|
@ -101,7 +106,6 @@ bool LayerListModel::setData(const QModelIndex &index,
|
||||||
Qt::ItemFlags LayerListModel::flags(QModelIndex const& index) const
|
Qt::ItemFlags LayerListModel::flags(QModelIndex const& index) const
|
||||||
{
|
{
|
||||||
Qt::ItemFlags flags = QAbstractItemModel::flags(index);
|
Qt::ItemFlags flags = QAbstractItemModel::flags(index);
|
||||||
|
|
||||||
if (index.isValid())
|
if (index.isValid())
|
||||||
flags |= Qt::ItemIsUserCheckable;
|
flags |= Qt::ItemIsUserCheckable;
|
||||||
return flags;
|
return flags;
|
||||||
|
@ -111,7 +115,7 @@ boost::optional<mapnik::layer&> LayerListModel::map_layer(int i)
|
||||||
{
|
{
|
||||||
if (map_)
|
if (map_)
|
||||||
{
|
{
|
||||||
std::vector<mapnik::layer> & layers = const_cast<std::vector<mapnik::layer>& >(map_->layers());
|
std::vector<mapnik::layer>& layers = const_cast<std::vector<mapnik::layer>&>(map_->layers());
|
||||||
if (i < int(layers.size()))
|
if (i < int(layers.size()))
|
||||||
return boost::optional<mapnik::layer&>(layers[i]);
|
return boost::optional<mapnik::layer&>(layers[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,8 +17,6 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef LAYER_LIST_MODEL_HPP
|
#ifndef LAYER_LIST_MODEL_HPP
|
||||||
#define LAYER_LIST_MODEL_HPP
|
#define LAYER_LIST_MODEL_HPP
|
||||||
|
|
||||||
|
@ -34,13 +32,11 @@ class LayerListModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
LayerListModel(std::shared_ptr<mapnik::Map> map, QObject * parent = 0);
|
LayerListModel(std::shared_ptr<mapnik::Map> map, QObject* parent = 0);
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
QVariant data(const QModelIndex& index, int role) const;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation,
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||||
int role = Qt::DisplayRole) const;
|
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
|
||||||
bool setData(const QModelIndex &index, const QVariant &value,
|
|
||||||
int role = Qt::EditRole);
|
|
||||||
Qt::ItemFlags flags(QModelIndex const& index) const;
|
Qt::ItemFlags flags(QModelIndex const& index) const;
|
||||||
boost::optional<mapnik::layer&> map_layer(int i);
|
boost::optional<mapnik::layer&> map_layer(int i);
|
||||||
|
|
||||||
|
@ -48,4 +44,4 @@ class LayerListModel : public QAbstractListModel
|
||||||
std::shared_ptr<mapnik::Map> map_;
|
std::shared_ptr<mapnik::Map> map_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //LAYER_LIST_MODEL_HPP
|
#endif // LAYER_LIST_MODEL_HPP
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,7 +17,6 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "layerwidget.hpp"
|
#include "layerwidget.hpp"
|
||||||
#include <qabstractitemdelegate.h>
|
#include <qabstractitemdelegate.h>
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
|
@ -29,35 +28,30 @@
|
||||||
#include <qscrollbar.h>
|
#include <qscrollbar.h>
|
||||||
#include <qrubberband.h>
|
#include <qrubberband.h>
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
#include <iostream>
|
|
||||||
#include "layerlistmodel.hpp"
|
#include "layerlistmodel.hpp"
|
||||||
#include "layer_info_dialog.hpp"
|
#include "layer_info_dialog.hpp"
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
LayerTab::LayerTab(QWidget* parent)
|
LayerTab::LayerTab(QWidget* parent)
|
||||||
: QListView(parent) {}
|
: QListView(parent)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void LayerTab::paintEvent(QPaintEvent* e)
|
||||||
void LayerTab::paintEvent(QPaintEvent *e)
|
|
||||||
{
|
{
|
||||||
QListView::paintEvent(e);
|
QListView::paintEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerTab::dataChanged(const QModelIndex &topLeft,
|
void LayerTab::dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles)
|
||||||
const QModelIndex &bottomRight)
|
|
||||||
{
|
{
|
||||||
QListView::dataChanged(topLeft, bottomRight);
|
|
||||||
qDebug("FIXME : update map view!");
|
|
||||||
emit update_mapwidget();
|
emit update_mapwidget();
|
||||||
|
QListView::dataChanged(topLeft, bottomRight, roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerTab::selectionChanged(const QItemSelection & selected, const QItemSelection &)
|
void LayerTab::selectionChanged(const QItemSelection& selected, const QItemSelection&)
|
||||||
{
|
{
|
||||||
QModelIndexList list = selected.indexes();
|
QModelIndexList list = selected.indexes();
|
||||||
if (list.size() != 0)
|
if (list.size() != 0)
|
||||||
{
|
{
|
||||||
std::cout << "SELECTED LAYER ->" << list[0].row() << "\n";
|
qDebug("SELECTED LAYER -> %d", list[0].row());
|
||||||
emit layerSelected(list[0].row());
|
emit layerSelected(list[0].row());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,33 +62,29 @@ void LayerTab::layerInfo()
|
||||||
QModelIndexList indexes = selectedIndexes();
|
QModelIndexList indexes = selectedIndexes();
|
||||||
if (indexes.size() > 0)
|
if (indexes.size() > 0)
|
||||||
{
|
{
|
||||||
qDebug("id = %d",indexes[0].row());
|
qDebug("id = %d", indexes[0].row());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerTab::layerInfo2(QModelIndex const& index)
|
void LayerTab::layerInfo2(QModelIndex const& index)
|
||||||
{
|
{
|
||||||
qDebug("LayerInfo id = %d",index.row());
|
qDebug("LayerInfo id = %d", index.row());
|
||||||
QVector<QPair<QString,QString> > params;
|
QVector<QPair<QString, QString>> params;
|
||||||
QVector<QString> style_names;
|
QVector<QString> style_names;
|
||||||
unsigned i = index.row();
|
unsigned i = index.row();
|
||||||
LayerListModel * model = static_cast<LayerListModel*>(this->model());
|
LayerListModel* model = static_cast<LayerListModel*>(this->model());
|
||||||
boost::optional<mapnik::layer&> layer = model->map_layer(i);
|
boost::optional<mapnik::layer&> layer = model->map_layer(i);
|
||||||
|
|
||||||
if (layer)
|
if (layer)
|
||||||
{
|
{
|
||||||
layer_info_dialog dlg(*layer,this);
|
layer_info_dialog dlg(*layer, this);
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StyleTab::StyleTab(QWidget*)
|
StyleTab::StyleTab(QWidget*) {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
void StyleTab::contextMenuEvent(QContextMenuEvent* event)
|
||||||
|
|
||||||
void StyleTab::contextMenuEvent(QContextMenuEvent * event )
|
|
||||||
{
|
{
|
||||||
qDebug("test");
|
qDebug("test");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,7 +17,6 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef LAYERWIDGET_HPP
|
#ifndef LAYERWIDGET_HPP
|
||||||
#define LAYERWIDGET_HPP
|
#define LAYERWIDGET_HPP
|
||||||
|
|
||||||
|
@ -29,8 +28,8 @@ class LayerTab : public QListView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
LayerTab(QWidget* parent=0);
|
LayerTab(QWidget* parent = 0);
|
||||||
void paintEvent(QPaintEvent *e);
|
void paintEvent(QPaintEvent* e);
|
||||||
signals:
|
signals:
|
||||||
void update_mapwidget();
|
void update_mapwidget();
|
||||||
void layerSelected(int) const;
|
void layerSelected(int) const;
|
||||||
|
@ -38,17 +37,18 @@ class LayerTab : public QListView
|
||||||
void layerInfo();
|
void layerInfo();
|
||||||
void layerInfo2(QModelIndex const&);
|
void layerInfo2(QModelIndex const&);
|
||||||
protected slots:
|
protected slots:
|
||||||
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
|
void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles);
|
||||||
void selectionChanged(const QItemSelection & selected, const QItemSelection &);
|
void selectionChanged(const QItemSelection& selected, const QItemSelection&);
|
||||||
};
|
};
|
||||||
|
|
||||||
class StyleTab : public QTreeView
|
class StyleTab : public QTreeView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
StyleTab(QWidget* parent=0);
|
StyleTab(QWidget* parent = 0);
|
||||||
protected:
|
|
||||||
void contextMenuEvent(QContextMenuEvent * event );
|
protected:
|
||||||
|
void contextMenuEvent(QContextMenuEvent* event);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,34 +17,36 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// qt
|
// qt
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <mapnik/datasource_cache.hpp>
|
#include <mapnik/datasource_cache.hpp>
|
||||||
#include <mapnik/font_engine_freetype.hpp>
|
#include <mapnik/font_engine_freetype.hpp>
|
||||||
|
#include <mapnik/mapnik.hpp>
|
||||||
#include "mainwindow.hpp"
|
#include "mainwindow.hpp"
|
||||||
|
|
||||||
int main( int argc, char **argv )
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
using mapnik::datasource_cache;
|
using mapnik::datasource_cache;
|
||||||
using mapnik::freetype_engine;
|
using mapnik::freetype_engine;
|
||||||
|
mapnik::setup();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||||
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
#endif
|
||||||
QCoreApplication::setOrganizationName("Mapnik");
|
QCoreApplication::setOrganizationName("Mapnik");
|
||||||
QCoreApplication::setOrganizationDomain("mapnik.org");
|
QCoreApplication::setOrganizationDomain("mapnik.org");
|
||||||
QCoreApplication::setApplicationName("Viewer");
|
QCoreApplication::setApplicationName("Viewer");
|
||||||
QSettings settings("viewer.ini",QSettings::IniFormat);
|
QSettings settings("viewer.ini", QSettings::IniFormat);
|
||||||
|
|
||||||
// register input plug-ins
|
// register input plug-ins
|
||||||
QString plugins_dir = settings.value("mapnik/plugins_dir",
|
QString plugins_dir = settings.value("mapnik/plugins_dir", QVariant("/usr/local/lib/mapnik/input/")).toString();
|
||||||
QVariant("/usr/local/lib/mapnik/input/")).toString();
|
|
||||||
datasource_cache::instance().register_datasources(plugins_dir.toStdString());
|
datasource_cache::instance().register_datasources(plugins_dir.toStdString());
|
||||||
// register fonts
|
// register fonts
|
||||||
int count = settings.beginReadArray("mapnik/fonts");
|
int count = settings.beginReadArray("mapnik/fonts");
|
||||||
for (int index=0; index < count; ++index)
|
for (int index = 0; index < count; ++index)
|
||||||
{
|
{
|
||||||
settings.setArrayIndex(index);
|
settings.setArrayIndex(index);
|
||||||
QString font_dir = settings.value("dir").toString();
|
QString font_dir = settings.value("dir").toString();
|
||||||
|
@ -52,33 +54,37 @@ int main( int argc, char **argv )
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
|
|
||||||
QApplication app( argc, argv );
|
QApplication app(argc, argv);
|
||||||
MainWindow window;
|
MainWindow window;
|
||||||
window.show();
|
window.show();
|
||||||
if (argc > 1) window.open(argv[1]);
|
if (argc > 1)
|
||||||
|
window.open(argv[1]);
|
||||||
if (argc >= 3)
|
if (argc >= 3)
|
||||||
{
|
{
|
||||||
QStringList list = QString(argv[2]).split(",");
|
QStringList list = QString(argv[2]).split(",");
|
||||||
if (list.size()==4)
|
if (list.size() == 4)
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
double x0 = list[0].toDouble(&ok);
|
double x0 = list[0].toDouble(&ok);
|
||||||
double y0 = list[1].toDouble(&ok);
|
double y0 = list[1].toDouble(&ok);
|
||||||
double x1 = list[2].toDouble(&ok);
|
double x1 = list[2].toDouble(&ok);
|
||||||
double y1 = list[3].toDouble(&ok);
|
double y1 = list[3].toDouble(&ok);
|
||||||
if (ok) window.set_default_extent(x0,y0,x1,y1);
|
if (ok)
|
||||||
|
window.set_default_extent(x0, y0, x1, y1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::shared_ptr<mapnik::Map> map = window.get_map();
|
std::shared_ptr<mapnik::Map> map = window.get_map();
|
||||||
if (map) map->zoom_all();
|
if (map)
|
||||||
|
map->zoom_all();
|
||||||
}
|
}
|
||||||
if (argc == 4)
|
if (argc == 4)
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
double scaling_factor = QString(argv[3]).toDouble(&ok);
|
double scaling_factor = QString(argv[3]).toDouble(&ok);
|
||||||
if (ok) window.set_scaling_factor(scaling_factor);
|
if (ok)
|
||||||
|
window.set_scaling_factor(scaling_factor);
|
||||||
}
|
}
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,7 +17,6 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
@ -39,7 +38,7 @@
|
||||||
// mapnik
|
// mapnik
|
||||||
|
|
||||||
#ifndef Q_MOC_RUN // QT moc chokes on BOOST_JOIN
|
#ifndef Q_MOC_RUN // QT moc chokes on BOOST_JOIN
|
||||||
//#include <mapnik/config_error.hpp>
|
// #include <mapnik/config_error.hpp>
|
||||||
#include <mapnik/load_map.hpp>
|
#include <mapnik/load_map.hpp>
|
||||||
#include <mapnik/save_map.hpp>
|
#include <mapnik/save_map.hpp>
|
||||||
#include <mapnik/projection.hpp>
|
#include <mapnik/projection.hpp>
|
||||||
|
@ -58,27 +57,27 @@
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
MainWindow::MainWindow()
|
MainWindow::MainWindow()
|
||||||
: filename_(),
|
: filename_()
|
||||||
default_extent_(-20037508.3428,-20037508.3428,20037508.3428,20037508.3428)
|
, default_extent_(-20037508.3428, -20037508.3428, 20037508.3428, 20037508.3428)
|
||||||
{
|
{
|
||||||
mapWidget_ = new MapWidget(this);
|
mapWidget_ = new MapWidget(this);
|
||||||
QSplitter *splitter = new QSplitter(this);
|
QSplitter* splitter = new QSplitter(this);
|
||||||
QTabWidget *tabWidget=new QTabWidget;
|
QTabWidget* tabWidget = new QTabWidget;
|
||||||
layerTab_ = new LayerTab;
|
layerTab_ = new LayerTab;
|
||||||
layerTab_->setFocusPolicy(Qt::NoFocus);
|
layerTab_->setFocusPolicy(Qt::NoFocus);
|
||||||
layerTab_->setIconSize(QSize(16,16));
|
layerTab_->setIconSize(QSize(16, 16));
|
||||||
|
|
||||||
//LayerDelegate *delegate = new LayerDelegate(this);
|
// LayerDelegate *delegate = new LayerDelegate(this);
|
||||||
//layerTab_->setItemDelegate(delegate);
|
// layerTab_->setItemDelegate(delegate);
|
||||||
//layerTab_->setItemDelegate(new QItemDelegate(this));
|
// layerTab_->setItemDelegate(new QItemDelegate(this));
|
||||||
//layerTab_->setViewMode(QListView::IconMode);
|
// layerTab_->setViewMode(QListView::IconMode);
|
||||||
|
|
||||||
layerTab_->setFlow(QListView::TopToBottom);
|
layerTab_->setFlow(QListView::TopToBottom);
|
||||||
tabWidget->addTab(layerTab_,tr("Layers"));
|
tabWidget->addTab(layerTab_, tr("Layers"));
|
||||||
|
|
||||||
// Styles tab
|
// Styles tab
|
||||||
styleTab_ = new StyleTab;
|
styleTab_ = new StyleTab;
|
||||||
tabWidget->addTab(styleTab_,tr("Styles"));
|
tabWidget->addTab(styleTab_, tr("Styles"));
|
||||||
splitter->addWidget(tabWidget);
|
splitter->addWidget(tabWidget);
|
||||||
splitter->addWidget(mapWidget_);
|
splitter->addWidget(mapWidget_);
|
||||||
QList<int> list;
|
QList<int> list;
|
||||||
|
@ -89,7 +88,7 @@ MainWindow::MainWindow()
|
||||||
mapWidget_->setFocusPolicy(Qt::StrongFocus);
|
mapWidget_->setFocusPolicy(Qt::StrongFocus);
|
||||||
mapWidget_->setFocus();
|
mapWidget_->setFocus();
|
||||||
|
|
||||||
//setCentralWidget(mapWidget_);
|
// setCentralWidget(mapWidget_);
|
||||||
setCentralWidget(splitter);
|
setCentralWidget(splitter);
|
||||||
createActions();
|
createActions();
|
||||||
createMenus();
|
createMenus();
|
||||||
|
@ -97,29 +96,25 @@ MainWindow::MainWindow()
|
||||||
createContextMenu();
|
createContextMenu();
|
||||||
|
|
||||||
setWindowTitle(tr("Mapnik Viewer"));
|
setWindowTitle(tr("Mapnik Viewer"));
|
||||||
status=new QStatusBar(this);
|
status = new QStatusBar(this);
|
||||||
status->showMessage(tr(""));
|
status->showMessage(tr(""));
|
||||||
setStatusBar(status);
|
setStatusBar(status);
|
||||||
resize(800,600);
|
resize(800, 600);
|
||||||
|
|
||||||
//connect mapview to layerlist
|
// connect mapview to layerlist
|
||||||
connect(mapWidget_, SIGNAL(mapViewChanged()),layerTab_, SLOT(update()));
|
connect(mapWidget_, SIGNAL(mapViewChanged()), layerTab_, SLOT(update()));
|
||||||
// slider
|
// slider
|
||||||
connect(slider_,SIGNAL(valueChanged(int)),mapWidget_,SLOT(zoomToLevel(int)));
|
connect(slider_, SIGNAL(valueChanged(int)), mapWidget_, SLOT(zoomToLevel(int)));
|
||||||
// renderer selector
|
// renderer selector
|
||||||
connect(renderer_selector_,SIGNAL(currentIndexChanged(QString const&)),
|
connect(renderer_selector_, SIGNAL(currentIndexChanged(int)), mapWidget_, SLOT(updateRenderer(int)));
|
||||||
mapWidget_, SLOT(updateRenderer(QString const&)));
|
|
||||||
|
|
||||||
// scale factor
|
// scale factor
|
||||||
connect(scale_factor_,SIGNAL(valueChanged(double)),
|
connect(scale_factor_, SIGNAL(valueChanged(double)), mapWidget_, SLOT(updateScaleFactor(double)));
|
||||||
mapWidget_, SLOT(updateScaleFactor(double)));
|
|
||||||
//
|
//
|
||||||
connect(layerTab_,SIGNAL(update_mapwidget()),mapWidget_,SLOT(updateMap()));
|
connect(layerTab_, SIGNAL(update_mapwidget()), mapWidget_, SLOT(updateMap()));
|
||||||
connect(layerTab_,SIGNAL(layerSelected(int)),
|
connect(layerTab_, SIGNAL(layerSelected(int)), mapWidget_, SLOT(layerSelected(int)));
|
||||||
mapWidget_,SLOT(layerSelected(int)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
delete mapWidget_;
|
delete mapWidget_;
|
||||||
|
@ -141,8 +136,7 @@ void MainWindow::open(QString const& path)
|
||||||
{
|
{
|
||||||
if (path.isNull())
|
if (path.isNull())
|
||||||
{
|
{
|
||||||
filename_ = QFileDialog::getOpenFileName(this,tr("Open Mapnik file"),
|
filename_ = QFileDialog::getOpenFileName(this, tr("Open Mapnik file"), currentPath, "*.xml");
|
||||||
currentPath,"*.xml");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -151,18 +145,15 @@ void MainWindow::open(QString const& path)
|
||||||
|
|
||||||
if (!filename_.isEmpty())
|
if (!filename_.isEmpty())
|
||||||
{
|
{
|
||||||
|
|
||||||
load_map_file(filename_);
|
load_map_file(filename_);
|
||||||
setWindowTitle(tr("%1 - Mapnik Viewer").arg(filename_));
|
setWindowTitle(tr("%1 - Mapnik Viewer").arg(filename_));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::reload()
|
void MainWindow::reload()
|
||||||
{
|
{
|
||||||
if (!filename_.isEmpty())
|
if (!filename_.isEmpty())
|
||||||
{
|
{
|
||||||
|
|
||||||
mapnik::box2d<double> bbox = mapWidget_->getMap()->get_current_extent();
|
mapnik::box2d<double> bbox = mapWidget_->getMap()->get_current_extent();
|
||||||
load_map_file(filename_);
|
load_map_file(filename_);
|
||||||
mapWidget_->zoomToBox(bbox);
|
mapWidget_->zoomToBox(bbox);
|
||||||
|
@ -173,28 +164,28 @@ void MainWindow::reload()
|
||||||
void MainWindow::save()
|
void MainWindow::save()
|
||||||
{
|
{
|
||||||
QString initialPath = QDir::currentPath() + "/untitled.xml";
|
QString initialPath = QDir::currentPath() + "/untitled.xml";
|
||||||
QString filename = QFileDialog::getSaveFileName(this, tr("Save"),
|
QString filename = QFileDialog::getSaveFileName(this,
|
||||||
|
tr("Save"),
|
||||||
initialPath,
|
initialPath,
|
||||||
tr("%1 Files (*.xml)")
|
tr("%1 Files (*.xml)").arg(QString("Mapnik definition")));
|
||||||
.arg(QString("Mapnik definition")));
|
|
||||||
if (!filename.isEmpty())
|
if (!filename.isEmpty())
|
||||||
{
|
{
|
||||||
std::cout<<"saving "<< filename.toStdString() << std::endl;
|
std::cout << "saving " << filename.toStdString() << std::endl;
|
||||||
mapnik::save_map(*mapWidget_->getMap(),filename.toStdString());
|
mapnik::save_map(*mapWidget_->getMap(), filename.toStdString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::load_map_file(QString const& filename)
|
void MainWindow::load_map_file(QString const& filename)
|
||||||
{
|
{
|
||||||
std::cout << "loading "<< filename.toStdString() << std::endl;
|
std::cout << "loading " << filename.toStdString() << std::endl;
|
||||||
unsigned width = mapWidget_->width();
|
unsigned width = mapWidget_->width();
|
||||||
unsigned height = mapWidget_->height();
|
unsigned height = mapWidget_->height();
|
||||||
std::shared_ptr<mapnik::Map> map(new mapnik::Map(width,height));
|
std::shared_ptr<mapnik::Map> map(new mapnik::Map(width, height));
|
||||||
mapWidget_->setMap(map);
|
mapWidget_->setMap(map);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mapnik::auto_cpu_timer t(std::clog, "loading map took: ");
|
mapnik::auto_cpu_timer t(std::clog, "loading map took: ");
|
||||||
mapnik::load_map(*map,filename.toStdString());
|
mapnik::load_map(*map, filename.toStdString());
|
||||||
}
|
}
|
||||||
catch (std::exception const& ex)
|
catch (std::exception const& ex)
|
||||||
{
|
{
|
||||||
|
@ -204,8 +195,8 @@ void MainWindow::load_map_file(QString const& filename)
|
||||||
{
|
{
|
||||||
std::cerr << "Exception caught in load_map\n";
|
std::cerr << "Exception caught in load_map\n";
|
||||||
}
|
}
|
||||||
layerTab_->setModel(new LayerListModel(map,this));
|
layerTab_->setModel(new LayerListModel(map, this));
|
||||||
styleTab_->setModel(new StyleModel(map,this));
|
styleTab_->setModel(new StyleModel(map, this));
|
||||||
zoom_all();
|
zoom_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,15 +243,15 @@ void MainWindow::about()
|
||||||
|
|
||||||
void MainWindow::export_as()
|
void MainWindow::export_as()
|
||||||
{
|
{
|
||||||
QAction *action = qobject_cast<QAction *>(sender());
|
QAction* action = qobject_cast<QAction*>(sender());
|
||||||
QByteArray fileFormat = action->data().toByteArray();
|
QByteArray fileFormat = action->data().toByteArray();
|
||||||
QString initialPath = QDir::currentPath() + "/map." + fileFormat;
|
QString initialPath = QDir::currentPath() + "/map." + fileFormat;
|
||||||
|
|
||||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Export As"),
|
QString fileName = QFileDialog::getSaveFileName(
|
||||||
|
this,
|
||||||
|
tr("Export As"),
|
||||||
initialPath,
|
initialPath,
|
||||||
tr("%1 Files (*.%2);;All Files (*)")
|
tr("%1 Files (*.%2);;All Files (*)").arg(QString(fileFormat.toUpper())).arg(QString(fileFormat)));
|
||||||
.arg(QString(fileFormat.toUpper()))
|
|
||||||
.arg(QString(fileFormat)));
|
|
||||||
if (!fileName.isEmpty())
|
if (!fileName.isEmpty())
|
||||||
{
|
{
|
||||||
QPixmap const& pix = mapWidget_->pixmap();
|
QPixmap const& pix = mapWidget_->pixmap();
|
||||||
|
@ -270,10 +261,9 @@ void MainWindow::export_as()
|
||||||
|
|
||||||
void MainWindow::print()
|
void MainWindow::print()
|
||||||
{
|
{
|
||||||
|
// Q_ASSERT(mapWidget_->pixmap());
|
||||||
//Q_ASSERT(mapWidget_->pixmap());
|
// QPrintDialog dialog(&printer, this);
|
||||||
//QPrintDialog dialog(&printer, this);
|
// if (dialog.exec()) {
|
||||||
//if (dialog.exec()) {
|
|
||||||
// QPainter painter(&printer);
|
// QPainter painter(&printer);
|
||||||
// QRect rect = painter.viewport();
|
// QRect rect = painter.viewport();
|
||||||
// QSize size = mapWidget_->pixmap()->size();
|
// QSize size = mapWidget_->pixmap()->size();
|
||||||
|
@ -281,66 +271,66 @@ void MainWindow::print()
|
||||||
// painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
|
// painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
|
||||||
// painter.setWindow(mapWidget_->pixmap()->rect());
|
// painter.setWindow(mapWidget_->pixmap()->rect());
|
||||||
// painter.drawPixmap(0, 0, *mapWidget_->pixmap());
|
// painter.drawPixmap(0, 0, *mapWidget_->pixmap());
|
||||||
//}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::createActions()
|
void MainWindow::createActions()
|
||||||
{
|
{
|
||||||
//exportAct = new QAction(tr("&Export as ..."),this);
|
// exportAct = new QAction(tr("&Export as ..."),this);
|
||||||
//exportAct->setShortcut(tr("Ctrl+E"));
|
// exportAct->setShortcut(tr("Ctrl+E"));
|
||||||
//connect(exportAct, SIGNAL(triggered()), this, SLOT(export_as()));
|
// connect(exportAct, SIGNAL(triggered()), this, SLOT(export_as()));
|
||||||
zoomAllAct = new QAction(QIcon(":/images/home.png"),tr("Zoom All"),this);
|
zoomAllAct = new QAction(QIcon(":/images/home.png"), tr("Zoom All"), this);
|
||||||
connect(zoomAllAct, SIGNAL(triggered()), this, SLOT(zoom_all()));
|
connect(zoomAllAct, SIGNAL(triggered()), this, SLOT(zoom_all()));
|
||||||
|
|
||||||
zoomBoxAct = new QAction(QIcon(":/images/zoombox.png"),tr("Zoom To Box"),this);
|
zoomBoxAct = new QAction(QIcon(":/images/zoombox.png"), tr("Zoom To Box"), this);
|
||||||
zoomBoxAct->setCheckable(true);
|
zoomBoxAct->setCheckable(true);
|
||||||
connect(zoomBoxAct, SIGNAL(triggered()), this, SLOT(zoom_to_box()));
|
connect(zoomBoxAct, SIGNAL(triggered()), this, SLOT(zoom_to_box()));
|
||||||
|
|
||||||
panAct = new QAction(QIcon(":/images/pan.png"),tr("Pan"),this);
|
panAct = new QAction(QIcon(":/images/pan.png"), tr("Pan"), this);
|
||||||
panAct->setCheckable(true);
|
panAct->setCheckable(true);
|
||||||
connect(panAct, SIGNAL(triggered()), this, SLOT(pan()));
|
connect(panAct, SIGNAL(triggered()), this, SLOT(pan()));
|
||||||
|
|
||||||
infoAct = new QAction(QIcon(":/images/info.png"),tr("Info"),this);
|
infoAct = new QAction(QIcon(":/images/info.png"), tr("Info"), this);
|
||||||
infoAct->setCheckable(true);
|
infoAct->setCheckable(true);
|
||||||
connect(infoAct, SIGNAL(triggered()), this, SLOT(info()));
|
connect(infoAct, SIGNAL(triggered()), this, SLOT(info()));
|
||||||
|
|
||||||
toolsGroup=new QActionGroup(this);
|
toolsGroup = new QActionGroup(this);
|
||||||
toolsGroup->addAction(zoomBoxAct);
|
toolsGroup->addAction(zoomBoxAct);
|
||||||
toolsGroup->addAction(panAct);
|
toolsGroup->addAction(panAct);
|
||||||
toolsGroup->addAction(infoAct);
|
toolsGroup->addAction(infoAct);
|
||||||
zoomBoxAct->setChecked(true);
|
zoomBoxAct->setChecked(true);
|
||||||
|
|
||||||
openAct=new QAction(tr("Open Map definition"),this);
|
openAct = new QAction(tr("Open Map definition"), this);
|
||||||
connect(openAct,SIGNAL(triggered()),this,SLOT(open()));
|
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
|
||||||
saveAct=new QAction(tr("Save Map definition"),this);
|
saveAct = new QAction(tr("Save Map definition"), this);
|
||||||
connect(saveAct,SIGNAL(triggered()),this,SLOT(save()));
|
connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
|
||||||
|
|
||||||
panLeftAct = new QAction(QIcon(":/images/left.png"),tr("&Pan Left"),this);
|
panLeftAct = new QAction(QIcon(":/images/left.png"), tr("&Pan Left"), this);
|
||||||
connect(panLeftAct, SIGNAL(triggered()), this, SLOT(pan_left()));
|
connect(panLeftAct, SIGNAL(triggered()), this, SLOT(pan_left()));
|
||||||
panRightAct = new QAction(QIcon(":/images/right.png"),tr("&Pan Right"),this);
|
panRightAct = new QAction(QIcon(":/images/right.png"), tr("&Pan Right"), this);
|
||||||
connect(panRightAct, SIGNAL(triggered()), this, SLOT(pan_right()));
|
connect(panRightAct, SIGNAL(triggered()), this, SLOT(pan_right()));
|
||||||
panUpAct = new QAction(QIcon(":/images/up.png"),tr("&Pan Up"),this);
|
panUpAct = new QAction(QIcon(":/images/up.png"), tr("&Pan Up"), this);
|
||||||
connect(panUpAct, SIGNAL(triggered()), this, SLOT(pan_up()));
|
connect(panUpAct, SIGNAL(triggered()), this, SLOT(pan_up()));
|
||||||
panDownAct = new QAction(QIcon(":/images/down.png"),tr("&Pan Down"),this);
|
panDownAct = new QAction(QIcon(":/images/down.png"), tr("&Pan Down"), this);
|
||||||
connect(panDownAct, SIGNAL(triggered()), this, SLOT(pan_down()));
|
connect(panDownAct, SIGNAL(triggered()), this, SLOT(pan_down()));
|
||||||
|
|
||||||
reloadAct = new QAction(QIcon(":/images/reload.png"),tr("Reload"),this);
|
reloadAct = new QAction(QIcon(":/images/reload.png"), tr("Reload"), this);
|
||||||
connect(reloadAct, SIGNAL(triggered()), this, SLOT(reload()));
|
connect(reloadAct, SIGNAL(triggered()), this, SLOT(reload()));
|
||||||
|
|
||||||
layerInfo = new QAction(QIcon(":/images/info.png"),tr("&Layer info"),layerTab_);
|
layerInfo = new QAction(QIcon(":/images/info.png"), tr("&Layer info"), layerTab_);
|
||||||
connect(layerInfo, SIGNAL(triggered()), layerTab_,SLOT(layerInfo()));
|
connect(layerInfo, SIGNAL(triggered()), layerTab_, SLOT(layerInfo()));
|
||||||
connect(layerTab_, SIGNAL(doubleClicked(QModelIndex const&)), layerTab_,SLOT(layerInfo2(QModelIndex const&)));
|
connect(layerTab_, SIGNAL(doubleClicked(QModelIndex const&)), layerTab_, SLOT(layerInfo2(QModelIndex const&)));
|
||||||
foreach (QByteArray format, QImageWriter::supportedImageFormats())
|
foreach (QByteArray format, QImageWriter::supportedImageFormats())
|
||||||
{
|
{
|
||||||
QString text = tr("%1...").arg(QString(format).toUpper());
|
QString text = tr("%1...").arg(QString(format).toUpper());
|
||||||
|
|
||||||
QAction *action = new QAction(text, this);
|
QAction* action = new QAction(text, this);
|
||||||
action->setData(format);
|
action->setData(format);
|
||||||
connect(action, SIGNAL(triggered()), this, SLOT(export_as()));
|
connect(action, SIGNAL(triggered()), this, SLOT(export_as()));
|
||||||
exportAsActs.append(action);
|
exportAsActs.append(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
printAct = new QAction(QIcon(":/images/print.png"),tr("&Print ..."),this);
|
printAct = new QAction(QIcon(":/images/print.png"), tr("&Print ..."), this);
|
||||||
printAct->setShortcut(tr("Ctrl+E"));
|
printAct->setShortcut(tr("Ctrl+E"));
|
||||||
connect(printAct, SIGNAL(triggered()), this, SLOT(print()));
|
connect(printAct, SIGNAL(triggered()), this, SLOT(print()));
|
||||||
|
|
||||||
|
@ -348,17 +338,17 @@ void MainWindow::createActions()
|
||||||
exitAct->setShortcut(tr("Ctrl+Q"));
|
exitAct->setShortcut(tr("Ctrl+Q"));
|
||||||
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
|
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
|
||||||
|
|
||||||
aboutAct = new QAction(QIcon(":/images/about.png"),tr("&About"), this);
|
aboutAct = new QAction(QIcon(":/images/about.png"), tr("&About"), this);
|
||||||
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
|
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::createMenus()
|
void MainWindow::createMenus()
|
||||||
{
|
{
|
||||||
exportMenu = new QMenu(tr("&Export As"), this);
|
exportMenu = new QMenu(tr("&Export As"), this);
|
||||||
foreach (QAction *action, exportAsActs)
|
foreach (QAction* action, exportAsActs)
|
||||||
exportMenu->addAction(action);
|
exportMenu->addAction(action);
|
||||||
|
|
||||||
fileMenu = new QMenu(tr("&File"),this);
|
fileMenu = new QMenu(tr("&File"), this);
|
||||||
fileMenu->addAction(openAct);
|
fileMenu->addAction(openAct);
|
||||||
fileMenu->addAction(saveAct);
|
fileMenu->addAction(saveAct);
|
||||||
fileMenu->addMenu(exportMenu);
|
fileMenu->addMenu(exportMenu);
|
||||||
|
@ -397,13 +387,13 @@ void MainWindow::createToolBars()
|
||||||
|
|
||||||
scale_factor_ = new QDoubleSpinBox(fileToolBar);
|
scale_factor_ = new QDoubleSpinBox(fileToolBar);
|
||||||
scale_factor_->setMinimum(0.1);
|
scale_factor_->setMinimum(0.1);
|
||||||
scale_factor_->setMaximum(5.0);
|
scale_factor_->setMaximum(10.0);
|
||||||
scale_factor_->setSingleStep(0.1);
|
scale_factor_->setSingleStep(0.1);
|
||||||
scale_factor_->setValue(1.0);
|
scale_factor_->setValue(1.0);
|
||||||
|
|
||||||
fileToolBar->addWidget(scale_factor_);
|
fileToolBar->addWidget(scale_factor_);
|
||||||
slider_ = new QSlider(Qt::Horizontal,fileToolBar);
|
slider_ = new QSlider(Qt::Horizontal, fileToolBar);
|
||||||
slider_->setRange(1,18);
|
slider_->setRange(1, 18);
|
||||||
slider_->setTickPosition(QSlider::TicksBelow);
|
slider_->setTickPosition(QSlider::TicksBelow);
|
||||||
slider_->setTickInterval(1);
|
slider_->setTickInterval(1);
|
||||||
slider_->setTracking(false);
|
slider_->setTracking(false);
|
||||||
|
@ -411,9 +401,7 @@ void MainWindow::createToolBars()
|
||||||
fileToolBar->addAction(aboutAct);
|
fileToolBar->addAction(aboutAct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::set_default_extent(double x0, double y0, double x1, double y1)
|
||||||
|
|
||||||
void MainWindow::set_default_extent(double x0,double y0, double x1, double y1)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -421,14 +409,15 @@ void MainWindow::set_default_extent(double x0,double y0, double x1, double y1)
|
||||||
if (map_ptr)
|
if (map_ptr)
|
||||||
{
|
{
|
||||||
mapnik::projection prj(map_ptr->srs());
|
mapnik::projection prj(map_ptr->srs());
|
||||||
prj.forward(x0,y0);
|
prj.forward(x0, y0);
|
||||||
prj.forward(x1,y1);
|
prj.forward(x1, y1);
|
||||||
default_extent_=mapnik::box2d<double>(x0,y0,x1,y1);
|
default_extent_ = mapnik::box2d<double>(x0, y0, x1, y1);
|
||||||
mapWidget_->zoomToBox(default_extent_);
|
mapWidget_->zoomToBox(default_extent_);
|
||||||
std::cout << "SET DEFAULT EXT\n";
|
std::cout << "SET DEFAULT EXT:" << default_extent_ << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (...) {}
|
catch (...)
|
||||||
|
{}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::set_scaling_factor(double scaling_factor)
|
void MainWindow::set_scaling_factor(double scaling_factor)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,7 +17,6 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef MAINWINDOW_HPP
|
#ifndef MAINWINDOW_HPP
|
||||||
#define MAINWINDOW_HPP
|
#define MAINWINDOW_HPP
|
||||||
|
|
||||||
|
@ -30,7 +29,7 @@
|
||||||
|
|
||||||
#include "mapwidget.hpp"
|
#include "mapwidget.hpp"
|
||||||
|
|
||||||
//using namespace mapnik;
|
// using namespace mapnik;
|
||||||
|
|
||||||
class LayerTab;
|
class LayerTab;
|
||||||
class StyleTab;
|
class StyleTab;
|
||||||
|
@ -44,13 +43,15 @@ class MainWindow : public QMainWindow
|
||||||
public:
|
public:
|
||||||
MainWindow();
|
MainWindow();
|
||||||
virtual ~MainWindow();
|
virtual ~MainWindow();
|
||||||
void set_default_extent(double x0,double y0,double x1, double y1);
|
void set_default_extent(double x0, double y0, double x1, double y1);
|
||||||
void set_scaling_factor(double scaling_factor);
|
void set_scaling_factor(double scaling_factor);
|
||||||
public :
|
|
||||||
|
public:
|
||||||
std::shared_ptr<mapnik::Map> get_map();
|
std::shared_ptr<mapnik::Map> get_map();
|
||||||
protected:
|
|
||||||
|
protected:
|
||||||
void closeEvent(QCloseEvent* event);
|
void closeEvent(QCloseEvent* event);
|
||||||
public slots:
|
public slots:
|
||||||
void zoom_all();
|
void zoom_all();
|
||||||
void zoom_to_box();
|
void zoom_to_box();
|
||||||
void pan();
|
void pan();
|
||||||
|
@ -65,7 +66,8 @@ public slots:
|
||||||
void pan_right();
|
void pan_right();
|
||||||
void pan_up();
|
void pan_up();
|
||||||
void pan_down();
|
void pan_down();
|
||||||
private:
|
|
||||||
|
private:
|
||||||
void createActions();
|
void createActions();
|
||||||
void createMenus();
|
void createMenus();
|
||||||
void createToolBars();
|
void createToolBars();
|
||||||
|
@ -74,43 +76,42 @@ private:
|
||||||
|
|
||||||
QString currentPath;
|
QString currentPath;
|
||||||
QString filename_;
|
QString filename_;
|
||||||
QAbstractItemModel *model;
|
QAbstractItemModel* model;
|
||||||
LayerTab *layerTab_;
|
LayerTab* layerTab_;
|
||||||
StyleTab * styleTab_;
|
StyleTab* styleTab_;
|
||||||
MapWidget * mapWidget_;
|
MapWidget* mapWidget_;
|
||||||
//actions
|
// actions
|
||||||
QList<QAction *> exportAsActs;
|
QList<QAction*> exportAsActs;
|
||||||
QActionGroup *toolsGroup;
|
QActionGroup* toolsGroup;
|
||||||
|
|
||||||
QAction *zoomAllAct;
|
QAction* zoomAllAct;
|
||||||
QAction *zoomBoxAct;
|
QAction* zoomBoxAct;
|
||||||
QAction *panAct;
|
QAction* panAct;
|
||||||
QAction *infoAct;
|
QAction* infoAct;
|
||||||
QAction *openAct;
|
QAction* openAct;
|
||||||
QAction *saveAct;
|
QAction* saveAct;
|
||||||
QAction *printAct;
|
QAction* printAct;
|
||||||
QAction *exitAct;
|
QAction* exitAct;
|
||||||
QAction *aboutAct;
|
QAction* aboutAct;
|
||||||
QAction *panLeftAct;
|
QAction* panLeftAct;
|
||||||
QAction *panRightAct;
|
QAction* panRightAct;
|
||||||
QAction *panUpAct;
|
QAction* panUpAct;
|
||||||
QAction *panDownAct;
|
QAction* panDownAct;
|
||||||
QAction *reloadAct;
|
QAction* reloadAct;
|
||||||
QAction *layerInfo;
|
QAction* layerInfo;
|
||||||
//toolbars
|
// toolbars
|
||||||
QToolBar *fileToolBar;
|
QToolBar* fileToolBar;
|
||||||
QToolBar *editToolBar;
|
QToolBar* editToolBar;
|
||||||
//menus
|
// menus
|
||||||
QMenu *exportMenu;
|
QMenu* exportMenu;
|
||||||
QMenu *fileMenu;
|
QMenu* fileMenu;
|
||||||
QMenu *helpMenu;
|
QMenu* helpMenu;
|
||||||
//status bar
|
// status bar
|
||||||
QStatusBar *status;
|
QStatusBar* status;
|
||||||
QSlider * slider_;
|
QSlider* slider_;
|
||||||
QComboBox * renderer_selector_;
|
QComboBox* renderer_selector_;
|
||||||
QDoubleSpinBox * scale_factor_;
|
QDoubleSpinBox* scale_factor_;
|
||||||
mapnik::box2d<double> default_extent_;
|
mapnik::box2d<double> default_extent_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // MAINWINDOW_HPP
|
||||||
#endif //MAINWINDOW_HPP
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,13 +17,12 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <mapnik/agg_renderer.hpp>
|
#include <mapnik/agg_renderer.hpp>
|
||||||
#include <mapnik/layer.hpp>
|
#include <mapnik/layer.hpp>
|
||||||
#include <mapnik/projection.hpp>
|
#include <mapnik/proj_transform.hpp>
|
||||||
#include <mapnik/scale_denominator.hpp>
|
#include <mapnik/scale_denominator.hpp>
|
||||||
#include <mapnik/view_transform.hpp>
|
#include <mapnik/view_transform.hpp>
|
||||||
#include <mapnik/transform_path_adapter.hpp>
|
#include <mapnik/transform_path_adapter.hpp>
|
||||||
|
@ -41,54 +40,38 @@
|
||||||
#include "mapwidget.hpp"
|
#include "mapwidget.hpp"
|
||||||
#include "info_dialog.hpp"
|
#include "info_dialog.hpp"
|
||||||
|
|
||||||
using mapnik::image_rgba8;
|
|
||||||
using mapnik::Map;
|
|
||||||
using mapnik::layer;
|
|
||||||
using mapnik::box2d;
|
using mapnik::box2d;
|
||||||
using mapnik::coord2d;
|
using mapnik::coord2d;
|
||||||
|
using mapnik::feature_kv_iterator;
|
||||||
using mapnik::feature_ptr;
|
using mapnik::feature_ptr;
|
||||||
using mapnik::view_transform;
|
using mapnik::image_rgba8;
|
||||||
|
using mapnik::layer;
|
||||||
|
using mapnik::Map;
|
||||||
using mapnik::projection;
|
using mapnik::projection;
|
||||||
using mapnik::scale_denominator;
|
using mapnik::scale_denominator;
|
||||||
using mapnik::feature_kv_iterator;
|
using mapnik::view_transform;
|
||||||
|
|
||||||
double scales [] = {279541132.014,
|
double scales[] = {279541132.014, 139770566.007, 69885283.0036, 34942641.5018, 17471320.7509,
|
||||||
139770566.007,
|
8735660.37545, 4367830.18772, 2183915.09386, 1091957.54693, 545978.773466,
|
||||||
69885283.0036,
|
272989.386733, 136494.693366, 68247.3466832, 34123.6733416, 17061.8366708,
|
||||||
34942641.5018,
|
8530.9183354, 4265.4591677, 2132.72958385, 1066.36479192, 533.182395962};
|
||||||
17471320.7509,
|
|
||||||
8735660.37545,
|
|
||||||
4367830.18772,
|
|
||||||
2183915.09386,
|
|
||||||
1091957.54693,
|
|
||||||
545978.773466,
|
|
||||||
272989.386733,
|
|
||||||
136494.693366,
|
|
||||||
68247.3466832,
|
|
||||||
34123.6733416,
|
|
||||||
17061.8366708,
|
|
||||||
8530.9183354,
|
|
||||||
4265.4591677,
|
|
||||||
2132.72958385,
|
|
||||||
1066.36479192,
|
|
||||||
533.182395962};
|
|
||||||
|
|
||||||
MapWidget::MapWidget(QWidget *parent)
|
MapWidget::MapWidget(QWidget* parent)
|
||||||
: QWidget(parent),
|
: QWidget(parent)
|
||||||
map_(),
|
, map_()
|
||||||
selected_(1),
|
, selected_(1)
|
||||||
extent_(),
|
, extent_()
|
||||||
cur_tool_(ZoomToBox),
|
, cur_tool_(ZoomToBox)
|
||||||
start_x_(0),
|
, start_x_(0)
|
||||||
start_y_(0),
|
, start_y_(0)
|
||||||
end_x_(0),
|
, end_x_(0)
|
||||||
end_y_(0),
|
, end_y_(0)
|
||||||
drag_(false),
|
, drag_(false)
|
||||||
first_(true),
|
, first_(true)
|
||||||
pen_(QColor(0,0,255,96)),
|
, pen_(QColor(0, 0, 255, 96))
|
||||||
selectedLayer_(-1),
|
, selectedLayer_(-1)
|
||||||
scaling_factor_(1.0),
|
, scaling_factor_(1.0)
|
||||||
cur_renderer_(AGG)
|
, cur_renderer_(AGG)
|
||||||
{
|
{
|
||||||
pen_.setWidth(3);
|
pen_.setWidth(3);
|
||||||
pen_.setCapStyle(Qt::RoundCap);
|
pen_.setCapStyle(Qt::RoundCap);
|
||||||
|
@ -97,7 +80,7 @@ MapWidget::MapWidget(QWidget *parent)
|
||||||
|
|
||||||
void MapWidget::setTool(eTool tool)
|
void MapWidget::setTool(eTool tool)
|
||||||
{
|
{
|
||||||
cur_tool_=tool;
|
cur_tool_ = tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapWidget::paintEvent(QPaintEvent*)
|
void MapWidget::paintEvent(QPaintEvent*)
|
||||||
|
@ -108,84 +91,86 @@ void MapWidget::paintEvent(QPaintEvent*)
|
||||||
{
|
{
|
||||||
if (cur_tool_ == ZoomToBox)
|
if (cur_tool_ == ZoomToBox)
|
||||||
{
|
{
|
||||||
unsigned width = end_x_-start_x_;
|
unsigned width = end_x_ - start_x_;
|
||||||
unsigned height = end_y_-start_y_;
|
unsigned height = end_y_ - start_y_;
|
||||||
painter.drawPixmap(QPoint(0, 0),pix_);
|
painter.drawPixmap(QPoint(0, 0), pix_);
|
||||||
painter.setPen(pen_);
|
painter.setPen(pen_);
|
||||||
painter.setBrush(QColor(200,200,255,128));
|
painter.setBrush(QColor(200, 200, 255, 128));
|
||||||
painter.drawRect(start_x_,start_y_,width,height);
|
painter.drawRect(start_x_, start_y_, width, height);
|
||||||
}
|
}
|
||||||
else if (cur_tool_ == Pan)
|
else if (cur_tool_ == Pan)
|
||||||
{
|
{
|
||||||
int dx = end_x_-start_x_;
|
int dx = end_x_ - start_x_;
|
||||||
int dy = end_y_-start_y_;
|
int dy = end_y_ - start_y_;
|
||||||
painter.setBrush(QColor(200,200,200,128));
|
painter.setBrush(QColor(200, 200, 200, 128));
|
||||||
painter.drawRect(0,0,width(),height());
|
painter.drawRect(0, 0, width(), height());
|
||||||
painter.drawPixmap(QPoint(dx,dy),pix_);
|
painter.drawPixmap(QPoint(dx, dy), pix_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
painter.drawPixmap(QPoint(0, 0),pix_);
|
painter.drawPixmap(QPoint(0, 0), pix_);
|
||||||
}
|
}
|
||||||
painter.end();
|
painter.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapWidget::resizeEvent(QResizeEvent * ev)
|
void MapWidget::resizeEvent(QResizeEvent* ev)
|
||||||
{
|
{
|
||||||
if (map_)
|
if (map_)
|
||||||
{
|
{
|
||||||
map_->resize(ev->size().width(),ev->size().height());
|
map_->resize(ev->size().width(), ev->size().height());
|
||||||
updateMap();
|
updateMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapWidget::mousePressEvent(QMouseEvent* e)
|
void MapWidget::mousePressEvent(QMouseEvent* e)
|
||||||
{
|
{
|
||||||
if (e->button()==Qt::LeftButton)
|
if (e->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
if (cur_tool_ == ZoomToBox || cur_tool_==Pan)
|
if (cur_tool_ == ZoomToBox || cur_tool_ == Pan)
|
||||||
{
|
{
|
||||||
start_x_ = e->x();
|
start_x_ = e->x();
|
||||||
start_y_ = e->y();
|
start_y_ = e->y();
|
||||||
drag_=true;
|
drag_ = true;
|
||||||
}
|
}
|
||||||
else if (cur_tool_==Info)
|
else if (cur_tool_ == Info)
|
||||||
{
|
{
|
||||||
if (map_)
|
if (map_)
|
||||||
{
|
{
|
||||||
QVector<QPair<QString,QString> > info;
|
QVector<QPair<QString, QString>> info;
|
||||||
|
|
||||||
projection map_proj(map_->srs()); // map projection
|
projection map_proj(map_->srs(), true); // map projection
|
||||||
double scale_denom = scale_denominator(map_->scale(),map_proj.is_geographic());
|
double scale_denom = scale_denominator(map_->scale(), map_proj.is_geographic());
|
||||||
view_transform t(map_->width(),map_->height(),map_->get_current_extent());
|
view_transform t(map_->width(), map_->height(), map_->get_current_extent());
|
||||||
|
|
||||||
for (unsigned index = 0; index < map_->layer_count();++index)
|
for (unsigned index = 0; index < map_->layer_count(); ++index)
|
||||||
{
|
{
|
||||||
if (int(index) != selectedLayer_) continue;
|
if (int(index) != selectedLayer_)
|
||||||
|
continue;
|
||||||
|
|
||||||
layer & layer = map_->layers()[index];
|
layer& layer = map_->layers()[index];
|
||||||
if (!layer.visible(scale_denom)) continue;
|
if (!layer.visible(scale_denom))
|
||||||
|
continue;
|
||||||
std::string name = layer.name();
|
std::string name = layer.name();
|
||||||
double x = e->x();
|
double x = e->x();
|
||||||
double y = e->y();
|
double y = e->y();
|
||||||
std::cout << "query at " << x << "," << y << "\n";
|
std::cout << "query at " << x << "," << y << "\n";
|
||||||
projection layer_proj(layer.srs());
|
projection layer_proj(layer.srs(), true);
|
||||||
mapnik::proj_transform prj_trans(map_proj,layer_proj);
|
mapnik::proj_transform prj_trans(map_proj, layer_proj);
|
||||||
//std::auto_ptr<mapnik::memory_datasource> data(new mapnik::memory_datasource);
|
// std::auto_ptr<mapnik::memory_datasource> data(new mapnik::memory_datasource);
|
||||||
mapnik::featureset_ptr fs = map_->query_map_point(index,x,y);
|
mapnik::featureset_ptr fs = map_->query_map_point(index, x, y);
|
||||||
|
|
||||||
if (fs)
|
if (fs)
|
||||||
{
|
{
|
||||||
feature_ptr feat = fs->next();
|
feature_ptr feat = fs->next();
|
||||||
if (feat)
|
if (feat)
|
||||||
{
|
{
|
||||||
feature_kv_iterator itr(*feat,true);
|
feature_kv_iterator itr(*feat, true);
|
||||||
feature_kv_iterator end(*feat);
|
feature_kv_iterator end(*feat);
|
||||||
|
|
||||||
for ( ;itr!=end; ++itr)
|
for (; itr != end; ++itr)
|
||||||
{
|
{
|
||||||
info.push_back(QPair<QString,QString>(QString(std::get<0>(*itr).c_str()),
|
info.push_back(QPair<QString, QString>(QString(std::get<0>(*itr).c_str()),
|
||||||
std::get<1>(*itr).to_string().c_str()));
|
std::get<1>(*itr).to_string().c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,29 +209,28 @@ void MapWidget::mousePressEvent(QMouseEvent* e)
|
||||||
|
|
||||||
if (info.size() > 0)
|
if (info.size() > 0)
|
||||||
{
|
{
|
||||||
info_dialog info_dlg(info,this);
|
info_dialog info_dlg(info, this);
|
||||||
info_dlg.exec();
|
info_dlg.exec();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove annotation layer
|
// remove annotation layer
|
||||||
map_->layers().erase(remove_if(map_->layers().begin(),
|
map_->layers().erase(
|
||||||
map_->layers().end(),
|
remove_if(map_->layers().begin(), map_->layers().end(), bind(&layer::name, _1) == "*annotations*"),
|
||||||
bind(&layer::name,_1) == "*annotations*")
|
map_->layers().end());
|
||||||
, map_->layers().end());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e->button()==Qt::RightButton)
|
else if (e->button() == Qt::RightButton)
|
||||||
{
|
{
|
||||||
//updateMap();
|
// updateMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapWidget::mouseMoveEvent(QMouseEvent* e)
|
void MapWidget::mouseMoveEvent(QMouseEvent* e)
|
||||||
{
|
{
|
||||||
if (cur_tool_ == ZoomToBox || cur_tool_==Pan)
|
if (cur_tool_ == ZoomToBox || cur_tool_ == Pan)
|
||||||
{
|
{
|
||||||
end_x_ = e->x();
|
end_x_ = e->x();
|
||||||
end_y_ = e->y();
|
end_y_ = e->y();
|
||||||
|
@ -256,31 +240,31 @@ void MapWidget::mouseMoveEvent(QMouseEvent* e)
|
||||||
|
|
||||||
void MapWidget::mouseReleaseEvent(QMouseEvent* e)
|
void MapWidget::mouseReleaseEvent(QMouseEvent* e)
|
||||||
{
|
{
|
||||||
if (e->button()==Qt::LeftButton)
|
if (e->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
end_x_ = e->x();
|
end_x_ = e->x();
|
||||||
end_y_ = e->y();
|
end_y_ = e->y();
|
||||||
if (cur_tool_ == ZoomToBox)
|
if (cur_tool_ == ZoomToBox)
|
||||||
{
|
{
|
||||||
drag_=false;
|
drag_ = false;
|
||||||
if (map_)
|
if (map_)
|
||||||
{
|
{
|
||||||
view_transform t(map_->width(),map_->height(),map_->get_current_extent());
|
view_transform t(map_->width(), map_->height(), map_->get_current_extent());
|
||||||
box2d<double> box = t.backward(box2d<double>(start_x_,start_y_,end_x_,end_y_));
|
box2d<double> box = t.backward(box2d<double>(start_x_, start_y_, end_x_, end_y_));
|
||||||
map_->zoom_to_box(box);
|
map_->zoom_to_box(box);
|
||||||
updateMap();
|
updateMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cur_tool_==Pan)
|
else if (cur_tool_ == Pan)
|
||||||
{
|
{
|
||||||
drag_=false;
|
drag_ = false;
|
||||||
if (map_)
|
if (map_)
|
||||||
{
|
{
|
||||||
int cx = int(0.5 * map_->width());
|
int cx = int(0.5 * map_->width());
|
||||||
int cy = int(0.5 * map_->height());
|
int cy = int(0.5 * map_->height());
|
||||||
int dx = end_x_ - start_x_;
|
int dx = end_x_ - start_x_;
|
||||||
int dy = end_y_ - start_y_;
|
int dy = end_y_ - start_y_;
|
||||||
map_->pan(cx - dx ,cy - dy);
|
map_->pan(cx - dx, cy - dy);
|
||||||
updateMap();
|
updateMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,7 +277,23 @@ void MapWidget::wheelEvent(QWheelEvent* e)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||||
|
QPointF corner(map_->width(), map_->height());
|
||||||
|
QPointF zoomCoords;
|
||||||
|
double zoom;
|
||||||
|
if (e->angleDelta().y() > 0)
|
||||||
|
{
|
||||||
|
zoom = 0.5;
|
||||||
|
QPointF center = corner / 2;
|
||||||
|
QPointF delta = e->position() - center;
|
||||||
|
zoomCoords = zoom * delta + center;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
zoom = 2.0;
|
||||||
|
zoomCoords = corner - e->position();
|
||||||
|
}
|
||||||
|
#else
|
||||||
QPoint corner(map_->width(), map_->height());
|
QPoint corner(map_->width(), map_->height());
|
||||||
QPoint zoomCoords;
|
QPoint zoomCoords;
|
||||||
double zoom;
|
double zoom;
|
||||||
|
@ -309,15 +309,17 @@ void MapWidget::wheelEvent(QWheelEvent* e)
|
||||||
zoom = 2.0;
|
zoom = 2.0;
|
||||||
zoomCoords = corner - e->pos();
|
zoomCoords = corner - e->pos();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
map_->pan_and_zoom(zoomCoords.x(), zoomCoords.y(), zoom);
|
map_->pan_and_zoom(zoomCoords.x(), zoomCoords.y(), zoom);
|
||||||
updateMap();
|
updateMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapWidget::keyPressEvent(QKeyEvent *e)
|
void MapWidget::keyPressEvent(QKeyEvent* e)
|
||||||
{
|
{
|
||||||
std::cout << "key pressed:"<< e->key()<<"\n";
|
std::cout << "key pressed:" << e->key() << "\n";
|
||||||
switch (e->key()) {
|
switch (e->key())
|
||||||
|
{
|
||||||
case Qt::Key_Minus:
|
case Qt::Key_Minus:
|
||||||
zoomOut();
|
zoomOut();
|
||||||
break;
|
break;
|
||||||
|
@ -370,8 +372,6 @@ void MapWidget::keyPressEvent(QKeyEvent *e)
|
||||||
default:
|
default:
|
||||||
QWidget::keyPressEvent(e);
|
QWidget::keyPressEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapWidget::zoomToBox(mapnik::box2d<double> const& bbox)
|
void MapWidget::zoomToBox(mapnik::box2d<double> const& bbox)
|
||||||
|
@ -387,7 +387,7 @@ void MapWidget::defaultView()
|
||||||
{
|
{
|
||||||
if (map_)
|
if (map_)
|
||||||
{
|
{
|
||||||
map_->resize(width(),height());
|
map_->resize(width(), height());
|
||||||
map_->zoom_all();
|
map_->zoom_all();
|
||||||
updateMap();
|
updateMap();
|
||||||
}
|
}
|
||||||
|
@ -415,9 +415,9 @@ void MapWidget::panUp()
|
||||||
{
|
{
|
||||||
if (map_)
|
if (map_)
|
||||||
{
|
{
|
||||||
double cx = 0.5*map_->width();
|
double cx = 0.5 * map_->width();
|
||||||
double cy = 0.5*map_->height();
|
double cy = 0.5 * map_->height();
|
||||||
map_->pan(int(cx),int(cy - cy*0.25));
|
map_->pan(int(cx), int(cy - cy * 0.25));
|
||||||
updateMap();
|
updateMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -426,9 +426,9 @@ void MapWidget::panDown()
|
||||||
{
|
{
|
||||||
if (map_)
|
if (map_)
|
||||||
{
|
{
|
||||||
double cx = 0.5*map_->width();
|
double cx = 0.5 * map_->width();
|
||||||
double cy = 0.5*map_->height();
|
double cy = 0.5 * map_->height();
|
||||||
map_->pan(int(cx),int(cy + cy*0.25));
|
map_->pan(int(cx), int(cy + cy * 0.25));
|
||||||
updateMap();
|
updateMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -437,9 +437,9 @@ void MapWidget::panLeft()
|
||||||
{
|
{
|
||||||
if (map_)
|
if (map_)
|
||||||
{
|
{
|
||||||
double cx = 0.5*map_->width();
|
double cx = 0.5 * map_->width();
|
||||||
double cy = 0.5*map_->height();
|
double cy = 0.5 * map_->height();
|
||||||
map_->pan(int(cx - cx * 0.25),int(cy));
|
map_->pan(int(cx - cx * 0.25), int(cy));
|
||||||
updateMap();
|
updateMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -448,42 +448,41 @@ void MapWidget::panRight()
|
||||||
{
|
{
|
||||||
if (map_)
|
if (map_)
|
||||||
{
|
{
|
||||||
double cx = 0.5*map_->width();
|
double cx = 0.5 * map_->width();
|
||||||
double cy = 0.5*map_->height();
|
double cy = 0.5 * map_->height();
|
||||||
map_->pan(int(cx + cx * 0.25),int(cy));
|
map_->pan(int(cx + cx * 0.25), int(cy));
|
||||||
updateMap();
|
updateMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MapWidget::zoomToLevel(int level)
|
void MapWidget::zoomToLevel(int level)
|
||||||
{
|
{
|
||||||
if ( map_ && level >= 0 && level < 19 )
|
if (map_ && level >= 0 && level < 19)
|
||||||
{
|
{
|
||||||
double scale_denom = scales[level];
|
double scale_denom = scales[level];
|
||||||
std::cerr << "scale denominator = " << scale_denom << "\n";
|
std::cerr << "scale denominator = " << scale_denom << "\n";
|
||||||
mapnik::box2d<double> ext = map_->get_current_extent();
|
mapnik::box2d<double> ext = map_->get_current_extent();
|
||||||
double width = static_cast<double>(map_->width());
|
double width = static_cast<double>(map_->width());
|
||||||
double height= static_cast<double>(map_->height());
|
double height = static_cast<double>(map_->height());
|
||||||
mapnik::coord2d pt = ext.center();
|
mapnik::coord2d pt = ext.center();
|
||||||
|
|
||||||
double res = scale_denom * 0.00028;
|
double res = scale_denom * 0.00028;
|
||||||
|
|
||||||
mapnik::box2d<double> box(pt.x - 0.5 * width * res,
|
mapnik::box2d<double> box(pt.x - 0.5 * width * res,
|
||||||
pt.y - 0.5 * height*res,
|
pt.y - 0.5 * height * res,
|
||||||
pt.x + 0.5 * width * res,
|
pt.x + 0.5 * width * res,
|
||||||
pt.y + 0.5 * height*res);
|
pt.y + 0.5 * height * res);
|
||||||
map_->zoom_to_box(box);
|
map_->zoom_to_box(box);
|
||||||
updateMap();
|
updateMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapWidget::export_to_file(unsigned ,unsigned ,std::string const&,std::string const&)
|
void MapWidget::export_to_file(unsigned, unsigned, std::string const&, std::string const&)
|
||||||
{
|
{
|
||||||
//image_rgba8 image(width,height);
|
// image_rgba8 image(width,height);
|
||||||
//agg_renderer renderer(map,image);
|
// agg_renderer renderer(map,image);
|
||||||
//renderer.apply();
|
// renderer.apply();
|
||||||
//image.saveToFile(filename,type);
|
// image.saveToFile(filename,type);
|
||||||
std::cout << "Export to file .." << std::endl;
|
std::cout << "Export to file .." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,25 +491,25 @@ void MapWidget::set_scaling_factor(double scaling_factor)
|
||||||
scaling_factor_ = scaling_factor;
|
scaling_factor_ = scaling_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void render_agg(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
void render_agg(mapnik::Map const& map, double scaling_factor, QPixmap& pix)
|
||||||
{
|
{
|
||||||
unsigned width=map.width();
|
unsigned width = map.width();
|
||||||
unsigned height=map.height();
|
unsigned height = map.height();
|
||||||
|
|
||||||
image_rgba8 buf(width,height);
|
image_rgba8 buf(width, height);
|
||||||
mapnik::agg_renderer<image_rgba8> ren(map,buf,scaling_factor);
|
mapnik::agg_renderer<image_rgba8> ren(map, buf, scaling_factor);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mapnik::auto_cpu_timer t(std::clog, "rendering took: ");
|
mapnik::auto_cpu_timer t(std::clog, "rendering took: ");
|
||||||
ren.apply();
|
ren.apply();
|
||||||
QImage image((uchar*)buf.data(),width,height,QImage::Format_ARGB32);
|
QImage image((uchar*)buf.data(), width, height, QImage::Format_ARGB32);
|
||||||
pix = QPixmap::fromImage(image.rgbSwapped());
|
pix = QPixmap::fromImage(image.rgbSwapped());
|
||||||
}
|
}
|
||||||
//catch (mapnik::config_error & ex)
|
// catch (mapnik::config_error & ex)
|
||||||
//{
|
//{
|
||||||
// std::cerr << ex.what() << std::endl;
|
// std::cerr << ex.what() << std::endl;
|
||||||
//}
|
// }
|
||||||
catch (std::exception const& ex)
|
catch (std::exception const& ex)
|
||||||
{
|
{
|
||||||
std::cerr << "exception: " << ex.what() << std::endl;
|
std::cerr << "exception: " << ex.what() << std::endl;
|
||||||
|
@ -521,18 +520,16 @@ void render_agg(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void render_grid(mapnik::Map const& map, double scaling_factor, QPixmap& pix)
|
||||||
void render_grid(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
|
||||||
{
|
{
|
||||||
std::cerr << "Not supported" << std::endl;
|
std::cerr << "Not supported" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void render_cairo(mapnik::Map const& map, double scaling_factor, QPixmap& pix)
|
||||||
void render_cairo(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
|
||||||
{
|
{
|
||||||
// FIXME
|
// FIXME
|
||||||
#ifdef HAVE_CAIRO
|
#ifdef HAVE_CAIRO
|
||||||
mapnik::cairo_surface_ptr image_surface(cairo_image_surface_create(CAIRO_FORMAT_ARGB32,map.width(),map.height()),
|
mapnik::cairo_surface_ptr image_surface(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, map.width(), map.height()),
|
||||||
mapnik::cairo_surface_closer());
|
mapnik::cairo_surface_closer());
|
||||||
mapnik::cairo_ptr cairo = mapnik::create_context(image_surface);
|
mapnik::cairo_ptr cairo = mapnik::create_context(image_surface);
|
||||||
if (cairo)
|
if (cairo)
|
||||||
|
@ -543,17 +540,20 @@ void render_cairo(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
||||||
}
|
}
|
||||||
mapnik::image_rgba8 data(map.width(), map.height());
|
mapnik::image_rgba8 data(map.width(), map.height());
|
||||||
mapnik::cairo_image_to_rgba8(data, image_surface);
|
mapnik::cairo_image_to_rgba8(data, image_surface);
|
||||||
QImage image((uchar*)data.bytes(),data.width(),data.height(),QImage::Format_ARGB32);
|
QImage image((uchar*)data.bytes(), data.width(), data.height(), QImage::Format_ARGB32);
|
||||||
pix = QPixmap::fromImage(image.rgbSwapped());
|
pix = QPixmap::fromImage(image.rgbSwapped());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapWidget::updateRenderer(QString const& txt)
|
void MapWidget::updateRenderer(int index)
|
||||||
{
|
{
|
||||||
if (txt == "AGG") cur_renderer_ = AGG;
|
std::cerr << "updateRenderer:" << index << std::endl;
|
||||||
else if (txt == "Cairo") cur_renderer_ = Cairo;
|
if (index == 0)
|
||||||
else if (txt == "Grid") cur_renderer_ = Grid;
|
cur_renderer_ = AGG;
|
||||||
std::cerr << "Update renderer called" << std::endl;
|
else if (index == 1)
|
||||||
|
cur_renderer_ = Cairo;
|
||||||
|
else if (index == 2)
|
||||||
|
cur_renderer_ = Grid;
|
||||||
updateMap();
|
updateMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,7 +567,7 @@ void MapWidget::updateMap()
|
||||||
{
|
{
|
||||||
if (map_)
|
if (map_)
|
||||||
{
|
{
|
||||||
if (cur_renderer_== AGG)
|
if (cur_renderer_ == AGG)
|
||||||
{
|
{
|
||||||
render_agg(*map_, scaling_factor_, pix_);
|
render_agg(*map_, scaling_factor_, pix_);
|
||||||
}
|
}
|
||||||
|
@ -586,14 +586,19 @@ void MapWidget::updateMap()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
projection prj(map_->srs()); // map projection
|
projection prj(map_->srs(), true); // map projection
|
||||||
box2d<double> ext = map_->get_current_extent();
|
box2d<double> ext = map_->get_current_extent();
|
||||||
double x0 = ext.minx();
|
double x0 = ext.minx();
|
||||||
double y0 = ext.miny();
|
double y0 = ext.miny();
|
||||||
double x1 = ext.maxx();
|
double x1 = ext.maxx();
|
||||||
double y1 = ext.maxy();
|
double y1 = ext.maxy();
|
||||||
prj.inverse(x0,y0);
|
double z = 0;
|
||||||
prj.inverse(x1,y1);
|
std::string dest_srs = {"epsg:4326"};
|
||||||
|
mapnik::proj_transform proj_tr(map_->srs(), dest_srs);
|
||||||
|
|
||||||
|
proj_tr.forward(x0, y0, z);
|
||||||
|
proj_tr.forward(x1, y1, z);
|
||||||
|
std::cout << "MAP SIZE:" << map_->width() << "," << map_->height() << std::endl;
|
||||||
std::cout << "BBOX (WGS84): " << x0 << "," << y0 << "," << x1 << "," << y1 << "\n";
|
std::cout << "BBOX (WGS84): " << x0 << "," << y0 << "," << x1 << "," << y1 << "\n";
|
||||||
update();
|
update();
|
||||||
// emit signal to interested widgets
|
// emit signal to interested widgets
|
||||||
|
@ -616,7 +621,6 @@ void MapWidget::setMap(std::shared_ptr<Map> map)
|
||||||
map_ = map;
|
map_ = map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MapWidget::layerSelected(int index)
|
void MapWidget::layerSelected(int index)
|
||||||
{
|
{
|
||||||
selectedLayer_ = index;
|
selectedLayer_ = index;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,7 +17,6 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef MAP_WIDGET_HPP
|
#ifndef MAP_WIDGET_HPP
|
||||||
#define MAP_WIDGET_HPP
|
#define MAP_WIDGET_HPP
|
||||||
|
|
||||||
|
@ -30,7 +29,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
#ifndef Q_MOC_RUN
|
#ifndef Q_MOC_RUN
|
||||||
#include <mapnik/map.hpp>
|
#include <mapnik/map.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
@ -39,22 +37,16 @@ class MapWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum eTool
|
enum eTool {
|
||||||
{
|
|
||||||
ZoomToBox = 1,
|
ZoomToBox = 1,
|
||||||
Pan,
|
Pan,
|
||||||
Info,
|
Info,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum eRenderer
|
enum eRenderer { AGG, Cairo, Grid };
|
||||||
{
|
|
||||||
AGG,
|
|
||||||
Cairo,
|
|
||||||
Grid
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<mapnik::Map> map_;
|
std::shared_ptr<mapnik::Map> map_;
|
||||||
int selected_;
|
int selected_;
|
||||||
QPixmap pix_;
|
QPixmap pix_;
|
||||||
|
@ -70,11 +62,12 @@ private:
|
||||||
int selectedLayer_;
|
int selectedLayer_;
|
||||||
double scaling_factor_;
|
double scaling_factor_;
|
||||||
eRenderer cur_renderer_;
|
eRenderer cur_renderer_;
|
||||||
public:
|
|
||||||
MapWidget(QWidget *parent=0);
|
public:
|
||||||
|
MapWidget(QWidget* parent = 0);
|
||||||
void setTool(eTool tool);
|
void setTool(eTool tool);
|
||||||
std::shared_ptr<mapnik::Map> getMap();
|
std::shared_ptr<mapnik::Map> getMap();
|
||||||
inline QPixmap const& pixmap() const { return pix_;}
|
inline QPixmap const& pixmap() const { return pix_; }
|
||||||
void setMap(std::shared_ptr<mapnik::Map> map);
|
void setMap(std::shared_ptr<mapnik::Map> map);
|
||||||
void defaultView();
|
void defaultView();
|
||||||
void zoomToBox(mapnik::box2d<double> const& box);
|
void zoomToBox(mapnik::box2d<double> const& box);
|
||||||
|
@ -85,26 +78,24 @@ public:
|
||||||
void panUp();
|
void panUp();
|
||||||
void panDown();
|
void panDown();
|
||||||
void set_scaling_factor(double);
|
void set_scaling_factor(double);
|
||||||
public slots:
|
public slots:
|
||||||
void zoomToLevel(int level);
|
void zoomToLevel(int level);
|
||||||
void updateMap();
|
void updateMap();
|
||||||
void layerSelected(int);
|
void layerSelected(int);
|
||||||
void updateRenderer(QString const& txt);
|
void updateRenderer(int);
|
||||||
void updateScaleFactor(double scale_factor);
|
void updateScaleFactor(double scale_factor);
|
||||||
signals:
|
signals:
|
||||||
void mapViewChanged();
|
void mapViewChanged();
|
||||||
protected:
|
|
||||||
|
protected:
|
||||||
void paintEvent(QPaintEvent* ev);
|
void paintEvent(QPaintEvent* ev);
|
||||||
void resizeEvent(QResizeEvent* ev);
|
void resizeEvent(QResizeEvent* ev);
|
||||||
void mousePressEvent(QMouseEvent* e);
|
void mousePressEvent(QMouseEvent* e);
|
||||||
void mouseMoveEvent(QMouseEvent* e);
|
void mouseMoveEvent(QMouseEvent* e);
|
||||||
void mouseReleaseEvent(QMouseEvent* e);
|
void mouseReleaseEvent(QMouseEvent* e);
|
||||||
void wheelEvent(QWheelEvent* e);
|
void wheelEvent(QWheelEvent* e);
|
||||||
void keyPressEvent(QKeyEvent *e);
|
void keyPressEvent(QKeyEvent* e);
|
||||||
void export_to_file(unsigned width,
|
void export_to_file(unsigned width, unsigned height, std::string const& filename, std::string const& type);
|
||||||
unsigned height,
|
|
||||||
std::string const& filename,
|
|
||||||
std::string const& type);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAP_WIDGET_HPP
|
#endif // MAP_WIDGET_HPP
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,7 +17,6 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "styles_model.hpp"
|
#include "styles_model.hpp"
|
||||||
#include <mapnik/config.hpp>
|
#include <mapnik/config.hpp>
|
||||||
#include <mapnik/util/variant.hpp>
|
#include <mapnik/util/variant.hpp>
|
||||||
|
@ -39,70 +38,50 @@ class node : private mapnik::util::noncopyable
|
||||||
{
|
{
|
||||||
struct node_base
|
struct node_base
|
||||||
{
|
{
|
||||||
virtual QString name() const=0;
|
virtual QString name() const = 0;
|
||||||
virtual QIcon icon() const=0;
|
virtual QIcon icon() const = 0;
|
||||||
virtual ~node_base() {}
|
virtual ~node_base() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template<typename T>
|
||||||
struct wrap : public node_base
|
struct wrap : public node_base
|
||||||
{
|
{
|
||||||
wrap(T const& obj)
|
wrap(T const& obj)
|
||||||
: obj_(obj) {}
|
: obj_(obj)
|
||||||
|
{}
|
||||||
|
|
||||||
~wrap() {}
|
~wrap() {}
|
||||||
|
|
||||||
QString name () const
|
QString name() const { return obj_.name(); }
|
||||||
{
|
|
||||||
return obj_.name();
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon icon() const
|
QIcon icon() const { return obj_.icon(); }
|
||||||
{
|
|
||||||
return obj_.icon();
|
|
||||||
}
|
|
||||||
|
|
||||||
T obj_;
|
T obj_;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template <typename T>
|
template<typename T>
|
||||||
node ( T const& obj, node * parent=0)
|
node(T const& obj, node* parent = 0)
|
||||||
: impl_(new wrap<T>(obj)),
|
: impl_(new wrap<T>(obj))
|
||||||
parent_(parent)
|
, parent_(parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QString name() const
|
QString name() const { return impl_->name(); }
|
||||||
{
|
|
||||||
return impl_->name();
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon icon() const
|
QIcon icon() const { return impl_->icon(); }
|
||||||
{
|
|
||||||
return impl_->icon();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned num_children() const
|
unsigned num_children() const { return children_.count(); }
|
||||||
{
|
|
||||||
return children_.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
node * child(unsigned row) const
|
node* child(unsigned row) const { return children_.value(row); }
|
||||||
{
|
|
||||||
return children_.value(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
node * parent() const
|
node* parent() const { return parent_; }
|
||||||
{
|
|
||||||
return parent_;
|
|
||||||
}
|
|
||||||
|
|
||||||
node * add_child(node * child)
|
node* add_child(node* child)
|
||||||
{
|
{
|
||||||
children_.push_back(child);
|
children_.push_back(child);
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
int row () const
|
int row() const
|
||||||
{
|
{
|
||||||
if (parent_)
|
if (parent_)
|
||||||
return parent_->children_.indexOf(const_cast<node*>(this));
|
return parent_->children_.indexOf(const_cast<node*>(this));
|
||||||
|
@ -110,94 +89,90 @@ public:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
~node()
|
~node() { qDeleteAll(children_); }
|
||||||
{
|
|
||||||
qDeleteAll(children_);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::unique_ptr<node_base> impl_;
|
const std::unique_ptr<node_base> impl_;
|
||||||
QList<node*> children_;
|
QList<node*> children_;
|
||||||
node * parent_;
|
node* parent_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct symbolizer_info
|
struct symbolizer_info
|
||||||
{
|
{
|
||||||
QString operator() (mapnik::point_symbolizer const& sym) const
|
QString operator()(mapnik::point_symbolizer const& sym) const
|
||||||
{
|
{
|
||||||
boost::ignore_unused_variable_warning(sym);
|
boost::ignore_unused_variable_warning(sym);
|
||||||
return QString("PointSymbolizer");
|
return QString("PointSymbolizer");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString operator() (mapnik::line_symbolizer const& sym) const
|
QString operator()(mapnik::line_symbolizer const& sym) const
|
||||||
{
|
{
|
||||||
boost::ignore_unused_variable_warning(sym);
|
boost::ignore_unused_variable_warning(sym);
|
||||||
return QString("LineSymbolizer");
|
return QString("LineSymbolizer");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString operator() (mapnik::line_pattern_symbolizer const& sym) const
|
QString operator()(mapnik::line_pattern_symbolizer const& sym) const
|
||||||
{
|
{
|
||||||
boost::ignore_unused_variable_warning(sym);
|
boost::ignore_unused_variable_warning(sym);
|
||||||
return QString("LinePatternSymbolizer");
|
return QString("LinePatternSymbolizer");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString operator() (mapnik::polygon_symbolizer const& sym) const
|
QString operator()(mapnik::polygon_symbolizer const& sym) const
|
||||||
{
|
{
|
||||||
boost::ignore_unused_variable_warning(sym);
|
boost::ignore_unused_variable_warning(sym);
|
||||||
return QString("PolygonSymbolizer");
|
return QString("PolygonSymbolizer");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString operator() (mapnik::polygon_pattern_symbolizer const& sym) const
|
QString operator()(mapnik::polygon_pattern_symbolizer const& sym) const
|
||||||
{
|
{
|
||||||
boost::ignore_unused_variable_warning(sym);
|
boost::ignore_unused_variable_warning(sym);
|
||||||
return QString("PolygonSymbolizer");
|
return QString("PolygonSymbolizer");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString operator() (mapnik::text_symbolizer const& sym) const
|
QString operator()(mapnik::text_symbolizer const& sym) const
|
||||||
{
|
{
|
||||||
boost::ignore_unused_variable_warning(sym);
|
boost::ignore_unused_variable_warning(sym);
|
||||||
return QString("TextSymbolizer");
|
return QString("TextSymbolizer");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString operator() (mapnik::shield_symbolizer const& sym) const
|
QString operator()(mapnik::shield_symbolizer const& sym) const
|
||||||
{
|
{
|
||||||
boost::ignore_unused_variable_warning(sym);
|
boost::ignore_unused_variable_warning(sym);
|
||||||
return QString("ShieldSymbolizer");
|
return QString("ShieldSymbolizer");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString operator() (mapnik::markers_symbolizer const& sym) const
|
QString operator()(mapnik::markers_symbolizer const& sym) const
|
||||||
{
|
{
|
||||||
boost::ignore_unused_variable_warning(sym);
|
boost::ignore_unused_variable_warning(sym);
|
||||||
return QString("MarkersSymbolizer");
|
return QString("MarkersSymbolizer");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString operator() (mapnik::building_symbolizer const& sym) const
|
QString operator()(mapnik::building_symbolizer const& sym) const
|
||||||
{
|
{
|
||||||
boost::ignore_unused_variable_warning(sym);
|
boost::ignore_unused_variable_warning(sym);
|
||||||
return QString("BuildingSymbolizer");
|
return QString("BuildingSymbolizer");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template<typename T>
|
||||||
QString operator() (T const& ) const
|
QString operator()(T const&) const
|
||||||
{
|
{
|
||||||
return QString ("FIXME");
|
return QString("FIXME");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct symbolizer_icon
|
struct symbolizer_icon
|
||||||
{
|
{
|
||||||
QIcon operator() (mapnik::polygon_symbolizer const& sym) const
|
QIcon operator()(mapnik::polygon_symbolizer const& sym) const
|
||||||
{
|
{
|
||||||
QPixmap pix(16,16);
|
QPixmap pix(16, 16);
|
||||||
QPainter painter(&pix);
|
QPainter painter(&pix);
|
||||||
mapnik::color const& fill = mapnik::get<mapnik::color>(sym, mapnik::keys::fill);
|
mapnik::color const& fill = mapnik::get<mapnik::color>(sym, mapnik::keys::fill);
|
||||||
QBrush brush(QColor(fill.red(),fill.green(),fill.blue(),fill.alpha()));
|
QBrush brush(QColor(fill.red(), fill.green(), fill.blue(), fill.alpha()));
|
||||||
painter.fillRect(0, 0, 16, 16, brush);
|
painter.fillRect(0, 0, 16, 16, brush);
|
||||||
return QIcon(pix);
|
return QIcon(pix);
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon operator() (mapnik::point_symbolizer const& sym) const
|
QIcon operator()(mapnik::point_symbolizer const& sym) const
|
||||||
{
|
{
|
||||||
// FIXME!
|
// FIXME!
|
||||||
/*
|
/*
|
||||||
|
@ -212,55 +187,57 @@ struct symbolizer_icon
|
||||||
*/
|
*/
|
||||||
return QIcon();
|
return QIcon();
|
||||||
}
|
}
|
||||||
QIcon operator() (mapnik::line_symbolizer const& sym) const
|
QIcon operator()(mapnik::line_symbolizer const& sym) const
|
||||||
{
|
{
|
||||||
QPixmap pix(48,16);
|
QPixmap pix(48, 16);
|
||||||
pix.fill();
|
pix.fill();
|
||||||
QPainter painter(&pix);
|
QPainter painter(&pix);
|
||||||
//mapnik::stroke const& strk = sym.get_stroke();
|
// mapnik::stroke const& strk = sym.get_stroke();
|
||||||
mapnik::color const& col = mapnik::get<mapnik::color>(sym, mapnik::keys::stroke);
|
mapnik::color const& col = mapnik::get<mapnik::color>(sym, mapnik::keys::stroke);
|
||||||
QPen pen(QColor(col.red(),col.green(),col.blue(),col.alpha()));
|
QPen pen(QColor(col.red(), col.green(), col.blue(), col.alpha()));
|
||||||
pen.setWidth(mapnik::get<double>(sym, mapnik::keys::width));
|
pen.setWidth(mapnik::get<double>(sym, mapnik::keys::width));
|
||||||
painter.setPen(pen);
|
painter.setPen(pen);
|
||||||
painter.drawLine(0,7,47,7);
|
painter.drawLine(0, 7, 47, 7);
|
||||||
//painter.drawLine(7,15,12,0);
|
// painter.drawLine(7,15,12,0);
|
||||||
//painter.drawLine(12,0,8,15);
|
// painter.drawLine(12,0,8,15);
|
||||||
return QIcon(pix);
|
return QIcon(pix);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template<typename T>
|
||||||
QIcon operator() (T const& ) const
|
QIcon operator()(T const&) const
|
||||||
{
|
{
|
||||||
return QIcon (":/images/filter.png");
|
return QIcon(":/images/filter.png");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class symbolizer_node
|
class symbolizer_node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
symbolizer_node(mapnik::symbolizer const & sym)
|
symbolizer_node(mapnik::symbolizer const& sym)
|
||||||
: sym_(sym) {}
|
: sym_(sym)
|
||||||
~symbolizer_node(){}
|
{}
|
||||||
|
~symbolizer_node() {}
|
||||||
|
|
||||||
QString name() const
|
QString name() const
|
||||||
{
|
{
|
||||||
//return QString("Symbolizer:fixme");
|
// return QString("Symbolizer:fixme");
|
||||||
return mapnik::util::apply_visitor(symbolizer_info(),sym_);
|
return mapnik::util::apply_visitor(symbolizer_info(), sym_);
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon icon() const
|
QIcon icon() const
|
||||||
{
|
{
|
||||||
return mapnik::util::apply_visitor(symbolizer_icon(),sym_);//QIcon(":/images/filter.png");
|
return mapnik::util::apply_visitor(symbolizer_icon(), sym_); // QIcon(":/images/filter.png");
|
||||||
}
|
}
|
||||||
mapnik::symbolizer const& sym_;
|
mapnik::symbolizer const& sym_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class rule_node
|
class rule_node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
rule_node(QString name,mapnik::rule const & r)
|
rule_node(QString name, mapnik::rule const& r)
|
||||||
: name_(name),
|
: name_(name)
|
||||||
rule_(r) {}
|
, rule_(r)
|
||||||
|
{}
|
||||||
~rule_node() {}
|
~rule_node() {}
|
||||||
QString name() const
|
QString name() const
|
||||||
{
|
{
|
||||||
|
@ -268,81 +245,68 @@ public:
|
||||||
return QString(mapnik::to_expression_string(*filter).c_str());
|
return QString(mapnik::to_expression_string(*filter).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon icon() const
|
QIcon icon() const { return QIcon(":/images/filter.png"); }
|
||||||
{
|
|
||||||
return QIcon(":/images/filter.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString name_;
|
QString name_;
|
||||||
mapnik::rule const& rule_;
|
mapnik::rule const& rule_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class style_node
|
class style_node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
style_node(QString name, mapnik::feature_type_style const& style)
|
style_node(QString name, mapnik::feature_type_style const& style)
|
||||||
: name_(name),
|
: name_(name)
|
||||||
style_(style) {}
|
, style_(style)
|
||||||
|
{}
|
||||||
|
|
||||||
~style_node() {}
|
~style_node() {}
|
||||||
|
|
||||||
QString name() const
|
QString name() const { return name_; }
|
||||||
{
|
|
||||||
return name_;
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon icon() const
|
QIcon icon() const { return QIcon(":/images/style.png"); }
|
||||||
{
|
|
||||||
return QIcon(":/images/style.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString name_;
|
QString name_;
|
||||||
mapnik::feature_type_style const& style_;
|
mapnik::feature_type_style const& style_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class map_node
|
class map_node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit map_node(std::shared_ptr<mapnik::Map> map)
|
explicit map_node(std::shared_ptr<mapnik::Map> map)
|
||||||
: map_(map) {}
|
: map_(map)
|
||||||
|
{}
|
||||||
~map_node() {}
|
~map_node() {}
|
||||||
|
|
||||||
QString name() const
|
QString name() const { return QString("Map"); }
|
||||||
{
|
|
||||||
return QString("Map");
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon icon() const
|
QIcon icon() const { return QIcon(":/images/map.png"); }
|
||||||
{
|
|
||||||
return QIcon(":/images/map.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<mapnik::Map> map_;
|
std::shared_ptr<mapnik::Map> map_;
|
||||||
};
|
};
|
||||||
|
|
||||||
StyleModel::StyleModel(std::shared_ptr<mapnik::Map> map, QObject * parent)
|
StyleModel::StyleModel(std::shared_ptr<mapnik::Map> map, QObject* parent)
|
||||||
: QAbstractItemModel(parent),
|
: QAbstractItemModel(parent)
|
||||||
root_(new node(map_node(map)))
|
, root_(new node(map_node(map)))
|
||||||
{
|
{
|
||||||
using style_type = std::map<std::string,mapnik::feature_type_style>;
|
using style_type = std::map<std::string, mapnik::feature_type_style>;
|
||||||
style_type const & styles = map->styles();
|
style_type const& styles = map->styles();
|
||||||
style_type::const_iterator itr = styles.begin();
|
style_type::const_iterator itr = styles.begin();
|
||||||
style_type::const_iterator end = styles.end();
|
style_type::const_iterator end = styles.end();
|
||||||
for (; itr != end; ++itr)
|
for (; itr != end; ++itr)
|
||||||
{
|
{
|
||||||
node * style_n = root_->add_child(new node(style_node(QString(itr->first.c_str()),itr->second),root_.get()));
|
node* style_n = root_->add_child(new node(style_node(QString(itr->first.c_str()), itr->second), root_.get()));
|
||||||
mapnik::rules const& rules = itr->second.get_rules();
|
mapnik::rules const& rules = itr->second.get_rules();
|
||||||
mapnik::rules::const_iterator itr2 = rules.begin();
|
mapnik::rules::const_iterator itr2 = rules.begin();
|
||||||
for ( ; itr2 != rules.end();++itr2)
|
for (; itr2 != rules.end(); ++itr2)
|
||||||
{
|
{
|
||||||
node* rule_n = style_n->add_child(new node(rule_node(QString("Rule"),*itr2),style_n));
|
node* rule_n = style_n->add_child(new node(rule_node(QString("Rule"), *itr2), style_n));
|
||||||
mapnik::rule::symbolizers::const_iterator itr3 = (*itr2).begin();
|
mapnik::rule::symbolizers::const_iterator itr3 = (*itr2).begin();
|
||||||
for ( ; itr3 !=itr2->end();++itr3)
|
for (; itr3 != itr2->end(); ++itr3)
|
||||||
{
|
{
|
||||||
rule_n->add_child(new node(symbolizer_node(*itr3),rule_n));
|
rule_n->add_child(new node(symbolizer_node(*itr3), rule_n));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -351,38 +315,39 @@ StyleModel::StyleModel(std::shared_ptr<mapnik::Map> map, QObject * parent)
|
||||||
StyleModel::~StyleModel() {}
|
StyleModel::~StyleModel() {}
|
||||||
|
|
||||||
// interface
|
// interface
|
||||||
QModelIndex StyleModel::index (int row, int col, QModelIndex const& parent) const
|
QModelIndex StyleModel::index(int row, int col, QModelIndex const& parent) const
|
||||||
{
|
{
|
||||||
// qDebug("index() row=%d col=%d parent::internalId() = %lld", row,col,parent.internalId());
|
// qDebug("index() row=%d col=%d parent::internalId() = %lld", row,col,parent.internalId());
|
||||||
node * parent_node;
|
node* parent_node;
|
||||||
|
|
||||||
if (!parent.isValid())
|
if (!parent.isValid())
|
||||||
parent_node = root_.get();
|
parent_node = root_.get();
|
||||||
else
|
else
|
||||||
parent_node = static_cast<node*>(parent.internalPointer());
|
parent_node = static_cast<node*>(parent.internalPointer());
|
||||||
|
|
||||||
node * child_node = parent_node->child(row);
|
node* child_node = parent_node->child(row);
|
||||||
if (child_node)
|
if (child_node)
|
||||||
return createIndex(row,col,child_node);
|
return createIndex(row, col, child_node);
|
||||||
else
|
else
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex StyleModel::parent (QModelIndex const& index) const
|
QModelIndex StyleModel::parent(QModelIndex const& index) const
|
||||||
{
|
{
|
||||||
node * child_node = static_cast<node*>(index.internalPointer());
|
node* child_node = static_cast<node*>(index.internalPointer());
|
||||||
node * parent_node = child_node->parent();
|
node* parent_node = child_node->parent();
|
||||||
if (parent_node == root_.get())
|
if (parent_node == root_.get())
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
return createIndex(parent_node->row(),0,parent_node);
|
return createIndex(parent_node->row(), 0, parent_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
int StyleModel::rowCount(QModelIndex const& parent) const
|
int StyleModel::rowCount(QModelIndex const& parent) const
|
||||||
{
|
{
|
||||||
//qDebug("rowCount");
|
// qDebug("rowCount");
|
||||||
node * parent_node;
|
node* parent_node;
|
||||||
if (parent.column() > 0) return 0;
|
if (parent.column() > 0)
|
||||||
|
return 0;
|
||||||
if (!parent.isValid())
|
if (!parent.isValid())
|
||||||
parent_node = root_.get();
|
parent_node = root_.get();
|
||||||
else
|
else
|
||||||
|
@ -390,25 +355,24 @@ int StyleModel::rowCount(QModelIndex const& parent) const
|
||||||
return parent_node->num_children();
|
return parent_node->num_children();
|
||||||
}
|
}
|
||||||
|
|
||||||
int StyleModel::columnCount( QModelIndex const&) const
|
int StyleModel::columnCount(QModelIndex const&) const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant StyleModel::data(const QModelIndex & index, int role) const
|
QVariant StyleModel::data(const QModelIndex& index, int role) const
|
||||||
{
|
{
|
||||||
//qDebug("data index::internalId() = %lld", index.internalId());
|
// qDebug("data index::internalId() = %lld", index.internalId());
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
node * cur_node = static_cast<node*>(index.internalPointer());
|
node* cur_node = static_cast<node*>(index.internalPointer());
|
||||||
if (cur_node)
|
if (cur_node)
|
||||||
{
|
{
|
||||||
if (role == Qt::DisplayRole)
|
if (role == Qt::DisplayRole)
|
||||||
{
|
{
|
||||||
|
|
||||||
return QVariant(cur_node->name());
|
return QVariant(cur_node->name());
|
||||||
}
|
}
|
||||||
else if ( role == Qt::DecorationRole)
|
else if (role == Qt::DecorationRole)
|
||||||
{
|
{
|
||||||
return cur_node->icon();
|
return cur_node->icon();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* This file is part of Mapnik (c++ mapping toolkit)
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Artem Pavlenko
|
* Copyright (C) 2024 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* Mapnik is free software; you can redistribute it and/or
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -17,7 +17,6 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef STYLE_MODEL_HPP
|
#ifndef STYLE_MODEL_HPP
|
||||||
#define STYLE_MODEL_HPP
|
#define STYLE_MODEL_HPP
|
||||||
|
|
||||||
|
@ -27,23 +26,22 @@
|
||||||
#include <mapnik/map.hpp>
|
#include <mapnik/map.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class node;
|
class node;
|
||||||
class StyleModel : public QAbstractItemModel
|
class StyleModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
StyleModel(std::shared_ptr<mapnik::Map> map, QObject * parent=0);
|
StyleModel(std::shared_ptr<mapnik::Map> map, QObject* parent = 0);
|
||||||
~StyleModel();
|
~StyleModel();
|
||||||
// interface
|
// interface
|
||||||
QModelIndex index (int row, int col, QModelIndex const& parent = QModelIndex()) const;
|
QModelIndex index(int row, int col, QModelIndex const& parent = QModelIndex()) const;
|
||||||
QModelIndex parent (QModelIndex const& child) const;
|
QModelIndex parent(QModelIndex const& child) const;
|
||||||
int rowCount( QModelIndex const& parent = QModelIndex()) const;
|
int rowCount(QModelIndex const& parent = QModelIndex()) const;
|
||||||
int columnCount( QModelIndex const& parent = QModelIndex()) const;
|
int columnCount(QModelIndex const& parent = QModelIndex()) const;
|
||||||
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//std::shared_ptr<mapnik::Map> map_;
|
// std::shared_ptr<mapnik::Map> map_;
|
||||||
const std::unique_ptr<node> root_;
|
const std::unique_ptr<node> root_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
######################################################################
|
######################################################################
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
QT += core gui widgets
|
QT += core gui widgets
|
||||||
|
LIBS += $$system(mapnik-config --libs --dep-libs)
|
||||||
QMAKE_CXX = $$system(mapnik-config --cxx)
|
QMAKE_CXX = $$system(mapnik-config --cxx)
|
||||||
QMAKE_LINK = $$system(mapnik-config --cxx)
|
QMAKE_LINK = $$system(mapnik-config --cxx)
|
||||||
QMAKE_CXXFLAGS += $$system(mapnik-config --cxxflags)
|
QMAKE_CXXFLAGS += $$system(mapnik-config --cxxflags)
|
||||||
QMAKE_CXXFLAGS += $$system(mapnik-config --includes --dep-includes --defines)
|
QMAKE_CXXFLAGS += $$system(mapnik-config --includes --dep-includes --defines)
|
||||||
QMAKE_LFLAGS += $$system(mapnik-config --libs)
|
QMAKE_LFLAGS += $$system(mapnik-config --ldflags)
|
||||||
QMAKE_LFLAGS += $$system(mapnik-config --ldflags --dep-libs)
|
|
||||||
# Input
|
# Input
|
||||||
|
|
||||||
CONFIG += qt debug_and_release
|
CONFIG += qt debug_and_release
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue