/*
 * Java Genetic Algorithm 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 (franz.wilhelmstoetter@gmail.com)
 */
package io.jenetics.jpx.format;

import java.util.Optional;

import io.jenetics.jpx.Latitude;
import io.jenetics.jpx.Length;
import io.jenetics.jpx.Longitude;

/**
 * Aggregation of the three location components: latitude, longitude and
 * elevation.
 *
 * @author <a href="mailto:franz.wilhelmstoetter@gmail.com">Franz Wilhelmstötter</a>
 * @version !__version__!
 * @since !__version__!
 */
public final class Location {
	private final Latitude _latitude;
	private final Longitude _longitude;
	private final Length _elevation;

	private Location(
		final Latitude latitude,
		final Longitude longitude,
		final Length elevation
	) {
		_latitude = latitude;
		_longitude = longitude;
		_elevation = elevation;
	}

	/**
	 * Return the <em>latitude</em> of {@code this} location.
	 *
	 * @return the <em>latitude</em> of {@code this} location, or
	 *         {@link Optional#empty()} if not available
	 */
	public Optional<Latitude> latitude() {
		return Optional.ofNullable(_latitude);
	}

	/**
	 * Return the <em>longitude</em> of {@code this} location.
	 *
	 * @return the <em>longitude</em> of {@code this} location, or
	 *         {@link Optional#empty()} if not available
	 */
	public Optional<Longitude> longitude() {
		return Optional.ofNullable(_longitude);
	}

	/**
	 * Return the <em>elevation</em> of {@code this} location.
	 *
	 * @return the <em>elevation</em> of {@code this} location, or
	 *         {@link Optional#empty()} if not available
	 */
	public Optional<Length> elevation() {
		return Optional.ofNullable(_elevation);
	}

	/**
	 * Create a new <em>location</em> object from the given {@code latitude},
	 * {@code longitude} and {@code elevation}.
	 *
	 * @param latitude the latitude of the location, maybe {@code null}
	 * @param longitude the longitude of the location, maybe {@code null}
	 * @param elevation the elevation if the location, maybe {@code null}
	 * @return a new location object from the given input data
	 */
	public static Location of(
		final Latitude latitude,
		final Longitude longitude,
		final Length elevation
	) {
		return new Location(latitude, longitude, elevation);
	}

	/**
	 * Create a new <em>location</em> object from the given {@code latitude}
	 * and {@code longitude}.
	 *
	 * @param latitude the latitude of the location, maybe {@code null}
	 * @param longitude the longitude of the location, maybe {@code null}
	 * @return a new location object from the given input data
	 */
	public static Location of(final Latitude latitude, final Longitude longitude) {
		return new Location(latitude, longitude, null);
	}

	/**
	 * Create a new <em>location</em> object from the given {@code latitude}.
	 *
	 * @param latitude the latitude of the location, maybe {@code null}
	 * @return a new location object from the given input data
	 */
	public static Location of(final Latitude latitude) {
		return new Location(latitude, null, null);
	}

	/**
	 * Create a new <em>location</em> object from the given {@code longitude}.
	 *
	 * @param longitude the longitude of the location, maybe {@code null}
	 * @return a new location object from the given input data
	 */
	public static Location of(final Longitude longitude) {
		return new Location(null, longitude, null);
	}

}

@@ -770,16 +770,65 @@
 ormat;%0A%0A
+import static java.util.Objects.requireNonNull;%0A%0A
 import j
@@ -944,16 +944,79 @@
 ngitude;
+%0Aimport io.jenetics.jpx.Point;%0Aimport io.jenetics.jpx.WayPoint;
 %0A%0A/**%0A *
@@ -2388,32 +2388,896 @@
 elevation);%0A%09%7D%0A%0A
+%09/**%0A%09 * Return a new %7B@link Point%7D from %7B@code this%7D location. If the%0A%09 * %7B@link #latitude()%7D or the %7B@link #longitude()%7D is not given,%0A%09 * %7B@link Optional#empty()%7D is returned%0A%09 *%0A%09 * @return a new %7B@link Point%7D if the latitude and longitude is given,%0A%09 *         %7B@link Optional#empty()%7D otherwise%0A%09 */%0A%09public Optional%3CPoint%3E toPoint() %7B%0A%09%09return latitude().flatMap(lat -%3E%0A%09%09%09longitude()%0A%09%09%09%09.map(lon -%3E WayPoint.of(lat, lon, _elevation, null))%0A%09%09);%0A%09%7D%0A%0A%09/**%0A%09 * Create a new location form the given GPS point.%0A%09 *%0A%09 * @param point the GPS point%0A%09 * @return a new location form the given GPS point%0A%09 * @throws NullPointerException if the given %7B@code point%7D is %7B@code null%7D%0A%09 */%0A%09public static Location of(final Point point) %7B%0A%09%09requireNonNull(point);%0A%09%09return of(%0A%09%09%09point.getLatitude(),%0A%09%09%09point.getLongitude(),%0A%09%09%09point.getElevation().orElse(null)%0A%09%09);%0A%09%7D%0A%0A
 %09/**%0A%09 * Create 

Add conversion methods from/to 'Point'.