It is currently April 18th, 2024, 3:26 am

free open geocoding apis

Tips and Tricks from the Rainmeter Community
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: free open geocoding apis

Post by jsmorley »

One thing I notice that is a "user" issue with the api.

If you use commas in the search (which is pretty standard behavior) you can get unexpected results. I think the api treats "Paris, Idaho" for instance as "find Paris AND Idaho or Paris OR Idaho, and return the first match"

So "Paris, Idaho" will actually always return the Paris in France, where "Paris Idaho" without the comma, properly returns the city in the US.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: free open geocoding apis

Post by moshi »

jsmorley wrote: I actually kinda like the single return. Not only is it easier to parse, (by miles) it's not hard to use it that way. If you put in "paris" and meant "Paris Idaho" instead of "Paris France", you will get the wrong one and see that you need to narrow the search.

if you would want to improve this you could also display a map.

Code: Select all

http://dev.virtualearth.net/REST/V1/Imagery/Map/Road/#Location#?mapSize=266,202&key=AijbFhynMi9YlUoC5sbBKfrfbnkcMJ34sYBEORQwbsviodnw8nTkkgh5se5COtMs
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: free open geocoding apis

Post by moshi »

jsmorley wrote:One thing I notice that is a "user" issue with the api.

If you use commas in the search (which is pretty standard behavior) you can get unexpected results. I think the api treats "Paris, Idaho" for instance as "find Paris AND Idaho or Paris OR Idaho, and return the first match"

So "Paris, Idaho" will actually always return the Paris in France, where "Paris Idaho" without the comma, properly returns the city in the US.
i would split the skin in two "stages"

Code: Select all

[Variables]
Location=
Stage=1

[Stage]
@Include="#@#includes\YahooWOEID#Stage#.inc"

stage1 YahooWOEID1.inc

Code: Select all

[MeasureCount]
Measure=Calc
Formula=(([MeasureCount])+1)
DynamicVariables=1
IfAboveValue=2
IfAboveAction=[!WriteKeyValue Variables "Location" "[MeasureLocation1]" "#CURRENTFILE#"][!WriteKeyValue Variables "Stage" "2" "#CURRENTFILE#"][!Refresh "#CURRENTCONFIG#"]

[MeasureLocation1]
Measure=Calc
Formula=1
DynamicVariables=1
Substitute="1":"#Location#",",":" "
in stage 2 would be the whole webparsing stuff
and

Code: Select all

FinishAction=[!WriteKeyValue Variables "Stage" "1" "#CURRENTFILE#"]
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: free open geocoding apis

Post by moshi »

get's quite confused with Cyrillic input Стокгольм (Stockholm). but no point in complaining about a free service.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: free open geocoding apis

Post by jsmorley »

1) I went another way to deal with the commas...
YahooWOEID_2.0.rmskin

Code: Select all

[MeasureInput]
Measure=Plugin
Plugin=InputText.dll
X=7
Y=7
H=18
W=190
SolidColor=80,80,80,255
FontFace=Segoe UI
FontColor=255,255,255,255
FontSize=10
Command1=!SetVariable Location "$UserInput$"
Command2=!CommandMeasure MeasureNoCommas "StripCommas()"

[MeasureNoCommas]
Measure=Script
ScriptFile=StripCommas.lua
UpdateDivider=-1
Lua script:

Code: Select all

function StripCommas()

	inVar = SKIN:GetVariable('Location')
	outVar = string.gsub(inVar, ',', ' ')
	outVar = string.gsub(outVar, '  ', ' ')
	SKIN:Bang('!WriteKeyValue', 'Variables', 'Location', outVar)
	SKIN:Bang('!Refresh')

end --> StripCommas	
2) I can't get WebParser to download that map from that link you posted. I think it is "streaming" based on some javascript or other code, and can't be used as an image.
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: free open geocoding apis

Post by jsmorley »

moshi wrote:get's quite confused with Cyrillic input Стокгольм (Stockholm). but no point in complaining about a free service.
Yeah, I sorta thought it might hate that. It is ok with extended ASCII chars though, and seems to handle at least common translations for names.
4-2-2013 2-24-32 PM.png
You do not have the required permissions to view the files attached to this post.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: free open geocoding apis

Post by moshi »

jsmorley wrote: Yeah, I sorta thought it might hate that. It is ok with extended ASCII chars though, and seems to handle at least common translations for names.

