Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • debian-gis-team/jts
1 result
Show changes
Commits on Source (13)
Showing
with 348 additions and 90 deletions
JTS Upgrade Guide
=================
JTS 1.16
--------
Coordinate and CoordinateSequence now define methods for XYZM access, with this in mind we ask the field ``z`` is deprecated and we ask client code to use ``coord.getZ()``.
JTS 1.15
--------
The JTS Topology Suite has a long history, and in 2016/2017, [Vivid Solutions](http://www.vividsolutions.com/) brought the project to the LocationTech working group of the Eclipse Foundation.
During that transition, the Java package names and Maven GAVs have changed. For package names (typically used in imports), the change is reflected below:
......
jts (1.15.1+ds-1~exp2) UNRELEASED; urgency=medium
jts (1.16.0~rc1+ds-1~exp1) experimental; urgency=medium
* Team upload.
* New upstream release candidate.
* Bump Standards-Version to 4.2.0, no changes.
* Update watch file to limit matches to archive path.
* Update copyright holders.
-- Bas Couwenberg <sebastic@debian.org> Mon, 20 Aug 2018 09:23:23 +0200
jts (1.15.1+ds-2) unstable; urgency=medium
* Team upload.
* Drop autopkgtest to test installability.
* Add lintian override for testsuite-autopkgtest-missing.
-- Bas Couwenberg <sebastic@debian.org> Tue, 31 Jul 2018 19:30:59 +0200
jts (1.15.1+ds-1) unstable; urgency=medium
* Team upload.
* Bump Standards-Version to 4.1.5, no changes.
* Move from experimental to unstable.
-- Bas Couwenberg <sebastic@debian.org> Thu, 05 Jul 2018 10:15:25 +0200
-- Bas Couwenberg <sebastic@debian.org> Sat, 07 Jul 2018 20:08:09 +0200
jts (1.15.1+ds-1~exp1) experimental; urgency=medium
......
......@@ -16,7 +16,7 @@ Build-Depends-Indep: default-jdk-doc,
libmaven-javadoc-plugin-java,
libmaven-source-plugin-java,
junit
Standards-Version: 4.1.5
Standards-Version: 4.2.0
Vcs-Browser: https://salsa.debian.org/debian-gis-team/jts
Vcs-Git: https://salsa.debian.org/debian-gis-team/jts.git -b experimental
Homepage: https://locationtech.github.io/jts/
......
......@@ -6,10 +6,12 @@ Source: https://github.com/locationtech/jts
Files-Excluded: doc/*.pdf
Files: *
Copyright: 2016, Vivid Solutions
2016, Martin Davis
2003, Open Source Geospatial Foundation
2017, Jia Yu
Copyright: 2016, 2018, Vivid Solutions
2018, Contributors to the Eclipse Foundation
2018, Felix Obermaier
2017, Jia Yu
2016, Martin Davis
2003, Open Source Geospatial Foundation
License: EPL-1.0 or EDL-1.0
Files: modules/app/src/main/java/org/locationtech/jtstest/testbuilder/io/shapefile/Shapefile.java
......
# Not worth the effort
testsuite-autopkgtest-missing
# Test installability
Depends: @
Test-Command: /bin/true
......@@ -5,4 +5,4 @@ uversionmangle=s/(\d)[_\.\-\+]?((RC|rc|pre|dev|beta|alpha|M)\d*)$/$1~$2/;s/RC/rc
filenamemangle=s/(?:.*?\/)?(?:rel|v|jts)?[\-\_]?(\d\S+)\.(tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))/jts-$1.$2/,\
repacksuffix=+ds \
https://github.com/locationtech/jts/releases \
(?:.*?/)?(?:rel|v|jts)?[\-\_]?(\d\S+)\.(?:tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))
(?:.*?/archive/)?(?:rel|v|jts)?[\-\_]?(\d\S+)\.(?:tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))
......@@ -22,6 +22,27 @@ This document lists the change history of release versions of the
The JTS distributions for older versions can be obtained at the
<a href='http://sourceforge.net/projects/jts-topo-suite/'><b>SourceForge JTS site</b></a>.
</p>
<!-- ================================================================ -->
<hr size='4' color='darkblue'>
<h2>Version 1.16</h2>
<i>Release Date: September 10, 2018</i>
<h3>API Changes</h3>
<ul>
<li>Added XYZM support to <code>CoordinateSequence</code> and <code>CoordinateSequenceFactory</code> with <code>getDimension()</code> and <code>getMeasures()</code> information.</li>
<li>Introduced <code>Coordinate</code> methods for <code>getX()</code>, <code>getY()</code>, <code>getZ()</code>, and <code>getM()</code>.</li>
<li>Deprecated <code>Coordiante.z</code field, use <code>Coordinate.getZ()</code>.
<li><code>Coordinate</code> subclasses introduced for XY, XYM, XYZM representations.</li>
</ul>
<h3>Functionality Improvements</h3>
<ul>
<li>Removed <code>PackedCoordinateSequenceFactory</code> constructor used to supply a default dimension, use appropriate <code>create( size, dimension )</code> instead.</li>
<li>WKTReader and WKTWriter support for measures</li>
</ul>
<!-- ================================================================ -->
<hr size='4' color='darkblue'>
<h2>Version 1.15</h2>
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-modules</artifactId>
<version>1.15.1</version>
<version>1.16.0-RC1</version>
</parent>
<artifactId>jts-app</artifactId>
<name>${project.groupId}:${project.artifactId}</name>
......
......@@ -112,7 +112,7 @@ public class MultiLineHandler implements ShapeHandler{
for (int t =0;t<numPoints; t++)
{
coords[t].z = file.readDoubleLE(); //z value
coords[t].setZ(file.readDoubleLE()); //z value
actualReadWords += 4;
}
}
......@@ -227,7 +227,7 @@ public class MultiLineHandler implements ShapeHandler{
for (int t=0;t<cs.length; t++)
{
z= cs[t].z ;
z= cs[t].getZ() ;
if (!(Double.isNaN( z ) ))
{
if (validZFound)
......
......@@ -96,7 +96,7 @@ public class MultiPointHandler implements ShapeHandler {
{
double z = file.readDoubleLE();//z
actualReadWords += 4;
coords[t].z = z;
coords[t].setZ(z);
}
}
......@@ -152,7 +152,7 @@ public class MultiPointHandler implements ShapeHandler {
for (int t=0;t<cs.length; t++)
{
z= cs[t].z ;
z= cs[t].getZ();
if (!(Double.isNaN( z ) ))
{
if (validZFound)
......
......@@ -68,7 +68,7 @@ public class PolygonHandler implements ShapeHandler{
{
p = pointList[t];
if ( (testPoint.x == p.x) && (testPoint.y == p.y) &&
((testPoint.z == p.z) || (!(testPoint.z == testPoint.z)) ) //nan test; x!=x iff x is nan
((testPoint.getZ() == p.getZ()) || (!(testPoint.getZ() == testPoint.getZ())) ) //nan test; x!=x iff x is nan
)
{
return true;
......@@ -138,7 +138,7 @@ public class PolygonHandler implements ShapeHandler{
actualReadWords += 8;
for(int t=0;t<numPoints;t++)
{
coords[t].z = file.readDoubleLE();
coords[t].setZ(file.readDoubleLE());
actualReadWords += 4;
}
}
......@@ -339,7 +339,7 @@ public class PolygonHandler implements ShapeHandler{
for (int t=0;t<cs.length; t++)
{
z= cs[t].z ;
z= cs[t].getZ() ;
if (!(Double.isNaN( z ) ))
{
if (validZFound)
......
......@@ -372,9 +372,9 @@ public class SVGWriter
throws IOException
{
writer.write(writeNumber(coordinate.x) + " " + writeNumber(coordinate.y));
if (outputDimension >= 3 && ! Double.isNaN(coordinate.z)) {
if (outputDimension >= 3 && ! Double.isNaN(coordinate.getZ())) {
writer.write(" ");
writer.write(writeNumber(coordinate.z));
writer.write(writeNumber(coordinate.getZ()));
}
}
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-modules</artifactId>
<version>1.15.1</version>
<version>1.16.0-RC1</version>
</parent>
<artifactId>jts-core</artifactId>
<name>${project.groupId}:${project.artifactId}</name>
......
......@@ -36,7 +36,7 @@ public class JTSVersion {
/**
* The minor version number.
*/
public static final int MINOR = 15;
public static final int MINOR = 16;
/**
* The patch version number.
......@@ -46,7 +46,7 @@ public class JTSVersion {
/**
* An optional string providing further release info (such as "alpha 1");
*/
private static final String releaseInfo = "";
private static final String releaseInfo = "RC1";
/**
* Prints the current JTS version to stdout.
......
......@@ -29,12 +29,12 @@ public class CGAlgorithms3D
public static double distance(Coordinate p0, Coordinate p1)
{
// default to 2D distance if either Z is not set
if (Double.isNaN(p0.z) || Double.isNaN(p1.z))
if (Double.isNaN(p0.getZ()) || Double.isNaN(p1.getZ()))
return p0.distance(p1);
double dx = p0.x - p1.x;
double dy = p0.y - p1.y;
double dz = p0.z - p1.z;
double dz = p0.getZ() - p1.getZ();
return Math.sqrt(dx * dx + dy * dy + dz * dz);
}
......@@ -58,10 +58,10 @@ public class CGAlgorithms3D
* 0<r<1 P is interior to AB
*/
double len2 = (B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y) + (B.z - A.z) * (B.z - A.z);
double len2 = (B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y) + (B.getZ() - A.getZ()) * (B.getZ() - A.getZ());
if (Double.isNaN(len2))
throw new IllegalArgumentException("Ordinates must not be NaN");
double r = ((p.x - A.x) * (B.x - A.x) + (p.y - A.y) * (B.y - A.y) + (p.z - A.z) * (B.z - A.z))
double r = ((p.x - A.x) * (B.x - A.x) + (p.y - A.y) * (B.y - A.y) + (p.getZ() - A.getZ()) * (B.getZ() - A.getZ()))
/ len2;
if (r <= 0.0)
......@@ -72,11 +72,11 @@ public class CGAlgorithms3D
// compute closest point q on line segment
double qx = A.x + r * (B.x - A.x);
double qy = A.y + r * (B.y - A.y);
double qz = A.z + r * (B.z - A.z);
double qz = A.getZ() + r * (B.getZ() - A.getZ());
// result is distance from p to q
double dx = p.x - qx;
double dy = p.y - qy;
double dz = p.z - qz;
double dz = p.getZ() - qz;
return Math.sqrt(dx*dx + dy*dy + dz*dz);
}
......@@ -149,11 +149,11 @@ public class CGAlgorithms3D
*/
double x1 = A.x + s * (B.x - A.x);
double y1 = A.y + s * (B.y - A.y);
double z1 = A.z + s * (B.z - A.z);
double z1 = A.getZ() + s * (B.getZ() - A.getZ());
double x2 = C.x + t * (D.x - C.x);
double y2 = C.y + t * (D.y - C.y);
double z2 = C.z + t * (D.z - C.z);
double z2 = C.getZ() + t * (D.getZ() - C.getZ());
// length (p1-p2)
return distance(new Coordinate(x1, y1, z1), new Coordinate(x2, y2, z2));
......
/*
* Copyright (c) 2016 Vivid Solutions.
* Copyright (c) 2018 Vivid Solutions
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
......@@ -19,25 +19,29 @@ import org.locationtech.jts.util.NumberUtil;
/**
* A lightweight class used to store coordinates
* on the 2-dimensional Cartesian plane.
* A lightweight class used to store coordinates on the 2-dimensional Cartesian plane.
* <p>
* It is distinct from {@link Point}, which is a subclass of {@link Geometry}.
* Unlike objects of type {@link Point} (which contain additional
* information such as an envelope, a precision model, and spatial reference
* system information), a <code>Coordinate</code> only contains ordinate values
* and accessor methods. <P>
*
* and accessor methods. </p>
* <p>
* <code>Coordinate</code>s are two-dimensional points, with an additional Z-ordinate.
* If an Z-ordinate value is not specified or not defined,
* constructed coordinates have a Z-ordinate of <code>NaN</code>
* (which is also the value of <code>NULL_ORDINATE</code>).
* The standard comparison functions ignore the Z-ordinate.
* Apart from the basic accessor functions, JTS supports
* only specific operations involving the Z-ordinate.
* only specific operations involving the Z-ordinate.</p>
* <p>
* Implementations may optionally support Z-ordiante and M-measure values
* as appropriate for a CoordinateSeqeunce. Use of {@link #getZ()} and {@link #getM()}
* accessors, or {@link #getOrdinate(int)} are recommended.</p>
*
*@version 1.7
* @version 1.16
*/
public class Coordinate implements Comparable, Cloneable, Serializable {
public class Coordinate implements Comparable<Coordinate>, Cloneable, Serializable {
private static final long serialVersionUID = 6683108902428366910L;
/**
......@@ -47,32 +51,50 @@ public class Coordinate implements Comparable, Cloneable, Serializable {
*/
public static final double NULL_ORDINATE = Double.NaN;
/**
* Standard ordinate index values
*/
/** Standard ordinate index value for, where X is 0 */
public static final int X = 0;
/** Standard ordinate index value for, where Y is 1 */
public static final int Y = 1;
/**
* Standard ordinate index value for, where Z is 2.
*
* <p>This constant assumes XYZM coordinate sequence definition, please check this assumption
* using {@link #getDimension()} and {@link #getMeasures()} before use.
*/
public static final int Z = 2;
/**
* The x-coordinate.
* Standard ordinate index value for, where M is 3.
*
* <p>This constant assumes XYZM coordinate sequence definition, please check this assumption
* using {@link #getDimension()} and {@link #getMeasures()} before use.
*/
public static final int M = 3;
/**
* The x-ordinate.
*/
public double x;
/**
* The y-coordinate.
* The y-ordinate.
*/
public double y;
/**
* The z-coordinate.
* The z-ordinate.
* @deprecated Recommend {@link #getZ()}
*/
public double z;
/**
* Constructs a <code>Coordinate</code> at (x,y,z).
*
*@param x the x-value
*@param y the y-value
*@param z the z-value
*@param x the x-ordinate
*@param y the y-ordinate
*@param z the z-ordinate
*/
public Coordinate(double x, double y, double z) {
this.x = x;
......@@ -94,7 +116,7 @@ public class Coordinate implements Comparable, Cloneable, Serializable {
*@param c the <code>Coordinate</code> to copy.
*/
public Coordinate(Coordinate c) {
this(c.x, c.y, c.z);
this(c.x, c.y, c.getZ());
}
/**
......@@ -115,12 +137,63 @@ public class Coordinate implements Comparable, Cloneable, Serializable {
public void setCoordinate(Coordinate other) {
x = other.x;
y = other.y;
z = other.z;
z = other.getZ();
}
/**
* The x-ordinate.
*/
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
/**
* The y-ordinate.
*/
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
/**
* The z-ordinate.
*/
public double getZ() {
return z;
}
/**
* The z-ordinate.
*
* @param z
*/
public void setZ(double z) {
this.z = z;
}
/**
* The m-measure, if available.
*/
public double getM() {
return Double.NaN;
}
/**
* The m-measure, if supported.
*
* @param m
*/
public void setM(double m) {
throw new IllegalArgumentException("Invalid ordinate index: " + M);
}
/**
* Gets the ordinate value for the given index.
* The supported values for the index are
*
* The base implementation supports values for the index are
* {@link X}, {@link Y}, and {@link Z}.
*
* @param ordinateIndex the ordinate index
......@@ -132,7 +205,7 @@ public class Coordinate implements Comparable, Cloneable, Serializable {
switch (ordinateIndex) {
case X: return x;
case Y: return y;
case Z: return z;
case Z: return getZ(); // sure to delegate to subclass rather than offer direct field access
}
throw new IllegalArgumentException("Invalid ordinate index: " + ordinateIndex);
}
......@@ -140,7 +213,8 @@ public class Coordinate implements Comparable, Cloneable, Serializable {
/**
* Sets the ordinate for the given index
* to a given value.
* The supported values for the index are
*
* The base implementation supported values for the index are
* {@link X}, {@link Y}, and {@link Z}.
*
* @param ordinateIndex the ordinate index
......@@ -157,7 +231,7 @@ public class Coordinate implements Comparable, Cloneable, Serializable {
y = value;
break;
case Z:
z = value;
setZ(value); // delegate to subclass rather than offer direct field access
break;
default:
throw new IllegalArgumentException("Invalid ordinate index: " + ordinateIndex);
......@@ -209,8 +283,8 @@ public class Coordinate implements Comparable, Cloneable, Serializable {
*/
public boolean equals3D(Coordinate other) {
return (x == other.x) && (y == other.y) &&
((z == other.z) ||
(Double.isNaN(z) && Double.isNaN(other.z)));
((getZ() == other.getZ()) ||
(Double.isNaN(getZ()) && Double.isNaN(other.getZ())));
}
/**
......@@ -221,7 +295,7 @@ public class Coordinate implements Comparable, Cloneable, Serializable {
* @return true if the Z ordinates are within the given tolerance
*/
public boolean equalInZ(Coordinate c, double tolerance){
return NumberUtil.equalsWithTolerance(this.z, c.z, tolerance);
return NumberUtil.equalsWithTolerance(this.getZ(), c.getZ(), tolerance);
}
/**
......@@ -258,7 +332,7 @@ public class Coordinate implements Comparable, Cloneable, Serializable {
*@return -1, zero, or 1 as this <code>Coordinate</code>
* is less than, equal to, or greater than the specified <code>Coordinate</code>
*/
public int compareTo(Object o) {
public int compareTo(Coordinate o) {
Coordinate other = (Coordinate) o;
if (x < other.x) return -1;
......@@ -274,7 +348,7 @@ public class Coordinate implements Comparable, Cloneable, Serializable {
*@return a <code>String</code> of the form <I>(x,y,z)</I>
*/
public String toString() {
return "(" + x + ", " + y + ", " + z + ")";
return "(" + x + ", " + y + ", " + getZ() + ")";
}
public Object clone() {
......@@ -316,7 +390,7 @@ public class Coordinate implements Comparable, Cloneable, Serializable {
public double distance3D(Coordinate c) {
double dx = x - c.x;
double dy = y - c.y;
double dz = z - c.z;
double dz = getZ() - c.getZ();
return Math.sqrt(dx * dx + dy * dy + dz * dz);
}
......@@ -350,7 +424,7 @@ public class Coordinate implements Comparable, Cloneable, Serializable {
* or 3-dimensional comparison, and handling NaN values correctly.
*/
public static class DimensionalComparator
implements Comparator
implements Comparator<Coordinate>
{
/**
* Compare two <code>double</code>s, allowing for NaN values.
......@@ -407,11 +481,8 @@ public class Coordinate implements Comparable, Cloneable, Serializable {
* equal to, or greater than 02
*
*/
public int compare(Object o1, Object o2)
public int compare(Coordinate c1, Coordinate c2)
{
Coordinate c1 = (Coordinate) o1;
Coordinate c2 = (Coordinate) o2;
int compX = compare(c1.x, c2.x);
if (compX != 0) return compX;
......@@ -420,7 +491,7 @@ public class Coordinate implements Comparable, Cloneable, Serializable {
if (dimensionsToTest <= 2) return 0;
int compZ = compare(c1.z, c2.z);
int compZ = compare(c1.getZ(), c2.getZ());
return compZ;
}
}
......
......@@ -25,11 +25,43 @@ import org.locationtech.jts.math.MathUtil;
* @version 1.7
*/
public class CoordinateArrays {
private final static Coordinate[] coordArrayType = new Coordinate[0];
private CoordinateArrays() {}
/**
* Determine dimension based on subclass of {@link Coordinate}.
*
* @param pts supplied coordinates
* @return number of ordinates recorded
*/
public static int dimension(Coordinate[] pts) {
if( pts == null || pts.length == 0) {
return 3; // unknown, assume default
}
int dimension = 0;
for(Coordinate coordinate : pts ) {
dimension = Math.max(dimension, Coordinates.dimension( coordinate ));
}
return dimension;
}
/**
* Determine number of measures based on subclass of {@link Coordinate}.
*
* @param pts supplied coordinates
* @return number of measures recorded
*/
public static int measures(Coordinate[] pts) {
if( pts == null || pts.length == 0) {
return 0; // unknown, assume default
}
int measures = 0;
for(Coordinate coordinate : pts ) {
measures = Math.max(measures, Coordinates.measures( coordinate ));
}
return measures;
}
/**
* Tests whether an array of {@link Coordinate}s forms a ring,
* by checking length and closure.
......@@ -212,7 +244,7 @@ public class CoordinateArrays {
public static Coordinate[] copyDeep(Coordinate[] coordinates) {
Coordinate[] copy = new Coordinate[coordinates.length];
for (int i = 0; i < coordinates.length; i++) {
copy[i] = new Coordinate(coordinates[i]);
copy[i] = coordinates[i].copy();
}
return copy;
}
......@@ -231,7 +263,7 @@ public class CoordinateArrays {
*/
public static void copyDeep(Coordinate[] src, int srcStart, Coordinate[] dest, int destStart, int length) {
for (int i = 0; i < length; i++) {
dest[destStart + i] = new Coordinate(src[srcStart + i]);
dest[destStart + i] = src[srcStart + i].copy();
}
}
......
......@@ -25,9 +25,10 @@ import java.util.Iterator;
* @version 1.7
*/
public class CoordinateList
extends ArrayList
extends ArrayList<Coordinate>
{
//With contributions from Markus Schaber [schabios@logi-track.com]
private static final long serialVersionUID = -1626110935756089896L;
//With contributions from Markus Schaber [schabios@logi-track.com]
//[Jon Aquino 2004-03-25]
private final static Coordinate[] coordArrayType = new Coordinate[0];
......@@ -64,8 +65,8 @@ public class CoordinateList
add(coord, allowRepeated);
}
public void add(Coordinate coord) {
super.add(coord);
public boolean add(Coordinate coord) {
return super.add(coord);
}
public Coordinate getCoordinate(int i) { return (Coordinate) get(i); }
......@@ -186,11 +187,11 @@ public class CoordinateList
* @param allowRepeated if set to false, repeated coordinates are collapsed
* @return true (as by general collection contract)
*/
public boolean addAll(Collection coll, boolean allowRepeated)
public boolean addAll(Collection<? extends Coordinate> coll, boolean allowRepeated)
{
boolean isChanged = false;
for (Iterator i = coll.iterator(); i.hasNext(); ) {
add((Coordinate) i.next(), allowRepeated);
for (Iterator<? extends Coordinate> i = coll.iterator(); i.hasNext(); ) {
add(i.next(), allowRepeated);
isChanged = true;
}
return isChanged;
......@@ -201,8 +202,10 @@ public class CoordinateList
*/
public void closeRing()
{
if (size() > 0)
add(new Coordinate((Coordinate) get(0)), false);
if (size() > 0) {
Coordinate duplicate = get(0).copy();
add(duplicate, false);
}
}
/** Returns the Coordinates in this collection.
......@@ -221,8 +224,8 @@ public class CoordinateList
*/
public Object clone() {
CoordinateList clone = (CoordinateList) super.clone();
for (int i = 0; i < this.size(); i++) {
clone.add(i, ((Coordinate) this.get(i)).clone());
for (int i = 0; i < this.size(); i++) {
clone.add(i, (Coordinate) this.get(i).clone());
}
return clone;
}
......
/*
* Copyright (c) 2016 Vivid Solutions.
* Copyright (c) 2018 Vivid Solutions
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
......@@ -45,22 +45,89 @@ import org.locationtech.jts.geom.impl.PackedCoordinateSequenceFactory;
public interface CoordinateSequence
extends Cloneable
{
/**
* Standard ordinate index values
*/
/** Standard ordinate index value for, where X is 0 */
int X = 0;
/** Standard ordinate index value for, where Y is 1 */
int Y = 1;
/**
* Standard ordinate index value for, where Z is 2.
*
* <p>This constant assumes XYZM coordinate sequence definition, please check this assumption
* using {@link #getDimension()} and {@link #getMeasures()} before use.
*/
/** Standard z-ordinate index */
int Z = 2;
/**
* Standard ordinate index value for, where M is 3.
*
* <p>This constant assumes XYZM coordinate sequence definition, please check this assumption
* using {@link #getDimension()} and {@link #getMeasures()} before use.
*/
int M = 3;
/**
* Returns the dimension (number of ordinates in each coordinate)
* for this sequence.
* Returns the dimension (number of ordinates in each coordinate) for this sequence.
*
* <p>This total includes any measures, indicated by non-zero {@link #getMeasures()}.
*
* @return the dimension of the sequence.
*/
int getDimension();
/**
* Returns the number of measures included in {@link #getDimension()} for each coordinate for this
* sequence.
*
* For a measured coordinate sequence a non-zero value is returned.
* <ul>
* <li>For XY sequence measures is zero</li>
* <li>For XYM sequence measure is one<li>
* <li>For XYZ sequence measure is zero</li>
* <li>For XYZM sequence measure is one</li>
* <li>Values greater than one are supported</li>
* </ul>
*
* @return the number of measures included in dimension
*/
default int getMeasures() {
return 0;
}
/**
* Checks {@link #getDimension()} and {@link #getMeasures()} to determine if {@link #getZ(int)}
* is supported.
*
* @return true if {@link #getZ(int)} is supported.
*/
default boolean hasZ() {
return (getDimension()-getMeasures()) > 2;
}
/**
* Checks {@link #getMeasures()} to determine if {@link #getM(int)}
* is supported.
*
* @return true if {@link #getM(int)} is supported.
*/
default boolean hasM() {
return getDimension()>2 && getMeasures() > 0;
}
/**
* Creates a coordinate for use in this sequence.
* <p>
* The coordinate is created supporting the same number of {@link #getDimension()} and {@link #getMeasures()}
* as this sequence and is suitable for use with {@link #getCoordinate(int, Coordinate)}.
* </p>
* @return coordinate for use with this sequence
*/
default Coordinate createCoordinate() {
return Coordinates.create(getDimension(), getMeasures());
}
/**
* Returns (possibly a copy of) the i'th coordinate in this sequence.
* Whether or not the Coordinate returned is the actual underlying
......@@ -112,11 +179,45 @@ public interface CoordinateSequence
*/
double getY(int index);
/**
* Returns ordinate Z of the specified coordinate if available.
*
* @param index
* @return the value of the Z ordinate in the index'th coordinate, or Double.NaN if not defined.
*/
default double getZ(int index)
{
if (hasZ()) {
return getOrdinate(index, 2);
} else {
return Double.NaN;
}
}
/**
* Returns ordinate M of the specified coordinate if available.
*
* @param index
* @return the value of the Z ordinate in the index'th coordinate, or Double.NaN if not defined.
*/
default double getM(int index)
{
if (hasM()) {
final int mIndex = getDimension()-getMeasures();
return getOrdinate( index, mIndex );
}
else {
return Double.NaN;
}
}
/**
* Returns the ordinate of a coordinate in this sequence.
* Ordinate indices 0 and 1 are assumed to be X and Y.
* <p>
* Ordinates indices greater than 1 have user-defined semantics
* (for instance, they may contain other dimensions or measure values).
* (for instance, they may contain other dimensions or measure
* values as described by {@link #getDimension()} and {@link #getMeasures()}).
*
* @param index the coordinate index in the sequence
* @param ordinateIndex the ordinate index in the coordinate (in range [0, dimension-1])
......@@ -164,7 +265,7 @@ public interface CoordinateSequence
* Called by Geometry#clone.
*
* @return a copy of the coordinate sequence containing copies of all points
* @deprecated
* @deprecated Recommend {@link #copy()}
*/
Object clone();
......