Skip to content

Commit fc57bf0

Browse files
committed
Clean up
1 parent d67528d commit fc57bf0

File tree

4 files changed

+172
-141
lines changed

4 files changed

+172
-141
lines changed

pom.xml

Lines changed: 69 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<name>Mapcode Java Library</name>
1414
<description>
1515
This library offers Java support for mapcodes.
16-
For more info: http://www.mapcode.com
16+
For more info: http://mapcode.com
1717
</description>
1818

1919
<organization>
@@ -25,7 +25,7 @@
2525
<developer>
2626
<id>pieter</id>
2727
<name>Pieter Geelen</name>
28-
<organization>Mapcode</organization>
28+
<organization>Mapcode Foundation</organization>
2929
<roles>
3030
<role>Founder</role>
3131
</roles>
@@ -34,18 +34,17 @@
3434
<developer>
3535
<id>rijn</id>
3636
<name>Rijn Buve</name>
37-
<organization>Mapcode</organization>
37+
<organization>Mapcode Foundation</organization>
3838
<roles>
39-
<role>Developer</role>
39+
<role>Managing Director, development</role>
4040
</roles>
4141
</developer>
4242

4343
<developer>
4444
<id>matthew</id>
4545
<name>Matthew Lowden</name>
46-
<organization>Mapcode</organization>
4746
<roles>
48-
<role>Original Port</role>
47+
<role>Original Java port</role>
4948
</roles>
5049
</developer>
5150
</developers>
@@ -101,6 +100,19 @@
101100

102101
<build>
103102
<plugins>
103+
104+
<!-- Java compiler. -->
105+
<plugin>
106+
<groupId>org.apache.maven.plugins</groupId>
107+
<artifactId>maven-compiler-plugin</artifactId>
108+
<version>${maven-compiler-plugin.version}</version>
109+
<configuration>
110+
<source>${jdk.version}</source>
111+
<target>${jdk.version}</target>
112+
</configuration>
113+
</plugin>
114+
115+
<!-- Code coverage using JaCoCo. -->
104116
<plugin>
105117
<groupId>org.jacoco</groupId>
106118
<artifactId>jacoco-maven-plugin</artifactId>
@@ -124,6 +136,7 @@
124136
</executions>
125137
</plugin>
126138

139+
<!-- Code coverage collection using Coveralls.io. -->
127140
<plugin>
128141
<groupId>org.eluder.coveralls</groupId>
129142
<artifactId>coveralls-maven-plugin</artifactId>
@@ -133,6 +146,7 @@
133146
</configuration>
134147
</plugin>
135148

149+
<!-- Unit tests using SureFire. -->
136150
<plugin>
137151
<groupId>org.apache.maven.plugins</groupId>
138152
<artifactId>maven-surefire-plugin</artifactId>
@@ -141,30 +155,18 @@
141155
<forkCount>1</forkCount>
142156
<reuseForks>true</reuseForks>
143157
<!--suppress MavenModelInspection -->
144-
<argLine>${argLine} -Xmx1024m</argLine>
158+
<argLine>${argLine} -Xmx1024m -ea</argLine>
145159
</configuration>
146160
</plugin>
147161

148-
<plugin>
149-
<groupId>org.apache.maven.plugins</groupId>
150-
<artifactId>maven-source-plugin</artifactId>
151-
<version>${maven-source-plugin.version}</version>
152-
<executions>
153-
<execution>
154-
<id>attach-sources</id>
155-
<goals>
156-
<goal>jar-no-fork</goal>
157-
</goals>
158-
</execution>
159-
</executions>
160-
</plugin>
161-
162+
<!-- Project reports. -->
162163
<plugin>
163164
<groupId>org.apache.maven.plugins</groupId>
164165
<artifactId>maven-project-info-reports-plugin</artifactId>
165166
<version>${maven-project-info-reports-plugin.version}</version>
166167
</plugin>
167168

169+
<!-- JavaDoc generation. -->
168170
<plugin>
169171
<groupId>org.apache.maven.plugins</groupId>
170172
<artifactId>maven-javadoc-plugin</artifactId>
@@ -179,6 +181,22 @@
179181
</executions>
180182
</plugin>
181183

184+
<!-- Attach source in JAR. -->
185+
<plugin>
186+
<groupId>org.apache.maven.plugins</groupId>
187+
<artifactId>maven-source-plugin</artifactId>
188+
<version>${maven-source-plugin.version}</version>
189+
<executions>
190+
<execution>
191+
<id>attach-sources</id>
192+
<goals>
193+
<goal>jar-no-fork</goal>
194+
</goals>
195+
</execution>
196+
</executions>
197+
</plugin>
198+
199+
<!-- Staging for Maven Central. -->
182200
<plugin>
183201
<groupId>org.sonatype.plugins</groupId>
184202
<artifactId>nexus-staging-maven-plugin</artifactId>
@@ -191,6 +209,7 @@
191209
</configuration>
192210
</plugin>
193211

212+
<!-- GPG signatures, required for Maven Central. -->
194213
<plugin>
195214
<groupId>org.apache.maven.plugins</groupId>
196215
<artifactId>maven-gpg-plugin</artifactId>
@@ -205,59 +224,55 @@
205224
</execution>
206225
</executions>
207226
</plugin>
208-
209-
<plugin>
210-
<groupId>org.apache.maven.plugins</groupId>
211-
<artifactId>maven-compiler-plugin</artifactId>
212-
<version>${maven-compiler-plugin.version}</version>
213-
<configuration>
214-
<source>${jdk.version}</source>
215-
<target>${jdk.version}</target>
216-
</configuration>
217-
</plugin>
218227
</plugins>
219228
</build>
220229

221230
<reporting>
222231
<plugins>
232+
233+
<!-- JaCoCo coverage reports. -->
223234
<plugin>
224235
<groupId>org.jacoco</groupId>
225236
<artifactId>jacoco-maven-plugin</artifactId>
226237
<version>${jacoco-maven-plugin.version}</version>
227238
</plugin>
228239

240+
<!-- Project info reports. -->
229241
<plugin>
230242
<groupId>org.apache.maven.plugins</groupId>
231243
<artifactId>maven-project-info-reports-plugin</artifactId>
244+
<version>${maven-project-info-reports-plugin.version}</version>
232245
<configuration>
233246
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
234247
</configuration>
235248
</plugin>
236249

250+
<!-- JavaDoc reports. -->
237251
<plugin>
238252
<groupId>org.apache.maven.plugins</groupId>
239253
<artifactId>maven-javadoc-plugin</artifactId>
254+
<version>${maven-javadoc-plugin.version}</version>
240255
</plugin>
241256
</plugins>
242257
</reporting>
243258

244259
<dependencies>
245260
<dependency>
246-
<groupId>log4j</groupId>
247-
<artifactId>log4j</artifactId>
248-
<version>${log4j.version}</version>
261+
<groupId>com.google.code.findbugs</groupId>
262+
<artifactId>jsr305</artifactId>
263+
<version>${jsr305.version}</version>
264+
<type>jar</type>
265+
<scope>provided</scope>
266+
<optional>true</optional>
249267
</dependency>
250268

251269
<dependency>
252-
<groupId>org.slf4j</groupId>
253-
<artifactId>slf4j-api</artifactId>
254-
<version>${slf4j.version}</version>
255-
</dependency>
270+
<groupId>com.google.code.gson</groupId>
271+
<artifactId>gson</artifactId>
272+
<version>${gson.version}</version>
256273

257-
<dependency>
258-
<groupId>org.slf4j</groupId>
259-
<artifactId>slf4j-log4j12</artifactId>
260-
<version>${slf4j.version}</version>
274+
<!-- GSON is only used in unit test. Not part of production code. -->
275+
<scope>test</scope>
261276
</dependency>
262277

263278
<dependency>
@@ -268,19 +283,21 @@
268283
</dependency>
269284

270285
<dependency>
271-
<groupId>com.google.code.findbugs</groupId>
272-
<artifactId>jsr305</artifactId>
273-
<version>${jsr305.version}</version>
274-
<type>jar</type>
275-
<scope>provided</scope>
276-
<optional>true</optional>
286+
<groupId>log4j</groupId>
287+
<artifactId>log4j</artifactId>
288+
<version>${log4j.version}</version>
277289
</dependency>
278290

