Skip to content

Commit 7cbd9b7

Browse files
committed
Added newest C lib
1 parent 757d6cd commit 7cbd9b7

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

mapcode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <math.h>
2828
#include "mapcoder/mapcoder.c"
2929

30-
static const char* VERSION = "1.01";
30+
static const char* VERSION = "1";
3131
static const int SELF_CHECK = 1;
3232
static const int SELF_CHECK_EXIT = 0;
3333

@@ -61,7 +61,7 @@ static double lonLargestNrOfResults = 0.0;
6161
* whenever a incorrect amount or combination of parameters is entered.
6262
*/
6363
static void usage(const char* appName) {
64-
printf("MAPCODE %s (C library version %s)%s\n", VERSION, mapcode_cversion, SELF_CHECK ? " (self-checking)" : "");
64+
printf("MAPCODE (version %s.%s%s)\n", mapcode_cversion, VERSION, SELF_CHECK ? ", self-checking" : "");
6565
printf("Copyright (C) 2014 Stichting Mapcode Foundation\n");
6666
printf("\n");
6767
printf("Usage:\n");

mapcoder/basics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define UWORD unsigned short int // 2-byte unsigned integer
22

3-
#define mapcode_cversion "1.32"
3+
#define mapcode_cversion "1.33"
44
#define MAXWIDE 10
55
#define BASEX 31
66
#define MAXFITLONG 6

mapcoder/mapcode_library.doc

-23 KB
Binary file not shown.

mapcoder/mapcoder.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,11 +1364,13 @@ int master_decode( long *nx,long *ny, // <- store result in nx,ny
13641364
if (isuseless(m)) {
13651365
int j,fitssomewhere=0;
13661366
for (j=iso_start; (j)<m; j++) { // look in previous rects
1367-
long minx,miny,maxx,maxy;
1367+
long minx,miny,maxx,maxy,xdiv8;
13681368
if (isuseless((j))) continue;
13691369
getboundaries((j),minx,miny,maxx,maxy);
1370-
if ( miny<=*ny && *ny<maxy && isInRange(*nx,minx,maxx) ) { fitssomewhere=1; break; }
1371-
}
1370+
// 1.33 fix to not remove valid results just across the edge of a territory
1371+
xdiv8 = x_divider(miny,maxy)/4; // should be /8 but there's some extra margin
1372+
if ( miny-60<=*ny && *ny<maxy+60 && isInRange(*nx,minx-xdiv8,maxx+xdiv8) ) { fitssomewhere=1; break; }
1373+
}
13721374
if (!fitssomewhere) {
13731375
err=-1234;
13741376
}
@@ -1629,8 +1631,7 @@ void master_encode( char *resultbuffer, int the_ctry, long x, long y, int forcec
16291631

16301632

16311633
#ifdef VERSION_1_32 // 1.32 true recursive processing
1632-
if (!stop_with_one_result)
1633-
master_encode( resultbuffer, the_ctry, x,y, forcecoder, 0,0,1 );
1634+
master_encode( resultbuffer, the_ctry, x,y, forcecoder, stop_with_one_result,/*allow-world*/0,1 );
16341635
result_override=-1;
16351636
return; /**/
16361637
#else

mapcoder/readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ version history
2424
1.30 updated the documentation and extended it with examples and suggestions
2525
1.31 added lookslikemapcode();
2626
1.32 added coord2mc1(); fixed 1.29 so no country-wide alternative is produced in edge cases; prevent FIJI failing to decode at exactly 180 degrees;
27+
1.33 fix to not remove valid results just across the edge of a territory

0 commit comments

Comments
 (0)