8000 Fix WKT parsing in Turkish locale by imotov · Pull Request #456 · locationtech/jts · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix WKT parsing in Turkish locale #456

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

Merged
merged 1 commit into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
import java.io.StringReader;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.Locale;

import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.CoordinateSequence;
import org.locationtech.jts.geom.CoordinateSequenceFactory;

import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryCollection;
import org.locationtech.jts.geom.GeometryFactory;
Expand All @@ -36,7 +36,6 @@
import org.locationtech.jts.geom.Polygon;
import org.locationtech.jts.geom.PrecisionModel;
import org.locationtech.jts.geom.impl.CoordinateArraySequenceFactory;
import org.locationtech.jts.geom.impl.PackedCoordinateSequenceFactory;
import org.locationtech.jts.util.Assert;
import org.locationtech.jts.util.AssertionFailedException;

Expand Down Expand Up @@ -612,7 +611,7 @@ private static EnumSet<Ordinate> getNextOrdinateFlags(StreamTokenizer tokenizer)

EnumSet<Ordinate> result = EnumSet.of(Ordinate.X, Ordinate.Y);

String nextWord = lookAheadWord(tokenizer).toUpperCase();
String nextWord = lookAheadWord(tokenizer).toUpperCase(Locale.ROOT);
if (nextWord.equalsIgnoreCase("Z")) {
tokenizer.nextToken();
result.add(Ordinate.Z);
Expand Down Expand Up @@ -767,7 +766,7 @@ private Geometry readGeometryTaggedText(StreamTokenizer tokenizer) throws IOExce

EnumSet<Ordinate> ordinateFlags = EnumSet.of(Ordinate.X, Ordinate.Y);
try {
type = getNextWord(tokenizer).toUpperCase();
type = getNextWord(tokenizer).toUpperCase(Locale.ROOT);
if (type.endsWith("ZM")) {
ordinateFlags.add(Ordinate.Z);
ordinateFlags.add(Ordinate.M);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import test.jts.GeometryTestCase;

import java.util.EnumSet;
import java.util.Locale;


/**
Expand Down Expand Up @@ -424,6 +425,18 @@ public void testReadLargeNumbers() throws Exception {
assertEquals(point1.getOrdinate(0, CoordinateSequence.Y), point2.getOrdinate(0, CoordinateSequence.Y), 1E-7);
}

public void testTurkishLocale() throws Exception {
Locale original = Locale.getDefault();
try {
Locale.setDefault(Locale.forLanguageTag("tr"));
Point point = (Point) reader2D.read("point (10 20)");
assertEquals(10.0, point.getX(), 1E-7);
assertEquals(20.0, point.getY(), 1E-7);
} finally {
Locale.setDefault(original);
}
}

private static CoordinateSequence createSequence(EnumSet<Ordinate> ordinateFlags, double[] xy) {

// get the number of dimension to verify size of provided ordinate values array
Expand Down
0