aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-11-27 22:58:56 +1300
committerGitHub <noreply@github.com>2016-11-27 22:58:56 +1300
commitac184d2a72358dd74600817daff5a191c7fa7ce5 (patch)
tree308b3fdcd9c2f0dbdcb04178d790c4d04066a40f
parent8004b238b4513b7be4684f7dbae3e03548856ca7 (diff)
parenteb8d6f28ec5b764043b99cdadfd60a51a79423a8 (diff)
downloadtrackermap-web-ac184d2a72358dd74600817daff5a191c7fa7ce5.tar.gz
trackermap-web-ac184d2a72358dd74600817daff5a191c7fa7ce5.tar.bz2
trackermap-web-ac184d2a72358dd74600817daff5a191c7fa7ce5.zip
Merge pull request #339 from Abyss777/polyline_geofence
Implemented polyline geofences
-rw-r--r--web/app/GeofenceConverter.js22
-rw-r--r--web/app/store/GeofenceTypes.js3
-rw-r--r--web/l10n/en.json1
3 files changed, 26 insertions, 0 deletions
diff --git a/web/app/GeofenceConverter.js b/web/app/GeofenceConverter.js
index f0e28b3f..9e3c1327 100644
--- a/web/app/GeofenceConverter.js
+++ b/web/app/GeofenceConverter.js
@@ -49,6 +49,20 @@ Ext.define('Traccar.GeofenceConverter', {
geometry = new ol.geom.Circle(center, radius);
}
}
+ } else if (wkt.lastIndexOf('LINESTRING', 0) === 0) {
+ content = wkt.match(/\([^\(\)]+\)/);
+ if (content !== null) {
+ coordinates = content[0].match(/-?\d+\.?\d*/g);
+ if (coordinates !== null) {
+ projection = mapView.getProjection();
+ for (i = 0; i < coordinates.length; i += 2) {
+ lat = Number(coordinates[i]);
+ lon = Number(coordinates[i + 1]);
+ points.push(ol.proj.transform([lon, lat], 'EPSG:4326', projection));
+ }
+ geometry = new ol.geom.LineString(points);
+ }
+ }
}
return geometry;
},
@@ -74,6 +88,14 @@ Ext.define('Traccar.GeofenceConverter', {
result += points[0][i][1] + ' ' + points[0][i][0] + ', ';
}
result = result.substring(0, result.length - 2) + '))';
+ } else if (geometry instanceof ol.geom.LineString) {
+ geometry.transform(projection, 'EPSG:4326');
+ points = geometry.getCoordinates();
+ result = 'LINESTRING (';
+ for (i = 0; i < points.length; i += 1) {
+ result += points[i][1] + ' ' + points[i][0] + ', ';
+ }
+ result = result.substring(0, result.length - 2) + ')';
}
return result;
}
diff --git a/web/app/store/GeofenceTypes.js b/web/app/store/GeofenceTypes.js
index c102de69..45b79897 100644
--- a/web/app/store/GeofenceTypes.js
+++ b/web/app/store/GeofenceTypes.js
@@ -25,5 +25,8 @@ Ext.define('Traccar.store.GeofenceTypes', {
}, {
key: 'Circle',
name: Strings.mapShapeCircle
+ }, {
+ key: 'LineString',
+ name: Strings.mapShapePolyline
}]
});
diff --git a/web/l10n/en.json b/web/l10n/en.json
index 55335da5..c558abdf 100644
--- a/web/l10n/en.json
+++ b/web/l10n/en.json
@@ -111,6 +111,7 @@
"mapBingAerial": "Bing Maps Aerial",
"mapShapePolygon": "Polygon",
"mapShapeCircle": "Circle",
+ "mapShapePolyline": "Polyline",
"mapLiveRoutes": "Live Routes",
"stateTitle": "State",
"stateName": "Attribute",