279291
<dependency>
280-
<groupId>com.google.code.gson</groupId>
281-
<artifactId>gson</artifactId>
282-
<version>${gson.version}</version>
283-
<scope>test</scope>
292+
<groupId>org.slf4j</groupId>
293+
<artifactId>slf4j-api</artifactId>
294+
<version>${slf4j.version}</version>
295+
</dependency>
296+
297+
<dependency>
298+
<groupId>org.slf4j</groupId>
299+
<artifactId>slf4j-log4j12</artifactId>
300+
<version>${slf4j.version}</version>
284301
</dependency>
285302
</dependencies>
286303
</project>

src/site/markdown/ReleaseNotes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
These are the release notes for the Java library for mapcodes.
44

5+
### 2.2.5
6+
7+
* Updated documentation.
8+
9+
* Cleaned up POM, sorted dependencies.
10+
511
### 2.2.4
612

713
* Added Travis CI and Coveralls badges to `README.md`.

src/site/markdown/index.md

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
# Mapcode Library for Java
22

3-
Welcome to the Java library to handle mapcodes. The original C library was created by Pieter Geelen. Work
4-
on the Java version of the Mapcode library was done by Rijn Buve, initial port by Matthew Lowden.
3+
Welcome to the Java library to handle mapcodes. The original C library was created by Pieter Geelen.
4+
The initial port to Java and considerable speed-ups were done by Matthew Lowden.
5+
Rijn Buve has further developed and maintained the Java version of the Mapcode library since.
56

67
## Release Notes
78

89
You can find the release notes for this library at: **[Release Notes](./ReleaseNotes.html)**.
910

1011
## Code Style Settings for IntelliJ IDEA
1112

