diff --git a/assets/highlight.css b/assets/highlight.css index 1240f03..1c69f6e 100644 --- a/assets/highlight.css +++ b/assets/highlight.css @@ -1,18 +1,18 @@ :root { - --light-hl-0: #001080; - --dark-hl-0: #9CDCFE; + --light-hl-0: #795E26; + --dark-hl-0: #DCDCAA; --light-hl-1: #000000; --dark-hl-1: #D4D4D4; - --light-hl-2: #AF00DB; - --dark-hl-2: #C586C0; - --light-hl-3: #A31515; - --dark-hl-3: #CE9178; - --light-hl-4: #098658; - --dark-hl-4: #B5CEA8; - --light-hl-5: #008000; - --dark-hl-5: #6A9955; - --light-hl-6: #795E26; - --dark-hl-6: #DCDCAA; + --light-hl-2: #A31515; + --dark-hl-2: #CE9178; + --light-hl-3: #AF00DB; + --dark-hl-3: #C586C0; + --light-hl-4: #001080; + --dark-hl-4: #9CDCFE; + --light-hl-5: #098658; + --dark-hl-5: #B5CEA8; + --light-hl-6: #008000; + --dark-hl-6: #6A9955; --light-hl-7: #0000FF; --dark-hl-7: #569CD6; --light-hl-8: #0070C1; diff --git a/badges/coverage.svg b/badges/coverage.svg deleted file mode 100644 index bf74062..0000000 --- a/badges/coverage.svg +++ /dev/null @@ -1,20 +0,0 @@ - - coverage: 100% - - - - - - - - - - - - - diff --git a/functions/calculateResolution.html b/functions/calculateResolution.html index 5d80cd6..c90dad6 100644 --- a/functions/calculateResolution.html +++ b/functions/calculateResolution.html @@ -1 +1 @@ -calculateResolution | nostr-geotags

Function calculateResolution

  • Parameters

    • input: number
    • max: undefined | number

    Returns number

\ No newline at end of file +calculateResolution | nostr-geotags

Function calculateResolution

  • Parameters

    • input: number
    • max: undefined | number

    Returns number

\ No newline at end of file diff --git a/functions/default.html b/functions/default.html index 2d01cb9..b753576 100644 --- a/functions/default.html +++ b/functions/default.html @@ -8,4 +8,4 @@ city names, etc. The function can also deduplicate and sort the tags.

If the input data is null, an error is thrown. The input must be an object.

Throws

Throws an error if the input data is null or not an object.

-
\ No newline at end of file +
\ No newline at end of file diff --git a/functions/filterNonStringTags.html b/functions/filterNonStringTags.html index b5293dc..39a381f 100644 --- a/functions/filterNonStringTags.html +++ b/functions/filterNonStringTags.html @@ -1,4 +1,4 @@ filterNonStringTags | nostr-geotags

Function filterNonStringTags

  • Filters out tags that contain non-string items.

    Parameters

    • tags: GeoTags[]

      An array of tags, where each tag is an array.

    Returns GeoTags[]

    Filtered array of tags.

    -
\ No newline at end of file +
\ No newline at end of file diff --git a/functions/filterOutType.html b/functions/filterOutType.html index 5a54d10..ebab42f 100644 --- a/functions/filterOutType.html +++ b/functions/filterOutType.html @@ -6,4 +6,4 @@ It iterates over the array and excludes any tags where the third element (the type identifier) matches the specified type. This is useful for removing specific types of geotags from a list of various tags.

-
\ No newline at end of file +
\ No newline at end of file diff --git a/functions/generateCountryTagKey.html b/functions/generateCountryTagKey.html index e6925df..acd93dc 100644 --- a/functions/generateCountryTagKey.html +++ b/functions/generateCountryTagKey.html @@ -4,4 +4,4 @@

This function determines the key to be used in a tag array based on the type of data. For the type 'name', it returns 'countryName', indicating the tag represents a country's name. For any other type, it returns 'countryCode', typically representing an ISO-3166 country code.

-
\ No newline at end of file +
\ No newline at end of file diff --git a/functions/iso31661Namespace.html b/functions/iso31661Namespace.html index dbb8a29..c45c2ea 100644 --- a/functions/iso31661Namespace.html +++ b/functions/iso31661Namespace.html @@ -1 +1 @@ -iso31661Namespace | nostr-geotags

Function iso31661Namespace

\ No newline at end of file +iso31661Namespace | nostr-geotags

Function iso31661Namespace

\ No newline at end of file diff --git a/functions/iso31662Namespace.html b/functions/iso31662Namespace.html index 0c68cff..d13d7e2 100644 --- a/functions/iso31662Namespace.html +++ b/functions/iso31662Namespace.html @@ -1 +1 @@ -iso31662Namespace | nostr-geotags

Function iso31662Namespace

\ No newline at end of file +iso31662Namespace | nostr-geotags

Function iso31662Namespace

\ No newline at end of file diff --git a/functions/iso31663Namespace.html b/functions/iso31663Namespace.html index 3313407..371dcf6 100644 --- a/functions/iso31663Namespace.html +++ b/functions/iso31663Namespace.html @@ -1 +1 @@ -iso31663Namespace | nostr-geotags

Function iso31663Namespace

\ No newline at end of file +iso31663Namespace | nostr-geotags

Function iso31663Namespace

\ No newline at end of file diff --git a/functions/sanitize.html b/functions/sanitize.html index abdabd3..3c91b58 100644 --- a/functions/sanitize.html +++ b/functions/sanitize.html @@ -7,4 +7,4 @@

Returns GeoTags[]

-
\ No newline at end of file +
\ No newline at end of file diff --git a/functions/sortTagsByKey.html b/functions/sortTagsByKey.html index 257e2a5..9fa1f7e 100644 --- a/functions/sortTagsByKey.html +++ b/functions/sortTagsByKey.html @@ -3,4 +3,4 @@

Returns GeoTags[]

The sorted array of tags.

This function sorts the tags based on the tag key (third element), which allows for easier processing and organization of tags.

-
\ No newline at end of file +
\ No newline at end of file diff --git a/index.html b/index.html index 8cdada7..2a32ad8 100644 --- a/index.html +++ b/index.html @@ -1,7 +1,4 @@ -nostr-geotags

nostr-geotags

nostr-geotags

-

ATTENTION: Use at your own risk, this is not a widely accepted standard, and there are chances a proposed standard will differ greatly or slightly from this pattern. See NIP-115

-
-

semver +nostr-geotags

nostr-geotags

nostr-geotags

semver cov test publish @@ -9,12 +6,12 @@ covgen npm bundle size npm bundle size

-

Summary

nostr-geotags is a modern ESM-only package for generating nostr geo tags (['g', ...]) based on various inputs like latitude, longitude, city, country, etc. It uses iso-3166 and ngeohash to generate geodata. This package is alpha and the API and response formats will change.

+

Summary

nostr-geotags is a modern ESM-only package for generating discoverable geohash and ISO-3166-1/2/3 tags using NIP_32 based on various inputs like latitude, longitude, city, country, etc. It uses iso-3166 and ngeohash to generate geodata. This package is alpha and the API and response formats will change. This package has gone full-circle and now implements NIP-32 just as it did in the first commit.

This package was derived from needs in @nostrwatch, an OpenSats Grant Recipient, and so was made possible by OpenSats.

Installation

The package is available on npm and can be installed using npm, yarn, or pnpm.

-
npm install nostr-geotags

yarn add nostr-geotags

pnpm add nostr-geotags +
npm install nostr-geotags

yarn add nostr-geotags

pnpm add nostr-geotags
-

Usage

import ngeotags from 'nostr-geotags'

event = {}
event.kind = 1
//created_at, content etc...
event.tags = []
event.tags.push(['t', 'nostrworks'])

const inputData = {
lat: 52.5200,
lon: 13.4050,
city: 'Berlin',
countryCode: 'DE'
};

const options = {
geohash: true,
gps: true,
city: true,
iso31662: true
};

event.tags = [...event.tags, ...ngeotags(inputData, options)];
//sign and verify the event
console.log(event); +

Usage

import ngeotags from 'nostr-geotags'

event = {}
event.kind = 1
//created_at, content etc...
event.tags = []
event.tags.push(['t', 'nostrworks'])

const inputData = {
lat: 52.5200,
lon: 13.4050,
city: 'Berlin',
countryCode: 'DE'
};

const options = {
geohash: true,
gps: true,
city: true,
iso31662: true
};

event.tags = [...event.tags, ...ngeotags(inputData, options)];
//sign and verify the event
console.log(event);

Input Reference

The inputData object can contain:

    @@ -123,15 +120,15 @@ ]

    Here two alpha2 codes are returned, the original ISO-3166-1 code, and the changed ISO-3166-3 code. Since the other ISO-3166-3 properties for AI are the same as their ISO-3166-1 counter-parts, they are not included.

    Example Response

    Here is the default response when lat, lon, countryCode, regionName, and planet are provided, with everything else default

    -
    [ 'l', 'u2mwdd8q4' ],
    [ 'l', 'u2mwdd8q' ],
    [ 'l', 'u2mwdd8' ],
    [ 'l', 'u2mwdd' ],
    [ 'l', 'u2mwd' ],
    [ 'l', 'u2mw' ],
    [ 'l', 'u2m' ],
    [ 'l', 'u2' ],
    [ 'l', 'u' ],
    [ 'L', 'ISO-3166-1' ],
    [ 'l', 'HU', 'ISO-3166-1' ],
    [ 'l', 'HUN', 'ISO-3166-1' ],
    [ 'l', '348', 'ISO-3166-1' ],
    [ 'L', 'countryName' ],
    [ 'l', 'Hungary', 'countryName' ],
    [ 'L', 'cityName' ],
    [ 'l', 'Budapest', 'cityName' ] +
    [ 'g', 'u2mwdd8q4' ],
    [ 'g', 'u2mwdd8q' ],
    [ 'g', 'u2mwdd8' ],
    [ 'g', 'u2mwdd' ],
    [ 'g', 'u2mwd' ],
    [ 'g', 'u2mw' ],
    [ 'g', 'u2m' ],
    [ 'g', 'u2' ],
    [ 'g', 'u' ],
    [ 'L', 'countryCode' ],
    [ 'l', 'HU', 'countryCode' ],
    [ 'l', 'HUN', 'countryCode' ],
    [ 'l', '348', 'countryCode' ],
    [ 'L', 'countryName' ],
    [ 'l', 'Hungary', 'countryName' ],
    [ 'L', 'cityName' ],
    [ 'l', 'Budapest', 'cityName' ]

    This is a response with all options enabled (deduped, dedupe: true)

    -
    [ 'l', 'u2mwdd8q4' ],
    [ 'l', 'u2mwdd8q' ],
    [ 'l', 'u2mwdd8' ],
    [ 'l', 'u2mwdd' ],
    [ 'l', 'u2mwd' ],
    [ 'l', 'u2mw' ],
    [ 'l', 'u2m' ],
    [ 'l', 'u2' ],
    [ 'l', 'u' ],
    [ 'l', '47.5636, 19.0947', 'dd' ],
    [ 'L', 'geo.lat' ],
    [ 'l', '47.5636', 'geo.lat' ],
    [ 'l', '47.563', 'geo.lat' ],
    [ 'l', '47.56', 'geo.lat' ],
    [ 'l', '47.5', 'geo.lat' ],
    [ 'L', 'geo.lon' ],
    [ 'l', '19.0947', 'geo.lon' ],
    [ 'l', '19.094', 'geo.lon' ],
    [ 'l', '19.09', 'geo.lon' ],
    [ 'l', '19', 'geo.lon' ],
    [ 'L', 'ISO-3166-1' ],
    [ 'l', 'HU', 'ISO-3166-1' ],
    [ 'l', 'HUN', 'ISO-3166-1' ],
    [ 'l', '348', 'ISO-3166-1' ],
    [ 'L', 'countryName' ],
    [ 'l', 'Hungary', 'countryName' ],
    [ 'L', 'ISO-3166-2' ],
    [ 'l', 'HU-BU', 'ISO-3166-2' ],
    [ 'L', 'cityName' ],
    [ 'l', 'Budapest', 'cityName' ],
    [ 'L', 'planetName' ],
    [ 'l', 'Earth', 'planetName' ] +
    [ 'g', 'u2mwdd8q4' ],
    [ 'g', 'u2mwdd8q' ],
    [ 'g', 'u2mwdd8' ],
    [ 'g', 'u2mwdd' ],
    [ 'g', 'u2mwd' ],
    [ 'g', 'u2mw' ],
    [ 'g', 'u2m' ],
    [ 'g', 'u2' ],
    [ 'g', 'u' ],
    [ 'l', '47.5636, 19.0947', 'dd' ],
    [ 'L', 'dd.lat' ],
    [ 'l', '47.5636', 'dd.lat' ],
    [ 'l', '47.563', 'dd.lat' ],
    [ 'l', '47.56', 'dd.lat' ],
    [ 'l', '47.5', 'dd.lat' ],
    [ 'L', 'dd.lon' ],
    [ 'l', '19.0947', 'dd.lon' ],
    [ 'l', '19.094', 'dd.lon' ],
    [ 'l', '19.09', 'dd.lon' ],
    [ 'l', '19', 'dd.lon' ],
    [ 'L', 'countryCode' ],
    [ 'l', 'HU', 'countryCode' ],
    [ 'l', 'HUN', 'countryCode' ],
    [ 'l', '348', 'countryCode' ],
    [ 'L', 'countryName' ],
    [ 'l', 'Hungary', 'countryName' ],
    [ 'L', 'regionCode' ],
    [ 'l', 'HU-BU', 'regionCode' ],
    [ 'L', 'cityName' ],
    [ 'l', 'Budapest', 'cityName' ],
    [ 'L', 'planetName' ],
    [ 'l', 'Earth', 'planetName' ]

    Development

    To build the package, run:

    -
    npm run build
    +
    npm run build
     

    To run tests:

    -
    npm test
    +
    npm test
     
