[mapcode] 31/56: Fixed issue with AAA codes; v1.61

Stefan Fritsch sf at moszumanska.debian.org
Wed Nov 2 23:27:29 UTC 2016


This is an automated email from the git hooks/post-receive script.

sf pushed a commit to annotated tag v2.0.2
in repository mapcode.

commit 1e74c13bce78b225d9fd9612e566ea3e87ebc1b1
Author: Rijn Buve <rijn at buve.nl>
Date:   Fri Jun 19 18:18:21 2015 +0200

    Fixed issue with AAA codes; v1.61
---
 mapcodelib/basics.h   | 129 ++++++++++++++++++++++++--------------------------
 mapcodelib/mapcoder.c |  36 +++++++-------
 2 files changed, 81 insertions(+), 84 deletions(-)

diff --git a/mapcodelib/basics.h b/mapcodelib/basics.h
index a2437f3..8f6d937 100644
--- a/mapcodelib/basics.h
+++ b/mapcodelib/basics.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2014-2015 Stichting Mapcode Foundation (http://www.mapcode.com)
- *
+ * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -16,15 +16,11 @@
 
 #define UWORD unsigned short int // 2-byte unsigned integer
 
-#ifdef VERSION160
-#define mapcode_cversion "1.60"
-#else
-#define mapcode_cversion "1.55"
-#endif
+#define mapcode_cversion "1.61"
 #define MAXWIDE 10
 #define BASEX 31
 #define MAXFITLONG 6
-#define XSIDE3 168
+#define XSIDE3 168 
 #define YSIDE3 176
 
 #define ALIASES "2UK=2UT,2CG=2CT,1GU=GUM,1UM=UMI,1VI=VIR,1PR=PRI,1AS=ASM,1MP=MNP,4CX=CXR,4CC=CCK,4NF=NFK,4HM=HMD,COL=5CL,5ME=5MX,MEX=5MX,5TM=TAM,5AG=AGU,5BC=BCN,5BS=BCS,5CM=CAM,5CS=CHP,5CH=CHH,5CO=COA,5DF=DIF,5DG=DUR,5GT=GUA,5GR=GRO,5HG=HID,5JA=JAL,5MI=MIC,5MO=MOR,5NA=NAY,5NL=NLE,5OA=OAX,5PB=PUE,5QE=QUE,5QR=ROO,5SL=SLP,5SI=SIN,5SO=SON,5TB=TAB,5TL=TLA,5VE=VER,5YU=YUC,5ZA=ZAC,811=8BJ,812=8TJ,813=8HE,814=8SX,815=8NM,821=8LN,822=8JL,823=8HL,831=8SH,832=8JS,833=8ZJ,834=8AH,835=8FJ,836=8JX,837 [...]
@@ -172,63 +168,63 @@ static const char encode_chars[34] = {
 
 
 static const UWORD data_start[MAX_CCODE+1] = {
-0, 3, 6, 9, 13, 16, 18, 19, 30, 31,
-33, 35, 37, 42, 44, 47, 51, 54, 56, 58,
-60, 62, 64, 68, 71, 79, 81, 116, 121, 131,
-133, 135, 138, 143, 155, 159, 165, 167, 169, 173,
-176, 183, 185, 187, 189, 193, 195, 202, 208, 212,
-216, 219, 221, 223, 250, 252, 259, 261, 266, 284,
-288, 292, 296, 298, 303, 311, 315, 325, 327, 332,
-336, 342, 356, 360, 365, 369, 385, 391, 396, 404,
-412, 428, 432, 436, 443, 454, 491, 495, 521, 527,
-545, 557, 593, 659, 694, 733, 745, 754, 782, 798,
-832, 848, 882, 918, 932, 956, 967, 1022, 1080, 1094,
-1155, 1179, 1208, 1276, 1353, 1405, 1484, 1569, 1621, 1696,
-1772, 1833, 1875, 1900, 1948, 1991, 2036, 2097, 2183, 2270,
-2319, 2382, 2467, 2558, 2643, 2702, 2815, 2912, 3004, 3088,
-3186, 3248, 3350, 3416, 3511, 3602, 3688, 3776, 3866, 3973,
-4119, 4221, 4325, 4356, 4393, 4468, 4504, 4538, 4574, 4626,
-4690, 4741, 4756, 4791, 4931, 5017, 5067, 5143, 5168, 5236,
-5293, 5328, 5408, 5459, 5530, 5623, 5658, 5736, 5795, 5861,
-5918, 5971, 6028, 6065, 6156, 6285, 6335, 6365, 6417, 6513,
-6546, 6627, 6675, 6755, 6798, 6892, 6926, 6971, 7078, 7082,
-7154, 7198, 7282, 7322, 7346, 7403, 7489, 7563, 7602, 7689,
-7765, 7873, 7951, 8025, 8095, 8152, 8234, 8316, 8375, 8402,
-8440, 8494, 8570, 8680, 8760, 8824, 8881, 8935, 9013, 9084,
-9170, 9220, 9281, 9425, 9429, 9434, 9439, 9444, 9450, 9455,
-9463, 9471, 9482, 9490, 9505, 9514, 9525, 9558, 9567, 9575,
-9590, 9600, 9610, 9618, 9626, 9642, 9650, 9660, 9671, 9681,
-9691, 9700, 9709, 9720, 9761, 9802, 9820, 9917, 10068, 10159,
-10241, 10436, 10439, 10442, 10445, 10455, 10460, 10463, 10475, 10488,
-10499, 10515, 10524, 10530, 10564, 10592, 10611, 10679, 10771, 10786,
-10790, 10826, 10913, 10924, 10942, 10959, 11023, 11055, 11096, 11116,
-11221, 11301, 11365, 11419, 11478, 11534, 11594, 11600, 11642, 11646,
-11649, 11659, 11674, 11685, 11723, 11786, 11832, 11837, 11844, 11849,
-11868, 11878, 11885, 11893, 11907, 11923, 11930, 11938, 11946, 11994,
-12003, 12014, 12064, 12075, 12085, 12104, 12120, 12133, 12145, 12164,
-12198, 12207, 12219, 12231, 12235, 12241, 12247, 12259, 12270, 12279,
-12285, 12299, 12317, 12328, 12370, 12421, 12471, 12527, 12540, 12553,
-12616, 12676, 12737, 12802, 12873, 12938, 13007, 13082, 13149, 13228,
-13302, 13316, 13331, 13376, 13389, 13417, 13431, 13444, 13460, 13476,
-13488, 13530, 13542, 13553, 13588, 13603, 13615, 13632, 13640, 13678,
-13691, 13706, 13826, 13872, 13916, 13956, 13980, 14021, 14060, 14080,
-14096, 14114, 14126, 14140, 14148, 14159, 14176, 14189, 14244, 14245,
-14246, 14247, 14286, 14292, 14297, 14302, 14307, 14313, 14320, 14326,
-14335, 14341, 14349, 14355, 14362, 14371, 14379, 14388, 14400, 14409,
-14417, 14428, 14439, 14448, 14458, 14465, 14515, 14549, 14558, 14570,
-14581, 14620, 14631, 14645, 14662, 14674, 14687, 14701, 14716, 14729,
-14750, 14758, 14777, 14786, 14798, 14809, 14823, 14838, 14851, 14865,
-14878, 14892, 14907, 14925, 14945, 14957, 14977, 14990, 15005, 15019,
-15037, 15053, 15067, 15080, 15097, 15117, 15134, 15152, 15167, 15181,
-15197, 15208, 15224, 15237, 15252, 15267, 15313, 15327, 15336, 15346,
-15359, 15373, 15384, 15397, 15413, 15428, 15429, 15456, 15462, 15470,
-15476, 15492, 15529, 15546, 15570, 15593, 15610, 15630, 15656, 15682,
-15701, 15718, 15771, 15812, 15834, 15861, 15881, 15902, 15920, 15950,
-15976, 15996, 16017, 16035, 16053, 16072, 16088, 16104, 16132, 16158,
-16165, 16167, 16168, 16200
+0, 3, 6, 9, 13, 16, 18, 19, 30, 31, 
+33, 35, 37, 42, 44, 47, 51, 54, 56, 58, 
+60, 62, 64, 68, 71, 79, 81, 116, 121, 131, 
+133, 135, 138, 143, 155, 159, 165, 167, 169, 173, 
+176, 183, 185, 187, 189, 193, 195, 202, 208, 212, 
+216, 219, 221, 223, 250, 252, 259, 261, 266, 284, 
+288, 292, 296, 298, 303, 311, 315, 325, 327, 332, 
+336, 342, 356, 360, 365, 369, 385, 391, 396, 404, 
+412, 428, 432, 436, 443, 454, 491, 495, 521, 527, 
+545, 557, 593, 659, 694, 733, 745, 754, 782, 798, 
+832, 848, 882, 918, 932, 956, 967, 1022, 1080, 1094, 
+1155, 1179, 1208, 1276, 1353, 1405, 1484, 1569, 1621, 1696, 
+1772, 1833, 1875, 1900, 1948, 1991, 2036, 2097, 2183, 2270, 
+2319, 2382, 2467, 2558, 2643, 2702, 2815, 2912, 3004, 3088, 
+3186, 3248, 3350, 3416, 3511, 3602, 3688, 3776, 3866, 3973, 
+4119, 4221, 4325, 4356, 4393, 4468, 4504, 4538, 4574, 4626, 
+4690, 4741, 4756, 4791, 4931, 5017, 5067, 5143, 5168, 5236, 
+5293, 5328, 5408, 5459, 5530, 5623, 5658, 5736, 5795, 5861, 
+5918, 5971, 6028, 6065, 6156, 6285, 6335, 6365, 6417, 6513, 
+6546, 6627, 6675, 6755, 6798, 6892, 6926, 6971, 7078, 7083, 
+7155, 7199, 7283, 7323, 7347, 7404, 7490, 7564, 7603, 7690, 
+7766, 7874, 7952, 8026, 8096, 8153, 8235, 8317, 8376, 8403, 
+8441, 8495, 8571, 8681, 8761, 8825, 8882, 8936, 9014, 9085, 
+9171, 9221, 9282, 9426, 9430, 9435, 9440, 9445, 9451, 9456, 
+9464, 9472, 9483, 9491, 9506, 9515, 9526, 9559, 9568, 9576, 
+9591, 9601, 9611, 9619, 9627, 9643, 9651, 9661, 9672, 9682, 
+9692, 9701, 9710, 9721, 9762, 9803, 9821, 9918, 10069, 10160, 
+10242, 10437, 10440, 10443, 10446, 10456, 10461, 10464, 10476, 10489, 
+10500, 10516, 10525, 10531, 10565, 10593, 10612, 10680, 10772, 10787, 
+10791, 10827, 10914, 10925, 10943, 10960, 11024, 11056, 11097, 11117, 
+11222, 11302, 11366, 11420, 11479, 11535, 11595, 11601, 11643, 11647, 
+11650, 11660, 11675, 11686, 11724, 11787, 11833, 11838, 11845, 11850, 
+11869, 11879, 11886, 11894, 11908, 11924, 11931, 11939, 11947, 11995, 
+12004, 12015, 12065, 12076, 12086, 12105, 12121, 12134, 12146, 12165, 
+12199, 12208, 12220, 12232, 12236, 12242, 12248, 12260, 12271, 12280, 
+12286, 12300, 12318, 12329, 12371, 12422, 12472, 12528, 12541, 12554, 
+12617, 12677, 12738, 12803, 12874, 12939, 13008, 13083, 13150, 13229, 
+13303, 13317, 13332, 13377, 13390, 13418, 13432, 13445, 13461, 13477, 
+13489, 13531, 13543, 13554, 13589, 13604, 13616, 13633, 13641, 13679, 
+13692, 13707, 13827, 13873, 13917, 13957, 13981, 14022, 14061, 14081, 
+14097, 14115, 14127, 14141, 14149, 14160, 14177, 14190, 14245, 14246, 
+14247, 14248, 14287, 14293, 14298, 14303, 14308, 14314, 14321, 14327, 
+14336, 14342, 14350, 14356, 14363, 14372, 14380, 14389, 14401, 14410, 
+14418, 14429, 14440, 14449, 14459, 14466, 14516, 14550, 14559, 14571, 
+14582, 14621, 14632, 14646, 14663, 14675, 14688, 14702, 14717, 14730, 
+14751, 14759, 14778, 14787, 14799, 14810, 14824, 14839, 14852, 14866, 
+14879, 14893, 14908, 14926, 14946, 14958, 14978, 14991, 15006, 15020, 
+15038, 15054, 15068, 15081, 15098, 15118, 15135, 15153, 15168, 15182, 
+15198, 15209, 15225, 15238, 15253, 15268, 15314, 15328, 15337, 15347, 
+15360, 15374, 15385, 15398, 15414, 15429, 15430, 15457, 15463, 15471, 
+15477, 15493, 15530, 15547, 15571, 15594, 15611, 15631, 15657, 15683, 
+15702, 15719, 15772, 15813, 15835, 15862, 15882, 15903, 15921, 15951, 
+15977, 15997, 16018, 16036, 16054, 16073, 16089, 16105, 16133, 16159, 
+16166, 16168, 16169, 16201
 };
 
-#define NR_RECS 16200
+#define NR_RECS 16201
 #define WORST_RECS_PER_CCODE 195 // 8 Argentina @43
 
 typedef struct { long minx; long miny; long maxx; long maxy; unsigned long flags; } mminforec;
@@ -242,7 +238,7 @@ static const mminforec mminfo[NR_RECS+1] = {
 {-5200000, 41310000, 9600000, 53557000, 0x0010216},
 {7404110, 43723932, 7444472, 43752762, 0x003021c},
 {-5384925, 36107682, -5321499, 36159576, 0x001000b},
-{-6703000, 35867000, -3426000, 38475972, 0x0a63091},
+{-6703000, 35867000, -3426000, 38475972, 0x0a63291},
 {-5384925, 36107682, -5321499, 36159576, 0x003021c},
 {-172537866, -8601181, -172450415, -8514691, 0x001000a},
 {-171996267, -9340159, -171646464, -8994200, 0xf04004b},
@@ -415,7 +411,7 @@ static const mminforec mminfo[NR_RECS+1] = {
 {14043750, 78045711, 14328250, 78106820, 0x2a7004a},
 {-9164930, 70754480, -7779602, 71245520, 0x001000c},
 {10400000, 76889405, 22024500, 79500000, 0x0a50011},
-{-9154000, 68600000, 33625000, 80843100, 0x0970012},
+{-9154000, 68600000, 33625000, 80843100, 0x0970212},
 {10000000, 74300000, 33624989, 80843000, 0x0010016},
 {-9165000, 70754400, 33625000, 80843100, 0x003021c},
 {-61257000, 13122000, -61139000, 13183000, 0x016000a},
@@ -449,7 +445,7 @@ static const mminforec mminfo[NR_RECS+1] = {
 {144875000, 14080000, 146076000, 20560000, 0x18d0011},
 {1482182, 42461955, 1598463, 42548445, 0x001000a},
 {1404864, 42394488, 1795464, 42694568, 0x001000c},
-{348000, 40191933, 3820000, 42873123, 0x0a90091},
+{348000, 40191933, 3820000, 42873123, 0x0a90291},
 {1404864, 42394488, 1795464, 42694568, 0x003021c},
 {144826158, 13521379, 144888964, 13582488, 0x2a7004a},
 {144737755, 13449545, 144800561, 13510654, 0x2a7004a},
@@ -500,7 +496,7 @@ static const mminforec mminfo[NR_RECS+1] = {
 {50575813, 26194782, 50623592, 26281272, 0x2a7044a},
 {50310000, 25788000, 50745000, 26338000, 0x023000c},
 {50448000, 25557000, 50825000, 25967000, 0x0bd0010},
-{50310000, 25557000, 50825000, 26338000, 0x0da0211},
+{50300000, 25557000, 50825000, 26338000, 0x0d80211},
 {172918000, 1324000, 173080000, 1365000, 0x00f000a},
 {172778000, 1323000, 173172000, 1974000, 0x026000c},
 {-157502976, 1911168, -157353217, 2060927, 0x680004b},
@@ -7315,6 +7311,7 @@ static const mminforec mminfo[NR_RECS+1] = {
 {-5200000, 41310000, 9600000, 51100000, 0x003021c},
 {19474000, 59973000, 20400000, 60464000, 0x001000c},
 {20400000, 59900000, 21118800, 60536000, 0x0e40010},
+{-9154000, 68600000, 33625000, 80843100, 0x0970012},
 {4490000, 54544000, 31600000, 68600000, 0x3770016},
 {19100000, 59675750, 21134000, 60671833, 0x003021c},
 {36798377, -1311622, 36884867, -1225132, 0x001000a},
diff --git a/mapcodelib/mapcoder.c b/mapcodelib/mapcoder.c
index 868b9dd..2cbece0 100644
--- a/mapcodelib/mapcoder.c
+++ b/mapcodelib/mapcoder.c
@@ -323,15 +323,15 @@ static double extrax,extray;
 static void decodeExtension(long *nx,long *ny, long dividerx4,long dividery,int ydirection) // add extra precision to a coordinate based on extra chars
 {
 #ifndef VERSION160 // old integer-arithmetic version
-  // long extrax,extray;
+  long extrax,extray;
   if (*extrapostfix) {
     int column1,row1,column2,row2,c1,c2;
     c1 = extrapostfix[0];
-    c1 = decode_chars[c1];
+    c1 = decode_chars[(unsigned int)c1];
     if (c1<0) c1=0; else if (c1>29) c1=29;
     row1 =(c1/5); column1 = (c1%5);
     c2 = (extrapostfix[1]) ? extrapostfix[1] : 72; // 72='H'=code 15=(3+2*6)
-    c2 = decode_chars[c2];
+    c2 = decode_chars[(unsigned int)c2];
     if (c2<0) c2=0; else if (c2>29) c2=29;
     row2 =(c2/6); column2 = (c2%6);
 
@@ -356,11 +356,11 @@ static void decodeExtension(long *nx,long *ny, long dividerx4,long dividery,int
     int column1,row1,column2,row2;
     double halfcolumn=0;
     int c1 = *extrapostfix++;
-    c1 = decode_chars[c1];
+    c1 = decode_chars[(unsigned int)c1];
     if (c1<0) c1=0; else if (c1>29) c1=29;
     row1 =(c1/5); column1 = (c1%5);
     if (*extrapostfix) {
-      int c2 = decode_chars[(int)*extrapostfix++];
+      int c2 = decode_chars[(unsigned int)*extrapostfix++];
       if (c2<0) c2=0; else if (c2>29) c2=29;
       row2 =(c2/6); column2 = (c2%6);
     }
@@ -458,7 +458,7 @@ static long decodeBase31( const char *code )
   long value=0;
   while (*code!='.' && *code!=0 )
   {
-    value = value*31 + decode_chars[(int)*code++];
+    value = value*31 + decode_chars[(unsigned int)*code++];
   }
   return value;
 }
@@ -488,7 +488,7 @@ static void encode_triple( char *result, long difx,long dify )
 static void decode_triple( const char *result, long *difx, long *dify )
 {
       // decode the first character
-      int c1 = decode_chars[(int)*result++];
+      int c1 = decode_chars[(unsigned int)*result++];
       if ( c1<24 )
       {
         long m = decodeBase31(result);
@@ -999,7 +999,7 @@ static int decodeNameless( const char *orginput, long *x, long *y,         int i
     // now determine X = index of first area, and SIDE
     if ( codex!=21 && A<=31 )
     {
-      int offset = decode_chars[(int)*result];
+      int offset = decode_chars[(unsigned int)*result];
 
       if ( offset < r*(p+1) )
       {
@@ -1014,7 +1014,7 @@ static int decodeNameless( const char *orginput, long *x, long *y,         int i
     else if ( codex!=21 && A<62 )
     {
 
-      X = decode_chars[(int)*result];
+      X = decode_chars[(unsigned int)*result];
       if ( X < (62-A) )
       {
         swapletters=(codex==22);
@@ -1165,7 +1165,7 @@ static int unpack_if_alldigits(char *input) // returns 1 if unpacked, 0 if left
       break;
     else if (*s=='.' && !dotpos)
       dotpos=s;
-    else if ( decode_chars[(int)*s]<0 || decode_chars[(int)*s]>9 )
+    else if ( decode_chars[(unsigned int)*s]<0 || decode_chars[(unsigned int)*s]>9 )
       return 0;  // nondigit, so stop
   }
 
@@ -1173,7 +1173,7 @@ static int unpack_if_alldigits(char *input) // returns 1 if unpacked, 0 if left
   {
       if (aonly) // v1.50 encoded only with A's
       {
-        int v = (s[0]=='A' || s[0]=='a' ? 31 : decode_chars[(int)s[0]]) * 32 + (s[1]=='A' || s[1]=='a' ? 31 : decode_chars[(int)s[1]]);
+        int v = (s[0]=='A' || s[0]=='a' ? 31 : decode_chars[(unsigned int)s[0]]) * 32 + (s[1]=='A' || s[1]=='a' ? 31 : decode_chars[(unsigned int)s[1]]);
         *input  = '0'+(v/100);
         s[0]= '0'+((v/10)%10);
         s[1]= '0'+(v%10);
@@ -1191,13 +1191,13 @@ static int unpack_if_alldigits(char *input) // returns 1 if unpacked, 0 if left
       if (*e=='a' || *e=='A') v+=31;
       else if (*e=='e' || *e=='E') v+=32;
       else if (*e=='u' || *e=='U') v+=33;
-      else if (decode_chars[(int)*e]<0) return -9; // invalid last character!
-      else v+=decode_chars[(int)*e];
+      else if (decode_chars[(unsigned int)*e]<0) return -9; // invalid last character!
+      else v+=decode_chars[(unsigned int)*e];
 
       if (v<100)
       {
-        *s = encode_chars[(int)v/10];
-        *e = encode_chars[(int)v%10];
+        *s = encode_chars[(unsigned int)v/10];
+        *e = encode_chars[(unsigned int)v%10];
       }
       return 1;
     }
@@ -1430,9 +1430,9 @@ static int master_decode(  long *nx,long *ny, // <- store result in nx,ny
     {
       if (*s=='.')
         { if (dot) return -5; else dot=s; }
-      else if ( decode_chars[(int)*s]<0 )
+      else if ( decode_chars[(unsigned int)*s]<0 )
         return -4; // invalid char
-      else if ( decode_chars[(int)*s]<10 ) // digit?
+      else if ( decode_chars[(unsigned int)*s]<10 ) // digit?
         nrd++;
     }
     if (dot==NULL)
@@ -2721,7 +2721,7 @@ int encodeLatLonToMapcodes_full( char **v, double lat, double lon, int tc, int s
     int i;
     for(i=0;i<MAX_MAPCODE_TERRITORY_CODE;i++) {
       master_encode(NULL,i,lon32,lat32,-1,stop_with_one_result,0,0); // 1.29 - also add parents recursively
-      if ((stop_with_one_result||debugStopAt) && nr_global_results>0) break;
+      if ((stop_with_one_result||debugStopAt>=0) && nr_global_results>0) break;
     }
   }
   else

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/mapcode.git



More information about the Pkg-grass-devel mailing list