12-
The Java code uses the default IntelliJ IDEA code style settings for Java.
13+
The Java code uses the *default* [JetBrains IntelliJ IDEA](https://www.jetbrains.com/idea)
14+
code style settings for Java, with one exception:
15+
code blocks are always surround by `{...}` and on separate lines.
1316

14-
How To Build The Mapcode Library JAR File
17+
### How To Build The Mapcode Library JAR File
1518

1619
The sources for the Mapcode Library for Java contain everything to build the Mapcode JAR file as well
1720
as a significant number of unit tests to verify the correctness of the implementation against the
@@ -22,15 +25,16 @@ with JDK 1.6, JDK 1.7 and JDK 1.8.
2225

2326
To build the library:
2427

25-
cd **MAPCODE-HOME**
28+
cd <MAPCODE-HOME>
2629
mvn clean install
2730

28-
This produces a JAR file in your local Maven repository at `~/.m2/repository/com/mapcode/mapcode/x.y/`
31+
This produces a JAR file in your local Maven repository at `~/.m2/repository/com/mapcode/mapcode/<version>/`
2932
You can include this JAR in your project, or store it in your local Nexus repository, for example.
3033

31-
If you creating a Maven project, you can see how to include the JAR in your project in the menu
34+
If you create a Maven project, you can see how to include the JAR in your project in the menu
3235
item `Dependency Information` in the menu on this page.
3336

37+
The latest official version of the libray on Maven Central can be found [**here**](http://search.maven.org/#search%7Cga%7C1%7Cmapcode).
3438

3539
## How To Use This Library In Your Application
3640

@@ -62,9 +66,9 @@ original input.
6266

6367
Example:
6468

65-
final double lat = 52.376514;
66-
final double lon = 4.908542;
67-
final List**Mapcode** results = MapcodeCodec.encode(lat, lon);
69+
double lat = 52.376514;
70+
double lon = 4.908542;
71+
List**Mapcode** results = MapcodeCodec.encode(lat, lon);
6872
// Returns a non-empty list of results.
6973

7074
This produces a non-empty list of resulting mapcodes. The shortest (potentially local) mapcodes is always
@@ -76,8 +80,8 @@ longitude) pair, where encoding is restricted to a specific territory.
7680

7781
Example:
7882

79-
final List**Mapcode** results = MapcodeCodec.encode(lat, lon, Territory.NLD);
80-
// Returns an empty list of results if the location is not within the territory.
83+
List**Mapcode** results = MapcodeCodec.encode(lat, lon, Territory.NLD);
84+
// Returns an empty list of results if the location is not within territory NLD.
8185

8286
This resticts encoding to a specific territory and produces a potentially empty list of results.
8387
Again, if encoding succeeded, the first mapcode is the shortest one and the last mapcode in the list is the
@@ -86,26 +90,27 @@ globally unique international mapcode.
8690
Both `encode()` methods are also offered as a `encodeToShortest()` method, which essentially
8791
returns only the first result of the previous methods (if there are any results).
8892

89-
final Mapcode result = MapcodeCodec.encodeToShortest(lat, lon);
90-
// Always returns a mapcode.
93+
Mapcode result = MapcodeCodec.encodeToShortest(lat, lon);
94+
// Always returns a mapcode (or valid lat and lon values).
9195

9296
try {
93-
final Mapcode result = MapcodeCodec.encodeToShortest(lat, lon, Territory.NLD);
97+
Mapcode result = MapcodeCodec.encodeToShortest(lat, lon, Territory.NLD);
98+
// This may fail.
9499
}
95-
catch (final UnknownMapcodeException e) {
100+
catch (UnknownMapcodeException e) {
96101
// If the location is not within the territory, this exception is thrown.
97102
}
98103

99104
**`Point decode(String mapcode)`** decodes a mapcode to a `Point` which contains a location. Example:
100105

101-
final Point p = MapcodeCodec.decode("NLD 49.4V");
106+
Point p = MapcodeCodec.decode("NLD 49.4V");
102107

103108
**`Point decode(String mapcode, Territory territory)`** decodes a mapcode to a `Point` which contains a
104109
location, where the mapcode must be located within a specific territory.
105110

106111
Examples of usage:
107112

108-
final Point p = MapcodeCodec.decode("49.4V", Territory.NLD);
113+
Point p = MapcodeCodec.decode("49.4V", Territory.NLD);
109114

110115

111116
## Class `Mapcode.java`
@@ -125,12 +130,16 @@ The default precision offered by `getCode()` is approximately 10m (maximum dista
125130
longitude the mapcode decodes to). This corresponds to an area of 20m x 20m (400m2). These mapcodes include
126131
no additional precision digits.
127132

128-
The precision offered by `getMapcodePrecision1()` is approximately 2m.
133+
The precision offered by `getCode(1)` is approximately 2m.
129134
This corresponds to an area of 4m x 4m (16m2). These mapcodes include 1 additional precision digit.
130135

131-
The precision offered by `getMapcodePrecision2()` is approximately 0.40m. This corresponds to an area
136+
The precision offered by `getCode(2)` is approximately 0.40m. This corresponds to an area
132137
of 0.80m x 0.80m (0.64m2). These mapcodes include 2 additional precision digits.
133138

139+
This goes up to `getCode(8)`, which provides nanometer accuracy. (Please note one of the main advantages
140+
of mapcodes over WGS84 coordinates is their simplicity and short size, so try to use as little precision
141+
as required for your application...)
142+
134143
**`Territory getTerritory()`** returns the territory information.
135144

136145
**`toString()`** and **`getCodeWithTerritory()`** return mapcodes string with territory information,
@@ -144,8 +153,9 @@ degrees.
144153

145154
**`Point fromDeg(double latitude, double longitude)`** returns a `Point` for a given (latitude, longitude)
146155
pair. Note that latitudes are always between **-90** and **90**, and longitudes are
147-
always between **-180** and **180** (non-inclusive). Values outside these range are correctly limited
148-
(latitude) or wrapped (longitude) to these ranges.
156+
always between **-180** and **180** (non-inclusive) whenreturned.
157+
However, values outside these range are correctly limited (latitude) or wrapped (longitude) to these ranges
158+
when supplied to the class.
149159

150160
The methods **`double getLat()`** and **`getLon()`** return the latitude and longitude respectively, in degrees.
151161

0 commit comments

Comments
 (0)