\ No newline at end of file diff --git a/interfaces/InputData.html b/interfaces/InputData.html index 472368d..849a8dc 100644 --- a/interfaces/InputData.html +++ b/interfaces/InputData.html @@ -1,4 +1,4 @@ -InputData | nostr-geotags

Interface InputData

interface InputData {
    cityName?: string;
    countryCode?: string;
    countryName?: string;
    geohash?: string;
    lat?: number;
    lon?: number;
    planetName?: string;
    regionName?: string;
    [key: string]: any;
}

Indexable

[key: string]: any

Properties

cityName? +InputData | nostr-geotags

Interface InputData

interface InputData {
    cityName?: string;
    countryCode?: string;
    countryName?: string;
    geohash?: string;
    lat?: number;
    lon?: number;
    planetName?: string;
    regionName?: string;
    [key: string]: any;
}

Indexable

[key: string]: any

Properties

cityName?: string
countryCode?: string
countryName?: string
geohash?: string
lat?: number
lon?: number
planetName?: string
regionName?: string
\ No newline at end of file +

Properties

cityName?: string
countryCode?: string
countryName?: string
geohash?: string
lat?: number
lon?: number
planetName?: string
regionName?: string
\ No newline at end of file diff --git a/interfaces/Options.html b/interfaces/Options.html index 7291c19..389d122 100644 --- a/interfaces/Options.html +++ b/interfaces/Options.html @@ -1,4 +1,4 @@ -Options | nostr-geotags

