]> git.openstreetmap.org Git - rails.git/blobdiff - vendor/assets/iD/iD.js
Update to iD v1.5.4
[rails.git] / vendor / assets / iD / iD.js
index 3190ee2422f3c6b39e5c07fde8184867c885b89c..11c3eb29ba1371f42429a41988249deac01098f3 100644 (file)
@@ -16411,7 +16411,7 @@ window.iD = function () {
     return d3.rebind(context, dispatch, 'on');
 };
 
-iD.version = '1.5.3';
+iD.version = '1.5.4';
 
 (function() {
     var detected = {};
@@ -23788,10 +23788,14 @@ iD.Background = function(context) {
 
     background.zoomToGpxLayer = function() {
         if (background.hasGpxLayer()) {
-            var gpx = d3.geo.bounds(gpxLayer.geojson());
-
-            if (!context.map().extent().intersects(gpx)) {
-                context.map().extent(gpx);
+            var viewport = context.map().extent().polygon(),
+                coords = _.reduce(gpxLayer.geojson().features, function(coords, feature) {
+                    var c = feature.geometry.coordinates;
+                    return _.union(coords, feature.geometry.type === 'Point' ? [c] : c);
+                }, []);
+
+            if (!iD.geo.polygonIntersectsPolygon(viewport, coords)) {
+                context.map().extent(d3.geo.bounds(gpxLayer.geojson()));
             }
         }
     };
@@ -24825,6 +24829,12 @@ iD.svg.Areas = function(projection) {
 
     var patternKeys = ['landuse', 'natural', 'amenity'];
 
+    var clipped = ['residential', 'commercial', 'retail', 'industrial'];
+
+    function clip(entity) {
+        return clipped.indexOf(entity.tags.landuse) !== -1;
+    }
+
     function setPattern(d) {
         for (var i = 0; i < patternKeys.length; i++) {
             if (patterns.hasOwnProperty(d.tags[patternKeys[i]])) {
@@ -24867,11 +24877,28 @@ iD.svg.Areas = function(projection) {
         });
 
         var data = {
+            clip: areas.filter(clip),
             shadow: strokes,
             stroke: strokes,
             fill: areas
         };
 
+        var clipPaths = surface.selectAll('defs').selectAll('.clipPath')
+           .filter(filter)
+           .data(data.clip, iD.Entity.key);
+
+        clipPaths.enter()
+           .append('clipPath')
+           .attr('class', 'clipPath')
+           .attr('id', function(entity) { return entity.id + '-clippath'; })
+           .append('path');
+
+        clipPaths.selectAll('path')
+           .attr('d', path);
+
+        clipPaths.exit()
+           .remove();
+
         var areagroup = surface
             .select('.layer-areas')
             .selectAll('g.areagroup')
@@ -24910,6 +24937,10 @@ iD.svg.Areas = function(projection) {
 
                 this.setAttribute('class', entity.type + ' area ' + layer + ' ' + entity.id);
 
+                if (layer === 'fill' && clip(entity)) {
+                    this.setAttribute('clip-path', 'url(#' + entity.id + '-clippath)');
+                }
+
                 if (layer === 'fill') {
                     setPattern.apply(this, arguments);
                 }
@@ -25687,25 +25718,29 @@ iD.svg.Midpoints = function(projection, context) {
             .filter(midpointFilter)
             .data(_.values(midpoints), function(d) { return d.id; });
 
-        var group = groups.enter()
+        var enter = groups.enter()
             .insert('g', ':first-child')
             .attr('class', 'midpoint');
 
-        group.append('polygon')
+        enter.append('polygon')
             .attr('points', '-6,8 10,0 -6,-8')
             .attr('class', 'shadow');
 
-        group.append('polygon')
+        enter.append('polygon')
             .attr('points', '-3,4 5,0 -3,-4')
             .attr('class', 'fill');
 
-        groups.attr('transform', function(d) {
-            var translate = iD.svg.PointTransform(projection),
-                a = context.entity(d.edge[0]),
-                b = context.entity(d.edge[1]),
-                angle = Math.round(iD.geo.angle(a, b, projection) * (180 / Math.PI));
-            return translate(d) + ' rotate(' + angle + ')';
-        });
+        groups
+            .attr('transform', function(d) {
+                var translate = iD.svg.PointTransform(projection),
+                    a = context.entity(d.edge[0]),
+                    b = context.entity(d.edge[1]),
+                    angle = Math.round(iD.geo.angle(a, b, projection) * (180 / Math.PI));
+                return translate(d) + ' rotate(' + angle + ')';
+            })
+            .call(iD.svg.TagClasses().tags(
+                function(d) { return d.parents[0].tags; }
+            ));
 
         // Propagate data bindings.
         groups.select('polygon.shadow');
@@ -25786,6 +25821,11 @@ iD.svg.Points = function(projection, context) {
 };
 iD.svg.Surface = function() {
     return function (selection) {
+        selection.selectAll('defs')
+            .data([0])
+            .enter()
+            .append('defs');
+
         var layers = selection.selectAll('.layer')
             .data(['areas', 'lines', 'hit', 'halo', 'label']);
 
@@ -102087,7 +102127,7 @@ iD.introGraph = '{"n185954700":{"id":"n185954700","loc":[-85.642244,41.939081],"
                         "advanced": "Advanced (black diamond)",
                         "expert": "Expert (double black diamond)",
                         "freeride": "Freeride (off-piste)",
-                        "extreme": "Extreme (climing equipment required)"
+                        "extreme": "Extreme (climbing equipment required)"
                     }
                 }
             },
@@ -114636,7 +114676,7 @@ iD.introGraph = '{"n185954700":{"id":"n185954700","loc":[-85.642244,41.939081],"
             },
             "delete": {
                 "title": "Delete",
-                "description": "Remove this from the map.",
+                "description": "Delete object permanently.",
                 "annotation": {
                     "point": "Deleted a point.",
                     "vertex": "Deleted a node from a way.",
@@ -115451,7 +115491,7 @@ iD.introGraph = '{"n185954700":{"id":"n185954700","loc":[-85.642244,41.939081],"
                         "advanced": "Advanced (black diamond)",
                         "expert": "Expert (double black diamond)",
                         "freeride": "Freeride (off-piste)",
-                        "extreme": "Extreme (climing equipment required)"
+                        "extreme": "Extreme (climbing equipment required)"
                     }
                 },
                 "piste/grooming": {