diff options
author | Abyss777 <abyss@fox5.ru> | 2016-07-04 15:11:45 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-07-04 15:11:45 +0500 |
commit | 23796ee74a04f87d5dd028dffffa8a992c5c662d (patch) | |
tree | 690e676bc5d7a6560f3affe65cab63f739349dbf /web/app/GeofenceConverter.js | |
parent | fe935b21c242a496fde8570d78322c42b3eaf414 (diff) | |
download | trackermap-server-23796ee74a04f87d5dd028dffffa8a992c5c662d.tar.gz trackermap-server-23796ee74a04f87d5dd028dffffa8a992c5c662d.tar.bz2 trackermap-server-23796ee74a04f87d5dd028dffffa8a992c5c662d.zip |
Tidied up variable names and declarations
Diffstat (limited to 'web/app/GeofenceConverter.js')
-rw-r--r-- | web/app/GeofenceConverter.js | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/web/app/GeofenceConverter.js b/web/app/GeofenceConverter.js index c41446f2d..d104ef127 100644 --- a/web/app/GeofenceConverter.js +++ b/web/app/GeofenceConverter.js @@ -18,35 +18,33 @@ Ext.define('Traccar.GeofenceConverter', { singleton: true, wktToGeometry: function (mapView, wkt) { - var geometry, points = []; - var projection, resolutionAtEquator, pointResolution, resolutionFactor; - var center, radius; - var m, i, lat, lon, tmp; + var geometry, projection, resolutionAtEquator, pointResolution, resolutionFactor, points = [], center, radius, + content, i, lat, lon, coordinates; if (wkt.startsWith("POLYGON")) { - m = wkt.match(/\([^\(\)]+\)/); - if (m !== null) { - tmp = m[0].match(/-?\d+\.?\d*/g); - if (tmp !== null) { + content = wkt.match(/\([^\(\)]+\)/); + if (content !== null) { + coordinates = content[0].match(/-?\d+\.?\d*/g); + if (coordinates !== null) { projection = mapView.getProjection(); - for (i = 0; i < tmp.length; i += 2) { - lat = Number(tmp[i]); - lon = Number(tmp[i + 1]); + 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.Polygon([points]); } } } else if (wkt.startsWith("CIRCLE")) { - m = wkt.match(/\([^\(\)]+\)/); - if (m !== null) { - tmp = m[0].match(/-?\d+\.?\d*/g); - if (tmp !== null) { + content = wkt.match(/\([^\(\)]+\)/); + if (content !== null) { + coordinates = content[0].match(/-?\d+\.?\d*/g); + if (coordinates !== null) { projection = mapView.getProjection(); - center = ol.proj.transform([Number(tmp[1]), Number(tmp[0])], 'EPSG:4326', projection); + center = ol.proj.transform([Number(coordinates[1]), Number(coordinates[0])], 'EPSG:4326', projection); resolutionAtEquator = mapView.getResolution(); pointResolution = projection.getPointResolution(resolutionAtEquator, center); resolutionFactor = resolutionAtEquator / pointResolution; - radius = (Number(tmp[2]) / ol.proj.METERS_PER_UNIT.m) * resolutionFactor; + radius = (Number(coordinates[2]) / ol.proj.METERS_PER_UNIT.m) * resolutionFactor; geometry = new ol.geom.Circle(center, radius); } } @@ -55,8 +53,7 @@ Ext.define('Traccar.GeofenceConverter', { }, geometryToWkt: function (projection, geometry) { - var result; - var i, center, radius, edgeCoordinate, earthSphere, groundRadius, points; + var result, i, center, radius, edgeCoordinate, earthSphere, groundRadius, points; if (geometry instanceof ol.geom.Circle) { center = geometry.getCenter(); radius = geometry.getRadius(); |