Interface Options

interface Options {
    city?: boolean;
    cityName?: null | boolean;
    country?: boolean;
    countryCode?: null | boolean;
    countryName?: null | boolean;
    ddMaxResolution?: number;
    geohash?: boolean;
    gps?: boolean;
    iso31661?: boolean;
    iso31662?: boolean;
    iso31663?: boolean;
    isoAsNamespace?: boolean;
    planet?: boolean;
    planetName?: null | boolean;
    region?: boolean;
    regionCode?: null | boolean;
    regionName?: null | boolean;
    sort?: boolean;
    unM49AsNamespace?: boolean;
}

Properties

city? +Options | nostr-geotags

Interface Options

interface Options {
    city?: boolean;
    cityName?: null | boolean;
    country?: boolean;
    countryCode?: null | boolean;
    countryName?: null | boolean;
    ddMaxResolution?: number;
    geohash?: boolean;
    gps?: boolean;
    iso31661?: boolean;
    iso31662?: boolean;
    iso31663?: boolean;
    isoAsNamespace?: boolean;
    planet?: boolean;
    planetName?: null | boolean;
    region?: boolean;
    regionCode?: null | boolean;
    regionName?: null | boolean;
    sort?: boolean;
    unM49AsNamespace?: boolean;
}

Properties

city?: boolean
cityName?: null | boolean
country?: boolean
countryCode?: null | boolean
countryName?: null | boolean
ddMaxResolution?: number
geohash?: boolean
gps?: boolean
iso31661?: boolean
iso31662?: boolean
iso31663?: boolean
isoAsNamespace?: boolean
planet?: boolean
planetName?: null | boolean
region?: boolean
regionCode?: null | boolean
regionName?: null | boolean
sort?: boolean
unM49AsNamespace?: boolean
\ No newline at end of file +

Properties

city?: boolean
cityName?: null | boolean
country?: boolean
countryCode?: null | boolean
countryName?: null | boolean
ddMaxResolution?: number
geohash?: boolean
gps?: boolean
iso31661?: boolean
iso31662?: boolean
iso31663?: boolean
isoAsNamespace?: boolean
planet?: boolean
planetName?: null | boolean
region?: boolean
regionCode?: null | boolean
regionName?: null | boolean
sort?: boolean
unM49AsNamespace?: boolean
\ No newline at end of file diff --git a/types/GeoTags.html b/types/GeoTags.html index 5e02bc5..40d6709 100644 --- a/types/GeoTags.html +++ b/types/GeoTags.html @@ -1,2 +1,2 @@ GeoTags | nostr-geotags

Type alias GeoTags

