Alternative geolocation resource identifier for link building and cache strategy

One of the problems I have experienced while working on GO2CINEMA is how to describe a geolocation in the URLs. Coordinates (latitude, longitude) does not sound like a good solution because:

  • Describing a geographic location at ~1M precision requires 5 decimal places. This makes for a long string, e.g. 51.52286,-0.22673.
  • Representation of coordinates is non-standardised. It can be 51.52286,-0.22673 (where it is unclear whether the data is in the latitude, longitude format or the vice-versa) or it can be any number of other formats (e.g. using query string).

The same issues can be extended to creating a resource identifier as part of the caching strategy.

MGRS

MGRS (Military Grid Reference System) is the geocoordinate standard used by NATO militaries forlocating points on the earth. MGRS divides the entire earth surface into “grid squares” down to 1 m precision.

Planet Earth divided into “grid squares”.

Location is referenced using a single identifier, e.g. 1 m precision identification 4QFJ1234567890 (14 characters) is equivalent to 21.30944,-157.91681 (19 characters).

MGRS have the following benefits over the coordinates:

  • Identifier consists only of alphanumeric characters (case-insensitive).
  • Identifier’s length is constant (for a set precision).
  • It is approx. 20% shorter.

SEO

Using MGRS allows to construct URLs that incorporate geolocation reference. Here is an example of URLs describing showtimes for different geolocation:

The only significant part of the URL is the last segment, which is the MGRS location identifier.

Development

MGRS can be converted to coordinates and back. If you are developing using Node.js, I recommend the mgrs package by Calvin Metcalf and Andreas Hocevar.

I am using it as such:

// @flow
/**
* @see https://en.wikipedia.org/wiki/Military_Grid_Reference_System
*/
import mgrs from 'mgrs';
export type CoordinatesType = {|
+latitude: number,
+longitude: number
|};
/**
* 5 decimal points give a precision of ~1 meter.
* This is enough for all the go2cinema.com operations.
*/
export const normalizeCoordinates = (coordinates: CoordinatesType): CoordinatesType => {
return {
latitude: Number(coordinates.latitude.toFixed(5)),
longitude: Number(coordinates.longitude.toFixed(5))
};
};
export const getCoordinatesFromMgrsId = (mgrsId: string): CoordinatesType => {
const [
longitude,
latitude
] = mgrs.toPoint(mgrsId);
return normalizeCoordinates({
latitude,
longitude
});
};
export const getMgrsFromCoordinates = (coordinates: CoordinatesType, precision = 3): string => {
return mgrs.forward(
[
coordinates.longitude,
coordinates.latitude
],
precision
);
};

Bonus

When debugging, it is worth knowing that Google Maps support MGRS, e.g. https://www.google.co.uk/maps/search/4QFJ1234567890

Can you help me with GO2CINEMA?

GO2CINEMA is my baby. I love working working on it 😍. However, it is my first startup this decade and there are a lot of things I need help with.

If you can give feedback, an SEO advice, a business advice, know an angel investor, know someone who can write an article about GO2CINEMA, make a tweet, invite me to a conference, a radio talk show, etc. or just want to express your support/ curiosity and say “Hi!”, email me at gajus@gajus.com or DM via Twitter, https://twitter.com/kuizinas.



SOURCE

LEAVE A REPLY

Please enter your comment!
Please enter your name here