| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
package org.locationtech.jts.geom; |
| 13 |
|
| 14 |
/** |
| 15 |
* Coordinate subclass supporting XYZM ordinates. |
| 16 |
* <p> |
| 17 |
* This data object is suitable for use with coordinate sequences with <tt>dimension</tt> = 4 and <tt>measures</tt> = 1. |
| 18 |
* |
| 19 |
* @since 1.16 |
| 20 |
*/ |
| 21 |
public class CoordinateXYZM extends Coordinate { |
| 22 |
private static final long serialVersionUID = -8763329985881823442L; |
| 23 |
|
| 24 |
/** Default constructor */ |
| 25 |
public CoordinateXYZM() { |
| 26 |
super(); |
| 27 |
this.m = 0.0; |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Constructs a CoordinateXYZM instance with the given ordinates and measure. |
| 32 |
* |
| 33 |
* @param x the X ordinate |
| 34 |
* @param y the Y ordinate |
| 35 |
* @param z the Z ordinate |
| 36 |
* @param m the M measure value |
| 37 |
*/ |
| 38 |
public CoordinateXYZM(double x, double y, double z, double m) { |
| 39 |
super(x, y, z); |
| 40 |
this.m = m; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Constructs a CoordinateXYZM instance with the ordinates of the given Coordinate. |
| 45 |
* |
| 46 |
* @param coord the coordinate providing the ordinates |
| 47 |
*/ |
| 48 |
public CoordinateXYZM(Coordinate coord) { |
| 49 |
super(coord); |
| 50 |
m = getM(); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Constructs a CoordinateXYZM instance with the ordinates of the given CoordinateXYZM. |
| 55 |
* |
| 56 |
* @param coord the coordinate providing the ordinates |
| 57 |
*/ |
| 58 |
public CoordinateXYZM(CoordinateXYZM coord) { |
| 59 |
super(coord); |
| 60 |
m = coord.m; |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Creates a copy of this CoordinateXYZM. |
| 65 |
* |
| 66 |
* @return a copy of this CoordinateXYZM |
| 67 |
*/ |
| 68 |
public CoordinateXYZM copy() { |
| 69 |
return new CoordinateXYZM(this); |
| 70 |
} |
| 71 |
|
| 72 |
/** The m-measure. */ |
| 73 |
private double m; |
| 74 |
|
| 75 |
/** The m-measure, if available. */ |
| 76 |
public double getM() { |
| 77 |
return m; |
| 78 |
} |
| 79 |
|
| 80 |
public void setM(double m) { |
| 81 |
this.m = m; |
| 82 |
} |
| 83 |
|
| 84 |
public double getOrdinate(int ordinateIndex) |
| 85 |
{ |
| 86 |
switch (ordinateIndex) { |
| 87 |
case X: return x; |
| 88 |
case Y: return y; |
| 89 |
case Z: return getZ(); |
| 90 |
case M: return getM(); |
| 91 |
} |
| 92 |
throw new IllegalArgumentException("Invalid ordinate index: " + ordinateIndex); |
| 93 |
} |
| 94 |
|
| 95 |
@Override |
| 96 |
public void setCoordinate(Coordinate other) |
| 97 |
{ |
| 98 |
x = other.x; |
| 99 |
y = other.y; |
| 100 |
z = other.getZ(); |
| 101 |
m = other.getM(); |
| 102 |
} |
| 103 |
|
| 104 |
@Override |
| 105 |
public void setOrdinate(int ordinateIndex, double value) { |
| 106 |
switch (ordinateIndex) { |
| 107 |
case X: |
| 108 |
x = value; |
| 109 |
break; |
| 110 |
case Y: |
| 111 |
y = value; |
| 112 |
break; |
| 113 |
case Z: |
| 114 |
z = value; |
| 115 |
break; |
| 116 |
case M: |
| 117 |
m = value; |
| 118 |
break; |
| 119 |
default: |
| 120 |
throw new IllegalArgumentException("Invalid ordinate index: " + ordinateIndex); |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
public String toString() { |
| 125 |
return "(" + x + ", " + y + ", " + getZ() + " m="+getM()+")"; |
| 126 |
} |
| 127 |
} |
| 128 |
|