Jump to content

ICT:Cargo Geo Coordinnates: Difference between revisions

From Costa Sano MediaWiki
Created page with "== Handling Geographical Coordinates in Cargo == Geographical data is stored using the '''Coordinates''' field type. This allows for both precise database storage and interactive map displays using Page Forms and Cargo. === 1. Define the Cargo Table === In your table declaration, use the `Coordinates` field type. <pre> {{#cargo_declare:_table=Places |Name=String |Location=Coordinates }} </pre> === 2. Create the Input Form..."
 
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 48: Line 48:
* '''Precision''': Ensure you use a period (`.`) for decimals and a comma (`,`) to separate the two values.
* '''Precision''': Ensure you use a period (`.`) for decimals and a comma (`,`) to separate the two values.
* '''Services''': While `leaflet` is recommended for its ease of use, you can also use `googlemaps` or `openlayers` if they are configured on your wiki.
* '''Services''': While `leaflet` is recommended for its ease of use, you can also use `googlemaps` or `openlayers` if they are configured on your wiki.
== Choosing a Map Service for Forms ==
To display a map in a form for coordinate input, use the `input type` parameter.
=== Option A: Leaflet (Recommended) ===
Uses OpenStreetMap. No API key required.
<pre>
{{{field|Location|input type=leaflet}}}
</pre>
=== Option B: OpenLayers (Default) ===
Solid open-source alternative.
<pre>
{{{field|Location|input type=openlayers}}}
</pre>
=== Option C: Google Maps ===
Requires a Google Maps API Key to be configured in your wiki's LocalSettings.php.
<pre>
{{{field|Location|input type=googlemaps}}}
</pre>
=== Common Parameters ===
You can customize the map's appearance in the form using these parameters:
* `height`: Height in pixels (e.g., `300`).
* `width`: Width in pixels (e.g., `500`).
* `starting bounds`: Initial map area if no coordinate is set yet (e.g., `-20,-15;50,55`).
=== Leaflet Troubleshooting ===
* '''Map not appearing:''' Ensure the `height` parameter is set (e.g., `height=400`).
* '''Marker not saving:''' Make sure you clicked the map to place the marker; simply zooming in won't store coordinates in the field.
* '''Search box:''' To add a search-by-address bar to your form map, add `|show search box` to the field parameters.
== Automating Place Data with Geocoding ==
The [[Extension:Maps|Maps extension]] provides the `{{#geocode:}}` function, which can automatically turn human-readable addresses into Cargo-compatible coordinates.
=== 1. Using Geocode in a Template ===
You can set up your template so that it accepts a "Street Address" but stores "Coordinates" in Cargo.
<pre>
{{#cargo_store:_table=Places
|Name={{{Name|}}}
|Location={{#geocode:{{{Address|}}}}}
}}
</pre>
=== 2. Using Geocode in a Query ===
You can also geocode "on the fly" to find distances or filter by location without having coordinates stored.
<pre>
{{#cargo_query:
|tables=Places
|fields=Name
|where=DISTANCE(Location, '{{#geocode:Brussels, Belgium}}') < 5000
}}
</pre>
=== 3. Configuration Tips ===
* '''Default Service:''' By default, Maps uses '''Nominatim''' (OpenStreetMap). This is free and requires no API key.
* '''Accuracy:''' Geocoding results depend on the external service. For high-volume wikis, results are cached to improve performance.
* '''Manual Overrides:''' Always provide a field for manual coordinates in case the auto-geocoding fails for a specific obscure location.
SearchBox
<pre>
{{{field|Location|input type=leaflet|show search box}}}
</pre>
== Research Documentation: Sanatoria of the Belgian Coast (1850–2026) ==
This research tracks the spatial and chronological evolution of tuberculosis (TBC) treatment centers for children.
=== 1. Cargo Table Structure ===
We use a specific table to link physical coordinates with historical time periods.
<pre>
{{#cargo_declare:_table=Sanatoria
|Name=String          <!-- Current or common name (e.g., Zeepreventorium) -->
|HistoricalName=String <!-- Name used in 1850-1950 (e.g., Solarium Touriste) -->
|City=String          <!-- Modern municipality -->
|OpeningYear=Date      <!-- Use "year" input type in forms -->
|ClosingYear=Date      <!-- Leave blank if still active in 2026 -->
|Location=Coordinates  <!-- Physical GPS spot -->
|Type=String          <!-- Sanatorium, Preventorium, or Openluchtschool -->
}}
</pre>
=== 2. Mapping Historical "Existence" ===
To show where a sanatorium "was" during a specific historical period, use a query that filters by your year fields.
==== Example: Map of all sites active in 1920 ====
<pre>
{{#cargo_query:
|tables=Sanatoria
|fields=Name, Location, OpeningYear
|where=YEAR(OpeningYear) <= 1920 AND (YEAR(ClosingYear) >= 1920 OR ClosingYear IS NULL)
|format=leaflet
|height=500
}}
</pre>
=== 3. Historical Map Layers (Advanced) ===
Since modern OpenStreetMap didn't exist in 1850, you can overlay historical Belgian maps using WMTS services (e.g., from the NGI or AGIV).
In your Leaflet display, you can add a historical base layer:
* '''Vandermaelen (1846-1854):''' Useful for the start of your study period.
* '''Ferraris (1777):''' For pre-industrial coastal context.
<pre>
{{#cargo_display_map:
|point={{{Location|}}}
|service=leaflet
|layers=HistoricalBelgianMap <!-- Requires Wiki-side configuration -->
}}
</pre>
=== 4. Research Notes on Coordinates ===
* '''Lost Buildings:''' If a sanatorium was demolished (e.g., many coastal villas during WWII), use coordinates from historical cadastral maps (Atlas der Buurtwegen).
* '''Accuracy:''' If the exact coordinate is approximate, document this in a "Notes" field so other researchers know the marker is an estimate.
=== Using Map Clustering ===
To keep the map clean when many sanatoria are close together, always add `|cluster=yes` to your queries.
<pre>
{{#cargo_query:
|tables=Sanatoria
|fields=Location
|format=leaflet
|cluster=yes
}}
</pre>
* '''Advantage:''' Improved performance and a cleaner user interface.
* '''Behavior:''' Clicking a cluster zooms the map automatically to reveal the individual markers.

Latest revision as of 10:23, 12 February 2026

Handling Geographical Coordinates in Cargo

Geographical data is stored using the Coordinates field type. This allows for both precise database storage and interactive map displays using Page Forms and Cargo.

1. Define the Cargo Table

In your table declaration, use the `Coordinates` field type.

{{#cargo_declare:_table=Places
|Name=String
|Location=Coordinates
}}

2. Create the Input Form

Use the `leaflet` input type (part of Extension:Page Forms) to provide an interactive map where users can click to set coordinates.

{{{field|Location|input type=leaflet|height=300|width=500}}}

3. Displaying Maps

Display a map for a single location

Use the `#cargo_display_map` function on the page itself to show where the specific place is located.

{{#cargo_display_map:
|point={{{Location|}}}
|service=leaflet
|zoom=14
|height=400
}}

Display all places on a master map

To show all entries from your `Places` table on one map, use a `#cargo_query` with a map format.

{{#cargo_query:
|tables=Places
|fields=_pageName=Page, Name, Location
|format=leaflet
|height=500
}}

Technical Note: Coordinate Format

  • Storage: Cargo stores coordinates as "Latitude, Longitude" in decimal degrees (e.g., `51.2194, 2.8972`).
  • Precision: Ensure you use a period (`.`) for decimals and a comma (`,`) to separate the two values.
  • Services: While `leaflet` is recommended for its ease of use, you can also use `googlemaps` or `openlayers` if they are configured on your wiki.


Choosing a Map Service for Forms

To display a map in a form for coordinate input, use the `input type` parameter.

Option A: Leaflet (Recommended)

Uses OpenStreetMap. No API key required.

{{{field|Location|input type=leaflet}}}

Option B: OpenLayers (Default)

Solid open-source alternative.

{{{field|Location|input type=openlayers}}}

Option C: Google Maps

Requires a Google Maps API Key to be configured in your wiki's LocalSettings.php.

{{{field|Location|input type=googlemaps}}}

Common Parameters

You can customize the map's appearance in the form using these parameters:

  • `height`: Height in pixels (e.g., `300`).
  • `width`: Width in pixels (e.g., `500`).
  • `starting bounds`: Initial map area if no coordinate is set yet (e.g., `-20,-15;50,55`).

Leaflet Troubleshooting

  • Map not appearing: Ensure the `height` parameter is set (e.g., `height=400`).
  • Marker not saving: Make sure you clicked the map to place the marker; simply zooming in won't store coordinates in the field.
  • Search box: To add a search-by-address bar to your form map, add `|show search box` to the field parameters.

Automating Place Data with Geocoding

The Maps extension provides the `{{#geocode:}}` function, which can automatically turn human-readable addresses into Cargo-compatible coordinates.

1. Using Geocode in a Template

You can set up your template so that it accepts a "Street Address" but stores "Coordinates" in Cargo.

{{#cargo_store:_table=Places
|Name={{{Name|}}}
|Location={{#geocode:{{{Address|}}}}}
}}

2. Using Geocode in a Query

You can also geocode "on the fly" to find distances or filter by location without having coordinates stored.

{{#cargo_query:
|tables=Places
|fields=Name
|where=DISTANCE(Location, '{{#geocode:Brussels, Belgium}}') < 5000
}}

3. Configuration Tips

  • Default Service: By default, Maps uses Nominatim (OpenStreetMap). This is free and requires no API key.
  • Accuracy: Geocoding results depend on the external service. For high-volume wikis, results are cached to improve performance.
  • Manual Overrides: Always provide a field for manual coordinates in case the auto-geocoding fails for a specific obscure location.

SearchBox

{{{field|Location|input type=leaflet|show search box}}}


Research Documentation: Sanatoria of the Belgian Coast (1850–2026)

This research tracks the spatial and chronological evolution of tuberculosis (TBC) treatment centers for children.

1. Cargo Table Structure

We use a specific table to link physical coordinates with historical time periods.

{{#cargo_declare:_table=Sanatoria
|Name=String          <!-- Current or common name (e.g., Zeepreventorium) -->
|HistoricalName=String <!-- Name used in 1850-1950 (e.g., Solarium Touriste) -->
|City=String          <!-- Modern municipality -->
|OpeningYear=Date      <!-- Use "year" input type in forms -->
|ClosingYear=Date      <!-- Leave blank if still active in 2026 -->
|Location=Coordinates  <!-- Physical GPS spot -->
|Type=String           <!-- Sanatorium, Preventorium, or Openluchtschool -->
}}

2. Mapping Historical "Existence"

To show where a sanatorium "was" during a specific historical period, use a query that filters by your year fields.

Example: Map of all sites active in 1920

{{#cargo_query:
|tables=Sanatoria
|fields=Name, Location, OpeningYear
|where=YEAR(OpeningYear) <= 1920 AND (YEAR(ClosingYear) >= 1920 OR ClosingYear IS NULL)
|format=leaflet
|height=500
}}

3. Historical Map Layers (Advanced)

Since modern OpenStreetMap didn't exist in 1850, you can overlay historical Belgian maps using WMTS services (e.g., from the NGI or AGIV).

In your Leaflet display, you can add a historical base layer:

  • Vandermaelen (1846-1854): Useful for the start of your study period.
  • Ferraris (1777): For pre-industrial coastal context.
{{#cargo_display_map:
|point={{{Location|}}}
|service=leaflet
|layers=HistoricalBelgianMap <!-- Requires Wiki-side configuration -->
}}

4. Research Notes on Coordinates

  • Lost Buildings: If a sanatorium was demolished (e.g., many coastal villas during WWII), use coordinates from historical cadastral maps (Atlas der Buurtwegen).
  • Accuracy: If the exact coordinate is approximate, document this in a "Notes" field so other researchers know the marker is an estimate.

Using Map Clustering

To keep the map clean when many sanatoria are close together, always add `|cluster=yes` to your queries.

{{#cargo_query:
|tables=Sanatoria
|fields=Location
|format=leaflet
|cluster=yes
}}
  • Advantage: Improved performance and a cleaner user interface.
  • Behavior: Clicking a cluster zooms the map automatically to reveal the individual markers.