From 22f37ea8bac7f45430e56c07d46d06755297f497 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Sun, 3 Jul 2016 14:38:11 +0500 Subject: Double brackets for "POLYGON" area --- src/org/traccar/geofence/GeofencePolygon.java | 6 +++--- test/org/traccar/geofence/GeofencePolygonTest.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/org/traccar/geofence/GeofencePolygon.java b/src/org/traccar/geofence/GeofencePolygon.java index 4ce61a623..33d91c0ff 100644 --- a/src/org/traccar/geofence/GeofencePolygon.java +++ b/src/org/traccar/geofence/GeofencePolygon.java @@ -119,14 +119,14 @@ public class GeofencePolygon extends GeofenceGeometry { @Override public String toWkt() { StringBuilder buf = new StringBuilder(); - buf.append("POLYGON ("); + buf.append("POLYGON (("); for (Coordinate coordinate : coordinates) { buf.append(String.valueOf(coordinate.getLat())); buf.append(" "); buf.append(String.valueOf(coordinate.getLon())); buf.append(", "); } - return buf.substring(0, buf.length() - 2) + ")"; + return buf.substring(0, buf.length() - 2) + "))"; } @Override @@ -140,7 +140,7 @@ public class GeofencePolygon extends GeofenceGeometry { if (!wkt.startsWith("POLYGON")) { throw new ParseException("Mismatch geometry type", 0); } - String content = wkt.substring(wkt.indexOf("(") + 1, wkt.indexOf(")")); + String content = wkt.substring(wkt.indexOf("((") + 2, wkt.indexOf("))")); if (content.isEmpty()) { throw new ParseException("No content", 0); } diff --git a/test/org/traccar/geofence/GeofencePolygonTest.java b/test/org/traccar/geofence/GeofencePolygonTest.java index 8711a3696..e3d6aaa29 100644 --- a/test/org/traccar/geofence/GeofencePolygonTest.java +++ b/test/org/traccar/geofence/GeofencePolygonTest.java @@ -9,7 +9,7 @@ public class GeofencePolygonTest { @Test public void testPolygonWKT() { - String test = "POLYGON (55.75474 37.61823, 55.75513 37.61888, 55.7535 37.6222, 55.75315 37.62165)"; + String test = "POLYGON ((55.75474 37.61823, 55.75513 37.61888, 55.7535 37.6222, 55.75315 37.62165))"; GeofenceGeometry geofenceGeometry = new GeofencePolygon(); try { geofenceGeometry.fromWkt(test); @@ -21,7 +21,7 @@ public class GeofencePolygonTest { @Test public void testContainsPolygon() { - String test = "POLYGON (55.75474 37.61823, 55.75513 37.61888, 55.7535 37.6222, 55.75315 37.62165)"; + String test = "POLYGON ((55.75474 37.61823, 55.75513 37.61888, 55.7535 37.6222, 55.75315 37.62165))"; GeofenceGeometry geofenceGeometry = new GeofencePolygon(); try { geofenceGeometry.fromWkt(test); -- cgit v1.2.3