actually i was talking about the api itself, not the input it gets from Rainmeter by default.

with my Evi skin i use:

Code: Select all

Substitute="1":"#EviInput#","![DetectEngine2] ":"","Ä":"%C3%84","ä":"%C3%A4","Ë":"%C3%8B","ë":"%C3%AB","Ï":"%C3%8F","ï":"%C3%AF","Ö":"%C3%96","ö":"%C3%B6","Ü":"%C3%9C","ü":"%C3%BC","Ÿ":"%C5%B8","ÿ":"%C3%BF","ß":"%C3%9F","Æ":"%C3%86","æ":"%C3%A6","Œ":"%C5%92","œ":"%C5%93","Ø":"%C3%98","ø":"%C3%B8","Å":"%C3%85","å":"%C3%A5","Ñ":"%C3%91","ñ":"%C3%B1","Á":"%C3%81","á":"%C3%A1","É":"%C3%89","é":"%C3%A9","Í":"%C3%8D","í":"%C3%AD","Ó":"%C3%93","ó":"%C3%B3","Ú":"%C3%9A","ú":"%C3%BA","À":"%C3%80","à":"%C3%A0","È":"%C3%88","è":"%C3%A8","Ì":"%C3%8C","ì":"%C3%AC","Ò":"%C3%92","ò":"%C3%B2","Ù":"%C3%99","ù":"%C3%B9","Â":"%C3%82","â":"%C3%A2","Ê":"%C3%8A","ê":"%C3%AA","Î":"%C3%8E","î":"%C3%AE","Ô":"%C3%94","ô":"%C3%B4","Û":"%C3%9B","û":"%C3%BB","Ç":"%C3%87","ç":"%C3%A7","Ą":"%C4%84","ą":"%C4%85","Ę":"%C4%98","ę":"%C4%99","Ł":"%C5%81","ł":"%C5%82","Ć":"%C4%86","ć":"%C4%87","Ń":"%C5%83","ń":"%C5%84","Ś":"%C5%9A","ś":"%C5%9B","Ź":"%C5%B9","ź":"%C5%BA","Ż":"%C5%BB","ż":"%C5%BC","Č":"%C4%8C","č":"%C4%8D","Ď":"%C4%8E","ď":"%C4%8F","Ě":"%C4%9A","ě":"%C4%9B","Ň":"%C5%87","ň":"%C5%88","Ř":"%C5%98","ř":"%C5%99","Š":"%C5%A0","š":"%C5%A1","Ť":"%C5%A4","ť":"%C5%A5","Ů":"%C5%AE","ů":"%C5%AF","Ý":"%C3%9D","ý":"%C3%BD","Ž":"%C5%BD","ž":"%C5%BE","Ĺ":"%C4%B9","ĺ":"%C4%BA","Ľ":"%C4%BD","ľ":"%C4%BE","Ŕ":"%C5%94","ŕ":"%C5%95","Ő":"%C5%90","ő":"%C5%91","Ű":"%C5%B0","ű":"%C5%B1","Đ":"%C4%90","đ":"%C4%91","Į":"%C4%AE","į":"%C4%AF","Ų":"%C5%B2","ų":"%C5%B3","Ū":"%C5%AA","ū":"%C5%AB","Ė":"%C4%96","ė":"%C4%97","Ā":"%C4%80","ā":"%C4%81","Ē":"%C4%92","ē":"%C4%93","Ģ":"%C4%A2","ģ":"%C4%A3","Ī":"%C4%AA","ī":"%C4%AB","Ķ":"%C4%B6","ķ":"%C4%B7","Ļ":"%C4%BB","ļ":"%C4%BC","Ņ":"%C5%85","ņ":"%C5%86","Ă":"%C4%82","ă":"%C4%83","Ș":"%C8%98","ș":"%C8%99","Ț":"%C8%9A","ț":"%C8%9B","Ã":"%C3%83","ã":"%C3%A3","Ĩ":"%C4%A8","ĩ":"%C4%A9","Õ":"%C3%95","õ":"%C3%B5","Ũ":"%C5%A8","ũ":"%C5%A9","А":"%D0%90","а":"%D0%B0","Б":"%D0%91","б":"%D0%B1","В":"%D0%92","в":"%D0%B2","Г":"%D0%93","г":"%D0%B3","Ґ":"%D2%90","ґ":"%D2%91","Д":"%D0%94","д":"%D0%B4","Ђ":"%D0%82","ђ":"%D1%92","Ѓ":"%D0%83","ѓ":"%D1%93","Е":"%D0%95","е":"%D0%B5","Ѐ":"%D0%80","ѐ":"%D1%90","Ё":"%D0%81","ё":"%D1%91","Є":"%D0%84","є":"%D1%94","Ж":"%D0%96","ж":"%D0%B6","З":"%D0%97","з":"%D0%B7","Ѕ":"%D0%85","ѕ":"%D1%95","И":"%D0%98","и":"%D0%B8","Ѝ":"%D0%8D","ѝ":"%D1%9D","І":"%D0%86","і":"%D1%96","Ї":"%D0%87","ї":"%D1%97","Й":"%D0%99","й":"%D0%B9","Ј":"%D0%88","ј":"%D1%98","К":"%D0%9A","к":"%D0%BA","Л":"%D0%9B","л":"%D0%BB","Љ":"%D0%89","љ":"%D1%99","М":"%D0%9C","м":"%D0%BC","Н":"%D0%9D","н":"%D0%BD","Њ":"%D0%8A","њ":"%D1%9A","О":"%D0%9E","о":"%D0%BE","П":"%D0%9F","п":"%D0%BF","Р":"%D0%A0","р":"%D1%80","С":"%D0%A1","с":"%D1%81","Т":"%D0%A2","т":"%D1%82","Ћ":"%D0%8B","ћ":"%D1%9B","Ќ":"%D0%8C","ќ":"%D1%9C","У":"%D0%A3","у":"%D1%83","Ў":"%D0%8E","ў":"%D1%9E","Ф":"%D0%A4","ф":"%D1%84","Х":"%D0%A5","х":"%D1%85","Ц":"%D0%A6","ц":"%D1%86","Ч":"%D0%A7","ч":"%D1%87","Џ":"%D0%8F","џ":"%D1%9F","Ш":"%D0%A8","ш":"%D1%88","Щ":"%D0%A9","щ":"%D1%89","Ъ":"%D0%AA","ъ":"%D1%8A","Ы":"%D0%AB","ы":"%D1%8B","Ь":"%D0%AC","ь":"%D1%8C","Э":"%D0%AD","э":"%D1%8D","Ю":"%D0%AE","ю":"%D1%8E","Я":"%D0%AF","я":"%D1%8F","Α":"%CE%91","α":"%CE%B1","Β":"%CE%92","β":"%CE%B2","Γ":"%CE%93","γ":"%CE%B3","Δ":"%CE%94","δ":"%CE%B4","Ε":"%CE%95","ε":"%CE%B5","Ζ":"%CE%96","ζ":"%CE%B6","Η":"%CE%97","η":"%CE%B7","Ι":"%CE%99","ι":"%CE%B9","Θ":"%CE%98","θ":"%CE%B8","Κ":"%CE%9A","κ":"%CE%BA","Λ":"%CE%9B","λ":"%CE%BB","Μ":"%CE%9C","μ":"%CE%BC","Ν":"%CE%9D","ν":"%CE%BD","Ξ":"%CE%9E","ξ":"%CE%BE","Ο":"%CE%9F","ο":"%CE%BF","Π":"%CE%A0","π":"%CF%80","Ρ":"%CE%A1","ρ":"%CF%81","Σ":"%CE%A3","σ":"%CF%83","ς":"%CF%82","Τ":"%CE%A4","τ":"%CF%84","Υ":"%CE%A5","υ":"%CF%85","Φ":"%CE%A6","φ":"%CF%86","Χ":"%CE%A7","χ":"%CF%87","Ψ":"%CE%A8","ψ":"%CF%88","Ω":"%CE%A9","ω":"%CF%89"
but the Yahoo! api returns Rostock instead of Stockholm, other apis like Yandex or Google work fine. somehow Yahoo! seems to shuffle the letters. :?
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: free open geocoding apis

Post by moshi »

btw. abbreviations work (ID=Idaho)
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: free open geocoding apis

Post by jsmorley »

Yes, and "points of interest" can be handy, for instance:
4-2-2013 5-04-31 PM.png
You do not have the required permissions to view the files attached to this post.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: free open geocoding apis

Post by moshi »

try postal codes. (for international postal codes Google is much better though)