Skip to content

Commit

Permalink
Merge branch 'master' into releases/r4.0.0
Browse files Browse the repository at this point in the history
Signed-off-by: Franz Wilhelmstötter <[email protected]>

# 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
#	settings.gradle.kts
  • Loading branch information
jenetics committed Nov 16, 2024
2 parents 204c335 + 2381b42 commit f6307ac
Show file tree
Hide file tree
Showing 63 changed files with 214,753 additions and 133,964 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
java-version: [ 21 ]
java-version: [ 21, 23 ]
steps:
- uses: actions/checkout@v2

Expand Down
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
[![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)
[![Javadoc](https://www.javadoc.io/badge/io.jenetics/jpx.svg)](http://www.javadoc.io/doc/io.jenetics/jpx)

**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.
**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.

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


## Dependencies

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**.
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**.


## Building JPX

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

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

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

## Examples

### Creating new GPX object with 3 track-points
### Creating a new GPX object with 3 track-points

```java
final GPX gpx = GPX.builder()
.addTrack(track -> track
.addSegment(segment -> segment
.addPoint(p -> p.lat(48.20100).lon(16.31651).ele(283))
.addPoint(p -> p.lat(48.20112).lon(16.31639).ele(278))
.addPoint(p -> p.lat(48.20126).lon(16.31601).ele(274))))
.addPoint(p -> p.lat(48.20100).lon(16.31651).ele(283))
.addPoint(p -> p.lat(48.20112).lon(16.31639).ele(278))
.addPoint(p -> p.lat(48.20126).lon(16.31601).ele(274))))
.build();
```

**Writing GPX object to a file**

```java
GPX.write(gpx, "track.gpx");
GPX.write(gpx, Path.of("track.gpx"));
```

*GPX output*
Expand Down Expand Up @@ -75,7 +75,7 @@ GPX.write(gpx, "track.gpx");
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.

```java
GPX.write(gpx, "track.gpx");
GPX.write(gpx, Path.of("track.gpx"));
GPX.read("gpx.xml").tracks()
.flatMap(Track::segments)
.flatMap(TrackSegment::points)
Expand Down Expand Up @@ -145,7 +145,7 @@ final GPX gpx11 = gpx10.toBuilder()
.build();

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

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

### XML configuration

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:
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:

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.
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.
Expand All @@ -304,7 +304,7 @@ final class ValidatingDocumentBuilder extends XMLProvider {
}
}
```
And don't forget to create a `META-INF/services/io.jenetics.jpx.XMLProvider` file with the following content:
And remember to create a `META-INF/services/io.jenetics.jpx.XMLProvider` file with the following content:

```
org.acme.NonValidatingDocumentBuilder
Expand All @@ -314,7 +314,7 @@ org.acme.NonValidatingDocumentBuilder

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

Copyright 2016-2023 Franz Wilhelmstötter
Copyright 2016-2024 Franz Wilhelmstötter

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

## Release notes

### [3.2.0](https://github.com/jenetics/jpx/releases/tag/v3.2.0)

#### Improvements

* [#183](https://github.com/jenetics/jpx/issues/183): Update Gradle to 8.11 and improve build scripts.
* [#181](https://github.com/jenetics/jpx/pull/181): Update code examples in README.

### [3.1.0](https://github.com/jenetics/jpx/releases/tag/v3.1.0)

#### Improvements
Expand Down
7 changes: 7 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## Release notes

### [3.2.0](https://github.com/jenetics/jpx/releases/tag/v3.2.0)

#### Improvements

* [#183](https://github.com/jenetics/jpx/issues/183): Update Gradle to 8.11 and improve build scripts.
* [#181](https://github.com/jenetics/jpx/pull/181): Update code examples in README.

### [3.0.1](https://github.com/jenetics/jpx/releases/tag/v3.0.1)

#### Bugs
Expand Down
11 changes: 7 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import io.jenetics.gradle.dsl.isModule
import io.jenetics.gradle.dsl.moduleName

/*
* Java GPX Library (@__identifier__@).
* Copyright (c) @__year__@ Franz Wilhelmstötter
Expand Down Expand Up @@ -30,7 +33,7 @@ plugins {
rootProject.version = JPX.VERSION

tasks.named<Wrapper>("wrapper") {
version = "8.4"
version = "8.11"
distributionType = Wrapper.DistributionType.ALL
}

Expand Down Expand Up @@ -110,8 +113,8 @@ fun setupJava(project: Project) {
"Build-OS-Arch" to Env.BUILD_OS_ARCH,
"Build-OS-Version" to Env.BUILD_OS_VERSION
)
if (project.extra.has("moduleName")) {
attr["Automatic-Module-Name"] = project.extra["moduleName"].toString()
if (project.isModule) {
attr["Automatic-Module-Name"] = project.moduleName
}

project.tasks.withType<Jar> {
Expand All @@ -128,7 +131,7 @@ fun setupTestReporting(project: Project) {
project.apply(plugin = "jacoco")

project.configure<JacocoPluginExtension> {
toolVersion = "0.8.9"
toolVersion = "0.8.12"
}

project.tasks {
Expand Down
9 changes: 6 additions & 3 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

/*
Expand All @@ -23,7 +24,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
/**
* @author <a href="mailto:[email protected]">Franz Wilhelmstötter</a>
* @since 2.1
* @version 2.1
* @version 3.2
*/
plugins {
`java-gradle-plugin`
Expand All @@ -35,8 +36,10 @@ repositories {
gradlePluginPortal()
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "17"
tasks.withType<KotlinCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}

configure<JavaPluginExtension> {
Expand Down
18 changes: 9 additions & 9 deletions buildSrc/src/main/kotlin/Env.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ import java.time.format.DateTimeFormatter
* Common environment values.
*/
object Env {
val NOW = ZonedDateTime.now()
private val NOW: ZonedDateTime = ZonedDateTime.now()

val YEAR = Year.now();
private val YEAR: Year = Year.now();

val COPYRIGHT_YEAR = "2016-${YEAR}"

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

val BUILD_DATE = DATE_FORMAT.format(NOW)
val BUILD_DATE: String = DATE_FORMAT.format(NOW)

val BUILD_JDK = System.getProperty("java.version")
val BUILD_JDK: String = System.getProperty("java.version")

val BUILD_OS_NAME = System.getProperty("os.name")
val BUILD_OS_NAME: String = System.getProperty("os.name")

val BUILD_OS_ARCH = System.getProperty("os.arch")
val BUILD_OS_ARCH: String = System.getProperty("os.arch")

val BUILD_OS_VERSION = System.getProperty("os.version")
val BUILD_OS_VERSION: String = System.getProperty("os.version")

val BUILD_BY = System.getProperty("user.name")
val BUILD_BY: String = System.getProperty("user.name")

}

Expand Down
43 changes: 43 additions & 0 deletions buildSrc/src/main/kotlin/io/jenetics/gradle/dsl/Extensions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Java GPX Library (@__identifier__@).
* Copyright (c) @__year__@ Franz Wilhelmstötter
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author:
* Franz Wilhelmstötter ([email protected])
*/

/**
* @author <a href="mailto:[email protected]">Franz Wilhelmstötter</a>
* @since 3.2
* @version 3.2
*/
package io.jenetics.gradle.dsl

import org.gradle.api.Project
import org.gradle.kotlin.dsl.extra

/**
* Gets the module name of the project, as configured in the build file.
*/
var Project.moduleName: String
get() = if (this.isModule) this.extra.get("moduleName").toString()
else this.name
set(value) = this.extra.set("moduleName", value)

/**
* Checks if the project is configured as a module.
*/
val Project.isModule: Boolean
get() = this.extra.has("moduleName")
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

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

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
4 changes: 3 additions & 1 deletion jpx/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import io.jenetics.gradle.dsl.moduleName

/*
* Java GPX Library (@__identifier__@).
* Copyright (c) @__year__@ Franz Wilhelmstötter
Expand Down Expand Up @@ -31,7 +33,7 @@ plugins {

description = "JPX - Java GPX (GPS) Library"

extra["moduleName"] = "io.jenetics.jpx"
moduleName = "io.jenetics.jpx"

dependencies {
testImplementation(libs.assertj)
Expand Down
2 changes: 1 addition & 1 deletion jpx/src/main/java/io/jenetics/jpx/Bounds.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public static Bounds of(
* @return a new {@code Bounds} object with the given extent
* @throws IllegalArgumentException if the latitude values are not within
* the range of {@code [-90..90]}
* @throws IllegalArgumentException if the longitudes value are not within
* @throws IllegalArgumentException if the longitude values are not within
* the range of {@code [-180..180]}
*/
public static Bounds of(
Expand Down
Loading

0 comments on commit f6307ac

Please sign in to comment.