Add GPS coordinate as wgs84 tag
This commit is contained in:
parent
00c9a3686e
commit
3543529600
1 changed files with 10 additions and 7 deletions
17
main.ts
17
main.ts
|
@ -92,6 +92,7 @@ for (const i in posts) {
|
||||||
|
|
||||||
// Populated from the first media item with coordinates
|
// Populated from the first media item with coordinates
|
||||||
let geotags;
|
let geotags;
|
||||||
|
let event_tags: string[][] = [];
|
||||||
|
|
||||||
let first = true;
|
let first = true;
|
||||||
for (const j in post.media) {
|
for (const j in post.media) {
|
||||||
|
@ -146,15 +147,20 @@ for (const i in posts) {
|
||||||
iso31663: false
|
iso31663: false
|
||||||
};
|
};
|
||||||
|
|
||||||
let exif_data = media.media_metadata.photo_metadata.exif_data;
|
const exif_data = media.media_metadata.photo_metadata.exif_data;
|
||||||
if (exif_data) {
|
if (exif_data) {
|
||||||
for (const k in exif_data) {
|
for (const k in exif_data) {
|
||||||
const exif_item = exif_data[k];
|
const exif_item = exif_data[k];
|
||||||
if (exif_item.latitude != undefined && exif_item.latitude != undefined) {
|
if (exif_item.latitude != undefined && exif_item.latitude != undefined) {
|
||||||
geotags = ngeotags({
|
// Add coordinates as a tag.
|
||||||
|
// There is currently no NIP defining a wgs84 tag!
|
||||||
|
event_tags.push(['wgs84', String(exif_item.latitude), String(exif_item.longitude)])
|
||||||
|
// Encode coordinates as Geohash in different resolutions:
|
||||||
|
// https://en.wikipedia.org/wiki/Geohash
|
||||||
|
event_tags = [...event_tags, ...ngeotags({
|
||||||
lat: exif_item.latitude,
|
lat: exif_item.latitude,
|
||||||
lon: exif_item.longitude
|
lon: exif_item.longitude
|
||||||
}, options);
|
}, options)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,12 +171,9 @@ for (const i in posts) {
|
||||||
let event = {
|
let event = {
|
||||||
kind: 1,
|
kind: 1,
|
||||||
content: message,
|
content: message,
|
||||||
tags: [],
|
tags: event_tags,
|
||||||
created_at: created_at
|
created_at: created_at
|
||||||
}
|
}
|
||||||
if (geotags != undefined) {
|
|
||||||
event.tags = [...event.tags, ...geotags];
|
|
||||||
}
|
|
||||||
const signed_event = await signer.signEvent(event);
|
const signed_event = await signer.signEvent(event);
|
||||||
console.log(signed_event);
|
console.log(signed_event);
|
||||||
events.push(signed_event);
|
events.push(signed_event);
|
||||||
|
|
Loading…
Reference in a new issue