Skip to content

Support using global Plus Codes to represent location#68

Open
caleb-allen wants to merge 4 commits intoobsidianmd:masterfrom
caleb-allen:master
Open

Support using global Plus Codes to represent location#68
caleb-allen wants to merge 4 commits intoobsidianmd:masterfrom
caleb-allen:master

Conversation

@caleb-allen
Copy link
Copy Markdown

Partially completes #16

This changes the handling of location strings by checking whether they are plus codes before processing them as lat/lon pairs. It also adds open-location-code as a dependency.

Overview of Plus Codes

Plus Codes are a way to represent geographical areas by using a string of characters and offer a system for addressing that is more human friendly than raw latitude and longitude coordinates.

For example, the plus code 9C3XGVJC+2W describes the location of the British Library in London. Compare this to the latitude and longitude values 51.530002, -0.127709, here written as Decimal Degrees, one of the many ways in which latitude and longitude are used.

Notation Example (British Library) Comment
Decimal Degrees (DD) 51.530002, -0.127709
OR
51.530002°, -0.127709°
OR
51.530002 N, 0.127709 W
GIS
Degrees Minutes Seconds (DMS) 51°31′48.01″N, 00°07′39.75″W
OR
51°31′48″N, 00°07′40″W
Navigation and cartography
Degrees Decimal Minutes (DDM) 51° 31.8' N, 12° 46.254' W Electronic navigation (aviation and maritime)
ISO 6709 +51.530002-000.127709/ Can include altitude
Well-Known Text (WKT) POINT(-0.127709 51.530002) Written with longitude first!

A plus code does encode location coordinates, but in a way that is unambiguous, culturally independent, and easy to decode. It also represents an area rather than a single point. This allows flexible precision: the first four digits describe a 1° lat by 1° lon area, and each subsequent digit reduces the area further and further. A 10 digit code describes an area approximately 14m x 14m, and adding 5 more digits describes an area of 4 x 14mm.

See also

Partially completes obsidianmd#16

This changes the handling of location strings by checking whether they are plus codes before processing them as lat/lon pairs. It also adds `open-location-code` as a dependency.
## Overview of Plus Codes

Plus Codes are a way to represent geographical areas by using a string of characters and offer a system for addressing that is more human friendly than raw latitude and longitude coordinates.

For example, the plus code **9C3XGVJC+2W** describes the location of [the British Library](https://plus.codes/9C3XGVJC+2W) in London. Compare this to the latitude and longitude values 51.530002, -0.127709, here written as Decimal Degrees, one of the many ways in which latitude and longitude are used.

| Notation                      | Example (British Library)                                                                     | Comment                                       |
| ----------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------- |
| Decimal Degrees (DD)          | 51.530002, -0.127709<br>*OR*<br>51.530002°, -0.127709°<br>*OR*<br>51.530002 N, 0.127709 W<br> | GIS                                           |
| Degrees Minutes Seconds (DMS) | 51°31′48.01″N, 00°07′39.75″W<br>*OR*<br>51°31′48″N, 00°07′40″W                                | Navigation and cartography                    |
| Degrees Decimal Minutes (DDM) | 51° 31.8' N, 12° 46.254' W                                                                    | Electronic navigation (aviation and maritime) |
| ISO 6709                      | +51.530002-000.127709/                                                                        | Can include altitude                          |
| Well-Known Text (WKT)         | POINT(-0.127709 51.530002)                                                                    | Written with longitude first!                 |

A plus code **does** encode location coordinates, but in a way that is unambiguous, culturally independent, and easy to decode. It also represents an **area** rather than a single point. This allows **flexible precision**: the first four digits describe a 1° lat by 1° lon area, and each subsequent digit reduces the area further and further. A 10 digit code describes an area approximately 14m x 14m, and adding 5 more digits describes an area of **4 x 14mm**.
#### See also
- [Open Location Code specification](https://github.com/google/open-location-code/blob/main/Documentation/Specification/olc_definition.adoc)
- [plus.codes](https://plus.codes/) demo
@caleb-allen
Copy link
Copy Markdown
Author

For clarity, this probably needs some testing before being merged

@caleb-allen
Copy link
Copy Markdown
Author

I've pushed some fixes as well as some test data. It does function in a Sandbox vault!

image

Here's a minimal vault:

The British Library.md
---
location: 9C3XGVJC+2W
---
maps.base
filters:
  and:
    - "!location.isEmpty()"
views:
  - type: map
    name: Map
    center: 0, 100
    coordinates: note.location

Replace separate generate_plus_code_files function with a unified
generate_test_files that accepts a pluscode_count argument (default 20),
outputting both coordinate and Plus Code files to the same directory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant