Native Libraries
GoTotus provides native libraries for a more fluid syntax and simpler use:
Python
Location: https://github.com/GoTotus/pytotus
pip install totus
from totus import Totus
t = Totus()
reference = t.Reference()
print("Any shop nearby:")
print(reference.GeoPOI(gh='69y7pkxfc', distance=1000, what='shop', limit=2))
print("Any shop nearby, but prividing lat/lon instead of geohash:")
print(reference.GeoPOI(lat=-34.60362, lon=-58.3824, what='shop', limit=2))
print("Only bookshops, 2km around:")
print(reference.GeoPOI(gh='69y7pkxfc', distance=2000, what='shop', filter={'shop': 'books'}, limit=2))
print("Only bookshops, 2km around, name includes the word 'libro' in any case:")
print(reference.GeoPOI(gh='69y7pkxfc', distance=2000, what='shop', filter={'shop': 'books', 'name': '~*libro*'}, limit=2))
will Output:
Any shop nearby:
[{
"id": 4675113766,
"lat": -34.60362,
"lon": -58.3824,
"gh": "69y7pkx5r3",
"dist": 71.6,
"info": {
"addr:city": "Ciudad Aut\u00f3noma de Buenos Aires",
"addr:country": "AR",
"addr:street": "Avenida Corrientes",
"name": "Maxikiosko",
"shop": "kiosk"
}
}, {
"id": 12179098601,
"lat": -34.60395,
"lon": -58.38076,
"gh": "69y7ps83ms",
"dist": 84,
"info": {
"addr:housenumber": "999",
"addr:street": "Avenida Presidente Roque S\u00e1enz Pe\u00f1a",
"name": "I Love Gifts",
"shop": "gift"
}
}]
Any shop nearby, but prividing lat/lon instead of geohash:
[{
"id": 4675113766,
"lat": -34.60362,
"lon": -58.3824,
"gh": "69y7pkx5r3",
"dist": 0.4,
"info": {
"addr:city": "Ciudad Aut\u00f3noma de Buenos Aires",
"addr:country": "AR",
"addr:street": "Avenida Corrientes",
"name": "Maxikiosko",
"shop": "kiosk"
}
}, {
"id": 5355217400,
"lat": -34.60365,
"lon": -58.38276,
"gh": "69y7pkwgp5",
"dist": 33,
"info": {
"shop": "books"
}
}]
Only bookshops, 2km around:
[{
"id": 5355217400,
"lat": -34.60365,
"lon": -58.38276,
"gh": "69y7pkwgp5",
"dist": 103.7,
"info": {
"shop": "books"
}
}, {
"id": 4683477630,
"lat": -34.604,
"lon": -58.38414,
"gh": "69y7pktcng",
"dist": 232.7,
"info": {
"addr:city": "Ciudad Aut\u00f3noma de Buenos Aires",
"addr:country": "AR",
"addr:street": "Avenida Corrientes",
"name": "Obel Libros",
"shop": "books"
}
}]
Only bookshops, 2km around, name includes the word 'libro' in any case:
[{
"id": 4683477630,
"lat": -34.604,
"lon": -58.38414,
"gh": "69y7pktcng",
"dist": 232.7,
"info": {
"addr:city": "Ciudad Aut\u00f3noma de Buenos Aires",
"addr:country": "AR",
"addr:street": "Avenida Corrientes",
"name": "Obel Libros",
"shop": "books"
}
}, {
"id": 4675113801,
"lat": -34.60372,
"lon": -58.38426,
"gh": "69y7pktfsp",
"dist": 241.1,
"info": {
"addr:city": "Ciudad Aut\u00f3noma de Buenos Aires",
"addr:country": "AR",
"addr:street": "Avenida Corrientes",
"name": "Cuspide Libros",
"shop": "books"
}
}]
Node / Javascript
npm i totus
let Totus = require('totus');
(async () => {
try {
const t = new Totus(); // Assumes TOTUS_KEY is set in environment variables
const reference = t.Reference();
console.log("Any shop nearby:");
let result = await reference.GeoPOI({gh: '69y7pkxfc', distance: 1000, what: 'shop', limit: 2});
console.log(result.map(poi => poi.data()));
console.log("\nAny shop nearby, but providing lat/lon instead of geohash:");
result = await reference.GeoPOI({lat: -34.60362, lon: -58.3824, what: 'shop', limit: 2});
console.log(result.map(poi => poi.data()));
console.log("\nOnly bookshops, 2km around:");
result = await reference.GeoPOI({gh: '69y7pkxfc', distance: 2000, what: 'shop', filter: {shop: 'books'}, limit: 2});
console.log(result.map(poi => poi.data()));
console.log("\nOnly bookshops, 2km around, name includes the word 'libro' in any case:");
result = await reference.GeoPOI({gh: '69y7pkxfc', distance: 2000, what: 'shop', filter: {shop: 'books', name: '~*libro*'}, limit: 2});
console.log(result.map(poi => poi.data()));
} catch (error) {
console.error('Error:', error.message);
}
})();
Golang
go get github.com/GoTotus/gototus
func main() {
t, err := totus.NewTotus("", "", "")
ref := t.Reference()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Println("Any shop nearby:")
pois, err := ref.GeoPOI(
totus.NewGeoPOISearch().
WithGeoHash("69y7pkxfc").
WithWhat("shop").
WithDistance(1000.0).
WithLimit(2))
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
for _, p := range pois {
fmt.Println(p)
}
}