Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - atomicdryad

#1
POI's / [KML/netlink] Panoramio automagically
March 28, 2014, 15:36:22
It appears Locus's .kml support handles this well, though there is some lag as it's downloading the thumbnails (the poi icons will be blue dots then turn into images).

This can't be imported, stick it in /sdcard/Locus/mapItems and activate via 'data' -> 'items'.



<?xml version='1.0' encoding='UTF-8'?>
<kml xmlns="http://earth.google.com/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
        <Document>
                <name>Panoramio</name>
                <open>1</open>

            <NetworkLink>
                <name>Panoramio</name>
                <flyToView>0</flyToView>
                <Link>
                    <href>http://www.panoramio.com/kml/</href>
                    <viewFormat>BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]</viewFormat>
                    <viewRefreshMode>onStop</viewRefreshMode>
                </Link>
            </NetworkLink>
        </Document>
</kml>
#2
Note: This is a .cgi script meant to run on a personal webserver, from a device with root access (see below for alternatives)...technically it's not an addon, however it improves upon Locus functionality in the following ways:

* The Wikipedia search function will return a descriptive POI with the article's first paragraphs, and the article's thumbnail. In addition, the rather frequent "List of ..." duplicate articles are prefixed with (L)
* Searching with the 'EO' locale will query the geonames.org datebase. Unlike the builtin geonames search, this is based on coordinates.
* Searching with the 'GL' locale will query geonames and return OSM POIs, based on coordinates.



install (server)

This requires a webserver that can run perl .cgi scripts. perl needs the LWP and JSON modules. The server must direct queries to http://api.wikilocation.org/articles . With apache, this means setting up a virtual host, or .htaccess rules like:

  RewriteCond %{HTTP_HOST} ^api\.wikilocation\.org$
  RewriteCond %{REQUEST_URI} articles
  RewriteCond %{QUERY_STRING} (.*)
  RewriteRule ^articles$ /wikiloc.cgi [L]


setup (android)

Unfortunately, since there's no functionality to change the search URLs in locus directly, one needs to redirect traffic to api.wikilocation.org. If you have root on your device, this is a simple matter of editing /system/etc/hosts and adding
123.123.123.123 api.wikilocation.org
where "123.123.123.123" is the ip address of your webserver.
If you don't have root, it's possible to make this work over wifi by fiddling with your router's DNS. Modifying the Locus .apk is another alternative (however, I'm new and this is the dev's forum, so I won't assist in that).

Once done, simply search wikipedia, you should see descriptive text. If there's an error, it will return one POI titled "A script error has occurred", with debugging output in it's description.

final note if you plan to use geonames you'll want to change this config variable:
our $geonamesUsername="demo";
The "demo" user is always past it's quota. You can obtain a username at http://geonames.org



If you know perl, extending this script should be easy. To replace a locale with a function, see the following config mapping:

our %localeOverride = (
  'eo' => sub { snag_geonames('default'); }, # EO: geonames spatial search
  'gl' => sub { snag_geonames('osm' ); },    # GL: osm poi search
);



POIs are sent to Locus as so:

{articles:
  [
    {"id":0,
     "lat":123.456,
     "lng":-78.90123,
     "distance":9001,
     "title":"Distance is in meters",
     "type":"<blink>I am a description</blink><br><img src=\"http://www.infinitecat.com/cute-cats/suspension-bridge.jpg\">",
     "url":"http://www.presentcat.com/"
    },
    {"id":123,
     .......(etc)
    },
  ]
}


Quick howto: replace wikipedia for the russian locale with a POI over george w bush's house:
Add to %localeOverride:
  'ru' => sub { dummy_function(); },
Then:

sub dummy_function {
  push @{$data->{articles}}, mkentry(123,29.75786,-95.46454,0,"Uhm..","Hey wait this isn't $param{lat} $param{lng}...","http://xda-developers.com");
  $out = encode_json($data);
}