Skip to content

Commit 5d23159

Browse files
committed
Merge branch 'master' into issues/JPX-1-JDBC_access
Signed-off-by: Franz Wilhelmstötter <franz.wilhelmstoetter@gmail.com> ; Conflicts: ; .github/workflows/gradle.yml ; build.gradle.kts ; buildSrc/src/main/kotlin/Env.kt ; jpx/src/main/java/io/jenetics/jpx/GPX.java ; jpx/src/main/java/io/jenetics/jpx/format/Location.java ; jpx/src/main/java/io/jenetics/jpx/geom/MathUtils.java ; jpx/src/main/java/io/jenetics/jpx/package-info.java ; jpx/src/main/java/module-info.java ; jpx/src/test/java/io/jenetics/jpx/GPXTest.java ; settings.gradle.kts
2 parents dfbbf11 + d14c867 commit 5d23159

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+214878
-134026
lines changed

README.md

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.jenetics/jpx/badge.svg)](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22jpx%22)
55
[![Javadoc](https://www.javadoc.io/badge/io.jenetics/jpx.svg)](http://www.javadoc.io/doc/io.jenetics/jpx)
66

7-
**JPX** is a Java library for creating, reading and writing [GPS](https://en.wikipedia.org/wiki/Global_Positioning_System) data in [GPX](https://en.wikipedia.org/wiki/GPS_Exchange_Format) format. It is a *full* implementation of version [1.1](http://www.topografix.com/GPX/1/1/) and version [1.0](http://www.topografix.com/gpx_manual.asp) of the GPX format. The data classes are completely immutable and allows a functional programming style. They are working also nicely with the Java [Stream](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/stream/Stream.html) API. It is also possible to convert the location information into strings which are compatible to the [ISO 6709](http://en.wikipedia.org/wiki/ISO_6709) standard.
7+
**JPX** is a Java library for creating, reading and writing [GPS](https://en.wikipedia.org/wiki/Global_Positioning_System) data in [GPX](https://en.wikipedia.org/wiki/GPS_Exchange_Format) format. It is a *full* implementation of version [1.1](http://www.topografix.com/GPX/1/1/) and version [1.0](http://www.topografix.com/gpx_manual.asp) of the GPX format. The data classes are completely immutable and allows a functional programming style. They are working also nicely with the Java [Stream](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/stream/Stream.html) API. It is also possible to convert the location information into strings which are compatible to the [ISO 6709](http://en.wikipedia.org/wiki/ISO_6709) standard.
88

99
Besides the basic functionality of reading and writing GPX files, the library also allows manipulating the read GPX object in a functional way.
1010

1111

1212
## Dependencies
1313

14-
No external dependencies are needed by the _JPX_ library. It only needs **Java 17** to compile and run. It also runs and compiles with **Java 21**.
14+
The _JPX_ library needs no external dependencies. It only needs **Java 17** to compile and run. It also runs and compiles with **Java 21** and **Java 23**.
1515

1616

1717
## Building JPX
1818

19-
For building the JPX library you have to check out the `master` branch from GitHub.
19+
For building the JPX library, you have to check out the `master` branch from GitHub.
2020

2121
$ git clone https://github.com/jenetics/jpx.git
2222

@@ -32,22 +32,22 @@ For building the JPX library you have to check out the `master` branch from GitH
3232

3333
## Examples
3434

35-
### Creating new GPX object with 3 track-points
35+
### Creating a new GPX object with 3 track-points
3636

3737
```java
3838
final GPX gpx = GPX.builder()
3939
.addTrack(track -> track
4040
.addSegment(segment -> segment
41-
.addPoint(p -> p.lat(48.20100).lon(16.31651).ele(283))
42-
.addPoint(p -> p.lat(48.20112).lon(16.31639).ele(278))
43-
.addPoint(p -> p.lat(48.20126).lon(16.31601).ele(274))))
41+
.addPoint(p -> p.lat(48.20100).lon(16.31651).ele(283))
42+
.addPoint(p -> p.lat(48.20112).lon(16.31639).ele(278))
43+
.addPoint(p -> p.lat(48.20126).lon(16.31601).ele(274))))
4444
.build();
4545
```
4646

4747
**Writing GPX object to a file**
4848

4949
```java
50-
GPX.write(gpx, "track.gpx");
50+
GPX.write(gpx, Path.of("track.gpx"));
5151
```
5252

5353
*GPX output*
@@ -75,7 +75,7 @@ GPX.write(gpx, "track.gpx");
7575
This example writes a given `GPX` object to a file, reads it again and prints the `WayPoint`s of all tracks and all track-segments to the console.
7676

7777
```java
78-
GPX.write(gpx, "track.gpx");
78+
GPX.write(gpx, Path.of("track.gpx"));
7979
GPX.read("gpx.xml").tracks()
8080
.flatMap(Track::segments)
8181
.flatMap(TrackSegment::points)
@@ -145,7 +145,7 @@ final GPX gpx11 = gpx10.toBuilder()
145145
.build();
146146

147147
// Writing GPX to file.
148-
GPX.write(gpx11, "track-v11.gpx");
148+
GPX.write(gpx11, Path.of("track-v11.gpx"));
149149
```
150150

151151
### ISO 6709 location strings
@@ -283,7 +283,7 @@ final GPX gpx1 = gpx.toBuilder()
283283

284284
### XML configuration
285285

286-
The _JPX_ library uses the XML classes available in the Java [`java.xml`](https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/module-summary.html) module. This API is highly configurable and it is possible to replace the underlying implementation. Especially for Android, using different XML implementation is a necessity. _JPX_ uses three _factory_ classes for reading/writing GPX files:
286+
The _JPX_ library uses the XML classes available in the Java [`java.xml`](https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/module-summary.html) module. This API is highly configurable, and it is possible to replace the underlying implementation. Especially for Android, using different XML implementation is a necessity. _JPX_ uses three _factory_ classes for reading/writing GPX files:
287287

288288
1. [`XMLInputFactory`](https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/javax/xml/stream/XMLInputFactory.html): This class is needed for reading GPX files.
289289
1. [`XMLOutputFactory`](https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/javax/xml/stream/XMLOutputFactory.html): This class is needed for writing GPX files.
@@ -304,7 +304,7 @@ final class ValidatingDocumentBuilder extends XMLProvider {
304304
}
305305
}
306306
```
307-
And don't forget to create a `META-INF/services/io.jenetics.jpx.XMLProvider` file with the following content:
307+
And remember to create a `META-INF/services/io.jenetics.jpx.XMLProvider` file with the following content:
308308

309309
```
310310
org.acme.NonValidatingDocumentBuilder
@@ -314,7 +314,7 @@ org.acme.NonValidatingDocumentBuilder
314314

315315
The library is licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html).
316316

317-
Copyright 2016-2023 Franz Wilhelmstötter
317+
Copyright 2016-2025 Franz Wilhelmstötter
318318

319319
Licensed under the Apache License, Version 2.0 (the "License");
320320
you may not use this file except in compliance with the License.
@@ -330,6 +330,19 @@ The library is licensed under the [Apache License, Version 2.0](http://www.apach
330330

331331
## Release notes
332332

333+
### [3.2.1](https://github.com/jenetics/jpx/releases/tag/v3.2.1)
334+
335+
#### Improvements
336+
337+
* [#186](https://github.com/jenetics/jpx/issues/186): LENIENT mode allows GPX tags without creator attributes.
338+
339+
### [3.2.0](https://github.com/jenetics/jpx/releases/tag/v3.2.0)
340+
341+
#### Improvements
342+
343+
* [#183](https://github.com/jenetics/jpx/issues/183): Update Gradle to 8.11 and improve build scripts.
344+
* [#181](https://github.com/jenetics/jpx/pull/181): Update code examples in README.
345+
333346
### [3.1.0](https://github.com/jenetics/jpx/releases/tag/v3.1.0)
334347

335348
#### Improvements

RELEASE_NOTES.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
## Release notes
22

3+
### [3.2.1](https://github.com/jenetics/jpx/releases/tag/v3.2.1)
4+
5+
#### Improvements
6+
7+
* [#186](https://github.com/jenetics/jpx/issues/186): LENIENT mode allows GPX tags without creator attributes.
8+
9+
### [3.2.0](https://github.com/jenetics/jpx/releases/tag/v3.2.0)
10+
11+
#### Improvements
12+
13+
* [#183](https://github.com/jenetics/jpx/issues/183): Update Gradle to 8.11 and improve build scripts.
14+
* [#181](https://github.com/jenetics/jpx/pull/181): Update code examples in README.
15+
316
### [3.0.1](https://github.com/jenetics/jpx/releases/tag/v3.0.1)
417

518
#### Bugs

build.gradle.kts

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import io.jenetics.gradle.dsl.isModule
2+
import io.jenetics.gradle.dsl.moduleName
3+
14
/*
25
* Java GPX Library (@__identifier__@).
36
* Copyright (c) @__year__@ Franz Wilhelmstötter
@@ -25,12 +28,13 @@
2528
*/
2629
plugins {
2730
base
31+
id("me.champeau.jmh") version "0.7.2" apply false
2832
}
2933

3034
rootProject.version = JPX.VERSION
3135

3236
tasks.named<Wrapper>("wrapper") {
33-
version = "8.4"
37+
version = "8.11"
3438
distributionType = Wrapper.DistributionType.ALL
3539
}
3640

@@ -110,8 +114,8 @@ fun setupJava(project: Project) {
110114
"Build-OS-Arch" to Env.BUILD_OS_ARCH,
111115
"Build-OS-Version" to Env.BUILD_OS_VERSION
112116
)
113-
if (project.extra.has("moduleName")) {
114-
attr["Automatic-Module-Name"] = project.extra["moduleName"].toString()
117+
if (project.isModule) {
118+
attr["Automatic-Module-Name"] = project.moduleName
115119
}
116120

117121
project.tasks.withType<Jar> {
@@ -128,7 +132,7 @@ fun setupTestReporting(project: Project) {
128132
project.apply(plugin = "jacoco")
129133

130134
project.configure<JacocoPluginExtension> {
131-
toolVersion = "0.8.9"
135+
toolVersion = "0.8.12"
132136
}
133137

134138
project.tasks {
@@ -188,6 +192,38 @@ fun setupJavadoc(project: Project) {
188192
}
189193
}
190194
}
195+
196+
val javadoc = project.tasks.findByName("javadoc") as Javadoc?
197+
if (javadoc != null) {
198+
project.tasks.register<io.jenetics.gradle.ColorizerTask>("colorizer") {
199+
directory = javadoc.destinationDir!!
200+
}
201+
202+
project.tasks.register("java2html") {
203+
doLast {
204+
providers.javaexec {
205+
mainClass.set("de.java2html.Java2Html")
206+
args = listOf(
207+
"-srcdir", "src/main/java",
208+
"-targetdir", "${javadoc.destinationDir}/src-html/${project.extra["moduleName"]}"
209+
)
210+
classpath = files("${project.rootDir}/buildSrc/lib/java2html.jar")
211+
}
212+
}
213+
}
214+
215+
javadoc.doLast {
216+
val colorizer = project.tasks.findByName("colorizer")
217+
colorizer?.actions?.forEach {
218+
it.execute(colorizer)
219+
}
220+
221+
val java2html = project.tasks.findByName("java2html")
222+
java2html?.actions?.forEach {
223+
it.execute(java2html)
224+
}
225+
}
226+
}
191227
}
192228

193229
/**

buildSrc/build.gradle.kts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
12
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
23

34
/*
@@ -23,7 +24,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2324
/**
2425
* @author <a href="mailto:franz.wilhelmstoetter@gmail.com">Franz Wilhelmstötter</a>
2526
* @since 2.1
26-
* @version 2.1
27+
* @version 3.2
2728
*/
2829
plugins {
2930
`java-gradle-plugin`
@@ -35,8 +36,10 @@ repositories {
3536
gradlePluginPortal()
3637
}
3738

38-
tasks.withType<KotlinCompile>().configureEach {
39-
kotlinOptions.jvmTarget = "17"
39+
tasks.withType<KotlinCompile> {
40+
compilerOptions {
41+
jvmTarget.set(JvmTarget.JVM_17)
42+
}
4043
}
4144

4245
configure<JavaPluginExtension> {

buildSrc/src/main/kotlin/Env.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,25 @@ import java.time.format.DateTimeFormatter
2626
* Common environment values.
2727
*/
2828
object Env {
29-
val NOW = ZonedDateTime.now()
29+
private val NOW: ZonedDateTime = ZonedDateTime.now()
3030

31-
val YEAR = Year.now();
31+
private val YEAR: Year = Year.now();
3232

3333
val COPYRIGHT_YEAR = "2016-${YEAR}"
3434

35-
val DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")
35+
private val DATE_FORMAT: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")
3636

37-
val BUILD_DATE = DATE_FORMAT.format(NOW)
37+
val BUILD_DATE: String = DATE_FORMAT.format(NOW)
3838

39-
val BUILD_JDK = System.getProperty("java.version")
39+
val BUILD_JDK: String = System.getProperty("java.version")
4040

41-
val BUILD_OS_NAME = System.getProperty("os.name")
41+
val BUILD_OS_NAME: String = System.getProperty("os.name")
4242

43-
val BUILD_OS_ARCH = System.getProperty("os.arch")
43+
val BUILD_OS_ARCH: String = System.getProperty("os.arch")
4444

45-
val BUILD_OS_VERSION = System.getProperty("os.version")
45+
val BUILD_OS_VERSION: String = System.getProperty("os.version")
4646

47-
val BUILD_BY = System.getProperty("user.name")
47+
val BUILD_BY: String = System.getProperty("user.name")
4848

4949
}
5050

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Java GPX Library (@__identifier__@).
3+
* Copyright (c) @__year__@ Franz Wilhelmstötter
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
* Author:
18+
* Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
19+
*/
20+
21+
/**
22+
* @author <a href="mailto:franz.wilhelmstoetter@gmail.com">Franz Wilhelmstötter</a>
23+
* @since 3.2
24+
* @version 3.2
25+
*/
26+
package io.jenetics.gradle.dsl
27+
28+
import org.gradle.api.Project
29+
import org.gradle.kotlin.dsl.extra
30+
31+
/**
32+
* Gets the module name of the project, as configured in the build file.
33+
*/
34+
var Project.moduleName: String
35+
get() = if (this.isModule) this.extra.get("moduleName").toString()
36+
else this.name
37+
set(value) = this.extra.set("moduleName", value)
38+
39+
/**
40+
* Checks if the project is configured as a module.
41+
*/
42+
val Project.isModule: Boolean
43+
get() = this.extra.has("moduleName")

gradle/wrapper/gradle-wrapper.jar

-19.7 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-all.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,8 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90+
' "$PWD" ) || exit
8891

8992
# Use the maximum available, or set MAX_FD != -1 to use that value.
9093
MAX_FD=maximum

0 commit comments

Comments
 (0)