Skip to content

Commit 24a7484

Browse files
committed
Initial commit
0 parents  commit 24a7484

17 files changed

+2620
-0
lines changed

mapcode.iml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="false">
4+
<output url="file://$MODULE_DIR$/target/classes" />
5+
<output-test url="file://$MODULE_DIR$/target/test-classes" />
6+
<content url="file://$MODULE_DIR$">
7+
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
8+
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
9+
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
10+
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
11+
<excludeFolder url="file://$MODULE_DIR$/target" />
12+
</content>
13+
<orderEntry type="inheritedJdk" />
14+
<orderEntry type="sourceFolder" forTests="false" />
15+
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
16+
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.2" level="project" />
17+
<orderEntry type="library" name="Maven: org.slf4j:slf4j-log4j12:1.7.2" level="project" />
18+
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
19+
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
20+
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:3.0.0" level="project" />
21+
<orderEntry type="library" scope="TEST" name="Maven: com.google.code.gson:gson:2.3" level="project" />
22+
</component>
23+
</module>
24+

pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
4+
http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>com.mapcode</groupId>
7+
<artifactId>mapcode-java</artifactId>
8+
<packaging>jar</packaging>
9+
<version>1.0-SNAPSHOT</version>
10+
<name>Mapcode Java Library</name>
11+
<dependencies>
12+
<dependency>
13+
<groupId>junit</groupId>
14+
<artifactId>junit</artifactId>
15+
<version>4.11</version>
16+
<scope>test</scope>
17+
</dependency>
18+
</dependencies>
19+
</project>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2014 Stichting Mapcode Foundation
3+
* For terms of use refer to http://www.mapcode.com/downloads.html
4+
******************************************************************************/
5+
package com.mapcode;
6+
7+
public class MapCodeCommon {
8+
public final static int[] nc = { 1, 31, 961, 29791, 923521, 28629151, 887503681 };
9+
10+
public final static int[] xside = { 0, 5, 31, 168, 961, 168 * 31, 29791, 165869, 923521, 5141947 };
11+
12+
public final static int[] yside = { 0, 6, 31, 176, 961, 176 * 31, 29791, 165869, 923521, 5141947 };
13+
14+
private static int[] xdivider19 = { 360, 360, 360, 360, 360, 360, 361, 361, 361, 361, 362, 362, 362, 363, 363, 363,
15+
364, 364, 365, 366, 366, 367, 367, 368, 369, 370, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380,
16+
382, 383, 384, 386, 387, 388, 390, 391, 393, 394, 396, 398, 399, 401, 403, 405, 407, 409, 411, 413, 415,
17+
417, 420, 422, 424, 427, 429, 432, 435, 437, 440, 443, 446, 449, 452, 455, 459, 462, 465, 469, 473, 476,
18+
480, 484, 488, 492, 496, 501, 505, 510, 515, 520, 525, 530, 535, 540, 546, 552, 558, 564, 570, 577, 583,
19+
590, 598, 605, 612, 620, 628, 637, 645, 654, 664, 673, 683, 693, 704, 715, 726, 738, 751, 763, 777, 791,
20+
805, 820, 836, 852, 869, 887, 906, 925, 946, 968, 990, 1014, 1039, 1066, 1094, 1123, 1154, 1187, 1223,
21+
1260, 1300, 1343, 1389, 1438, 1490, 1547, 1609, 1676, 1749, 1828, 1916, 2012, 2118, 2237, 2370, 2521, 2691,
22+
2887, 3114, 3380, 3696, 4077, 4547, 5139, 5910, 6952, 8443, 10747, 14784, 23681, 59485 };
23+
24+
public static int x_divider(int miny, int maxy)
25+
// returns divider for longitude (multiplied by 4), for a given latitude
26+
{
27+
if (miny >= 0) // maxy>miny>0
28+
return xdivider19[miny >> 19];
29+
if (maxy >= 0) // maxy>0>miny
30+
return xdivider19[0];
31+
return xdivider19[(-maxy) >> 19]; // 0>maxy>miny
32+
}
33+
34+
public static int count_city_coordinates_for_country(int samecodex, int index, int firstcode) {
35+
int i = get_first_nameless_record(samecodex, index, firstcode);
36+
int e = index;
37+
while (MapcoderData.codex(e) == samecodex) {
38+
e++;
39+
}
40+
e--;
41+
return e - i + 1;
42+
}
43+
44+
public static int get_first_nameless_record(int samecodex, int index, int firstcode) {
45+
int i = index;
46+
while (i >= firstcode && MapcoderData.isNameless(i) && MapcoderData.codex(i) == samecodex) {
47+
i--;
48+
}
49+
i++;
50+
return i;
51+
}
52+
53+
}

0 commit comments

Comments
 (0)