rusackas commented on code in PR #45607:
URL: https://github.com/apache/superset/pull/45607#discussion_r4366114318


##########
superset-frontend/plugins/plugin-chart-country-map/scripts/maps/countries/philippines.py:
##########
@@ -0,0 +1,84 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Philippines: a province-level community source replaces the raw,
+outdated Natural Earth boundaries, plus a dissolve of the (unrelated,
+Natural-Earth-sourced) regions.
+
+The notebook this replaces fetched this same community source, renamed
+its columns, and then never wired the result into its output - the
+plain "philippines" entry it shipped was actually still raw Natural
+Earth data (highly-urbanized cities split out as their own polygons, an
+undivided "Maguindanao", "Compostela Valley" instead of "Davao de
+Oro"). Confirmed against the previously-committed philippines.geojson.
+This fixes that: the corrected 83-province source is now the
+"philippines" output.
+"""
+
+from __future__ import annotations
+
+import geopandas as gpd
+
+from maps.context import BuildContext
+
+NAME = "philippines"
+
+_URL = (
+    "https://raw.githubusercontent.com/jdruii/phgeojson/";
+    "098399b6f27ca10e31c8f304e4148b3a56431ec2/philippines.geojson"
+)
+
+
+def build(ctx: BuildContext) -> dict[str, gpd.GeoDataFrame]:
+    try:
+        source = gpd.read_file(_URL)
+    except Exception as exc:  # noqa: BLE001 - re-raised with context below
+        raise RuntimeError(
+            f"Unable to download or load the GeoJSON file for Philippines: 
{exc}"
+        ) from exc
+
+    required_columns = {"NAME_1", "ISO", "geometry"}
+    if missing_columns := required_columns - set(source.columns):
+        raise ValueError(
+            f"Philippines source is missing columns: 
{sorted(missing_columns)}. "
+            f"Available columns: {sorted(source.columns)}"
+        )
+
+    philippines = source.rename(columns={"NAME_1": "name", "ISO": 
"iso_3166_2"})[

Review Comment:
   Good catch. Reoriented the 5 affected provinces to clockwise exteriors in 
`philippines.geojson` and added the same orientation to `philippines.py` so a 
regen keeps it.



##########
docs/admin_docs/configuration/country-map-tools.mdx:
##########
@@ -33,8 +33,15 @@ The Country Maps visualization already ships with the maps 
for the following cou
 To add a new country to the list, you'd have to edit files in
 
[@superset-ui/plugin-chart-country-map](https://github.com/apache/superset/tree/master/superset-frontend/plugins/plugin-chart-country-map).
 
-1. Generate a new GeoJSON file for your country following the guide in [this 
Jupyter 
notebook](https://github.com/apache/superset/blob/master/superset-frontend/plugins/plugin-chart-country-map/scripts/Country%20Map%20GeoJSON%20Generator.ipynb).
-2. Edit the countries list in 
[plugin-chart-country-map/src/countries.ts](https://github.com/apache/superset/blob/master/superset-frontend/plugins/plugin-chart-country-map/src/countries.ts).
-3. Install superset-frontend dependencies: `cd superset-frontend && npm 
install`
-4. Verify your countries in Superset plugins storybook: `npm run 
plugins:storybook`.
-5. Build and install Superset from source code.
+1. Most countries need no correction at all - check whether yours already 
resolves via a plain
+   lookup in 
[`scripts/maps/catalog.py`](https://github.com/apache/superset/blob/master/superset-frontend/plugins/plugin-chart-country-map/scripts/maps/catalog.py)
+   before writing anything.
+2. If it needs a fix (a renamed region, a relocated territory, a replacement 
data source, ...),

Review Comment:
   Yep, the docs now say to add the new module to `REGISTRY` in 
`scripts/maps/countries/__init__.py`.



##########
superset-frontend/plugins/plugin-chart-country-map/README.md:
##########
@@ -53,10 +53,21 @@ for more details.
 
 ### Update Map
 
-To update the country maps or add a new country, run scripts in the Jupyter 
notebook
-`scripts/Country Map GeoJSON Generator.ipynb`.
+To regenerate every country's GeoJSON from upstream Natural Earth and
+community sources, `countries.ts`, and `docs/data/countries.json`, run:
 
 ```bash
-pip install geopandas shapely matplotlib notebook
-jupyter notebook
+pip install geopandas shapely matplotlib requests
+npm run update-maps

Review Comment:
   Fixed, each command in the README now says which directory it runs from.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to