GeoTags: Geohash | LabelTag

Represents a union of all possible types returned by generateTags()

-
\ No newline at end of file +
\ No newline at end of file diff --git a/types/Geohash.html b/types/Geohash.html index 224c5a4..2fd920e 100644 --- a/types/Geohash.html +++ b/types/Geohash.html @@ -1,2 +1,2 @@ Geohash | nostr-geotags

Type alias Geohash

Geohash: [string, string] | [string, string, string]

Represents a nostr event g (geo) tag with a length of 2

-
\ No newline at end of file +
\ No newline at end of file diff --git a/types/ISO31663FieldType.html b/types/ISO31663FieldType.html index 0078ef6..ff14fb8 100644 --- a/types/ISO31663FieldType.html +++ b/types/ISO31663FieldType.html @@ -1 +1 @@ -ISO31663FieldType | nostr-geotags

Type alias ISO31663FieldType

ISO31663FieldType: "alpha2" | "alpha3" | "numeric" | "name"
\ No newline at end of file +ISO31663FieldType | nostr-geotags

Type alias ISO31663FieldType

ISO31663FieldType: "alpha2" | "alpha3" | "numeric" | "name"
\ No newline at end of file diff --git a/types/Label.html b/types/Label.html index 6912ec0..9cd5e3f 100644 --- a/types/Label.html +++ b/types/Label.html @@ -1,2 +1,2 @@ Label | nostr-geotags

Type alias Label

Label: [string, string, string]

Represents a nostr event l (geo) tag with a length of 2

-
\ No newline at end of file +
\ No newline at end of file diff --git a/types/LabelNamespace.html b/types/LabelNamespace.html index 429c24b..92a664f 100644 --- a/types/LabelNamespace.html +++ b/types/LabelNamespace.html @@ -1,2 +1,2 @@ LabelNamespace | nostr-geotags

Type alias LabelNamespace

LabelNamespace: [string, string]

Represents a nostr event L (label) tag with a length of 2

-
\ No newline at end of file +
\ No newline at end of file diff --git a/types/LabelTag.html b/types/LabelTag.html index a381184..2cb9acb 100644 --- a/types/LabelTag.html +++ b/types/LabelTag.html @@ -1,2 +1,2 @@ LabelTag | nostr-geotags

Type alias LabelTag

LabelTag: LabelNamespace | Label

Represents a union of LabelNamespace and Label

-
\ No newline at end of file +
\ No newline at end of file