JGirault has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/303551

Change subject: Use polygon holes when auto positioning a map (for masks)
......................................................................

Use polygon holes when auto positioning a map (for masks)

Bug: T138545
Change-Id: I1120cdd5bf1d636c1f03b34e0fe28d71e952aa20
---
M modules/box/Map.js
1 file changed, 11 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Kartographer 
refs/changes/51/303551/1

diff --git a/modules/box/Map.js b/modules/box/Map.js
index 7955dd5..868e507 100644
--- a/modules/box/Map.js
+++ b/modules/box/Map.js
@@ -67,11 +67,16 @@
                return layerBounds;
        }
 
+       /*jscs:disable disallowDanglingUnderscores */
        /**
         * Validate that the bounds contain no outlier.
         *
         * An outlier is a layer whom bounds do not fit into the world,
         * i.e. `-180 <= longitude <= 180  &&  -90 <= latitude <= 90`
+        *
+        * There is a special case for **masks** (polygons that cover the entire
+        * globe with a hole to highlight a specific area). In this case the
+        * algorithm tries to validate the hole bounds.
         *
         * @param {L.Layer} layer Layer to get and validate the bounds.
         * @return {L.LatLng|boolean} Bounds if valid.
@@ -84,9 +89,15 @@
 
                if ( bounds && worldLatLng.contains( bounds ) ) {
                        return bounds;
+               } else if ( layer instanceof L.Polygon && layer._holes && 
layer._holes[ 0 ] ) {
+                       bounds = new L.LatLngBounds( layer._convertLatLngs( 
layer._holes[ 0 ] ) );
+                       if ( worldLatLng.contains( bounds ) ) {
+                               return bounds;
+                       }
                }
                return false;
        }
+       /*jscs:enable disallowDanglingUnderscores */
 
        /**
         * Returns the data for the list of groups.

-- 
To view, visit https://gerrit.wikimedia.org/r/303551
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1120cdd5bf1d636c1f03b34e0fe28d71e952aa20
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Kartographer
Gerrit-Branch: master
Gerrit-Owner: JGirault <julien.inbox.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to