Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WKTReader/-Writer enhancement #291

Merged
merged 7 commits into from Aug 20, 2018
@@ -57,6 +57,7 @@
* <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;

This comment has been minimized.

Copy link
@jodygarnett

jodygarnett Aug 17, 2018

Contributor

I am a bit uncomfortable having this as a constant, because for the XYM case it is not true.

This comment has been minimized.

Copy link
@FObermaier

FObermaier Aug 18, 2018

Author Contributor

It might have slipped in when resolving conficts.


/**
@@ -177,7 +178,7 @@ default Coordinate createCoordinate() {
* @return the value of the Y ordinate in the index'th coordinate
*/
double getY(int index);

/**
* Returns ordinate Z of the specified coordinate if available.
*
@@ -413,7 +413,7 @@ public MultiPoint createMultiPoint(CoordinateSequence coordinates) {
Point[] points = new Point[coordinates.size()];
for (int i = 0; i < coordinates.size(); i++) {
CoordinateSequence ptSeq = getCoordinateSequenceFactory()
.create(1, coordinates.getDimension());
.create(1, coordinates.getDimension(), coordinates.getMeasures());
CoordinateSequences.copy(coordinates, i, ptSeq, 0, 1);
points[i] = createPoint(ptSeq);
}
@@ -0,0 +1,35 @@
package org.locationtech.jts.io;

import java.util.EnumSet;

/**
* An enumeration of possible Well-Known-Text ordinates
*/
public enum WKTOrdinates {

This comment has been minimized.

Copy link
@jodygarnett

jodygarnett Aug 17, 2018

Contributor

Thanks I like this approach much better

This comment has been minimized.

Copy link
@FObermaier

FObermaier Aug 18, 2018

Author Contributor

Should perhaps be renamed to just WKOrdinates since they might apply to WKB as well.

This comment has been minimized.

Copy link
@jodygarnett

jodygarnett Aug 19, 2018

Contributor

Not sure if there is anything "well-known" about this idea? Leaving that off as "Ordinates" sounds like a utility class, ... how about OrdinateSet, or CoordinateType?

/**
* X-ordinate
*/
X,
/**
* Y-ordinate
*/
Y,
/**
* Z-ordinate
*/
Z,
/**
* Measure-ordinate
*/
M;

private static final EnumSet<WKTOrdinates> XY = EnumSet.of(X, Y);
private static final EnumSet<WKTOrdinates> XYZ = EnumSet.of(X, Y, Z);
private static final EnumSet<WKTOrdinates> XYM = EnumSet.of(X, Y, M);
private static final EnumSet<WKTOrdinates> XYZM = EnumSet.of(X, Y, Z, M);

public static EnumSet<WKTOrdinates> getXY() { return XY.clone(); }

This comment has been minimized.

Copy link
@jodygarnett

jodygarnett Aug 17, 2018

Contributor

Do you just want this to be unmodifiable?

This comment has been minimized.

Copy link
@FObermaier

FObermaier Aug 18, 2018

Author Contributor

Yes, is there a better way?

This comment has been minimized.

Copy link
@jodygarnett

jodygarnett Aug 19, 2018

Contributor

Collections.unmodifiableSet( XY ) is what I am used to. Not perfect as it masks that it is an EnumSet, but good enough to prevent modification.

Guava provides an Sets.immutableEnumSet(enumSet) but I do not want the dependency.

This comment has been minimized.

Copy link
@jodygarnett

jodygarnett Aug 19, 2018

Contributor

Recommending calling these createXY, createXYZ, etc... so it is clear a copy is being produced?

public static EnumSet<WKTOrdinates> getXYZ() { return XYZ.clone(); }
public static EnumSet<WKTOrdinates> getXYM() { return XYM.clone(); }
public static EnumSet<WKTOrdinates> getXYZM() { return XYZM.clone(); }
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.