View Single Post
Posts: 1,548 | Thanked: 7,510 times | Joined on Apr 2010 @ Czech Republic
#1059
ModRana V0.32 has been release, with CLI interface imeprovements. Repost from the Saera thread:

ModRana now has quite a few new CLI options for use by Saera (and any other program or script):
Code:
usage: modrana.py [-h] [-d device ID] [-u GUI ID]
                  [--local-search search query]
                  [--local-search-location an address or geographic coordinates]
                  [--address-search an address]
                  [--wikipedia-search search query] [--return-static-map-url]
                  [--center-on-position] [--set-zl zoom level number]
                  [--center-on-position-on-zl zoom level number]
                  [--focus-on-coordinates geographic coordinates with the geo: prefix]

A flexible GPS navigation system.

optional arguments:
  -h, --help            show this help message and exit
  -d device ID          specify device type
  -u GUI ID             specify user interface type (GTK or QML)
  --local-search search query
                        specify a local search query EXAMPLE: "pizza"
  --local-search-location an address or geographic coordinates
                        specify a geographic location for a local search query
                        (current location is used by default), both addresses
                        and geographic coordinates with the geo: prefix are
                        supported; use "LAST_KNOWN_POSITION" to use last known
                        position EXAMPLE: "London" or
                        "geo:50.083333,14.416667" or LAST_KNOWN_POSITION"
  --address-search an address
                        specify an address search query EXAMPLE: "Baker Street
                        221b, London"
  --wikipedia-search search query
                        specify a local search query EXAMPLE: "Prague castle"
  --return-static-map-url
                        return static map URL for a CLI query (works for local
                        search, address and Wikipedia search)
  --center-on-position  focus on the current position & enable centering
  --set-zl zoom level number
                        set a zoom level EXAMPLE: 15
  --center-on-position-on-zl zoom level number
                        focus on current position on a given zoom level
                        EXAMPLE: 15
  --focus-on-coordinates geographic coordinates with the geo: prefix
                        focus on given coordinates, NOTE you can use --set-zl
                        to set zoom level, EXAMPLE: "geo:50.083333,14.416667"
Search
The search options work in two modes:

If --return-static-map-url is used, modRana loads only the most essential modules, handles the query and exits after printing the Url pointing to a static-map with the result to stdout.

If --return-static-map-url is not used, modRana starts normally and shows the search results.

Exit codes
If everything went fine, modRana returns 0, as expected.

If something went wrong, modRana exits with one of the codes below:
Code:
SYNTAX_ERROR = 2
SEARCH_NO_RESULTS_FOUND = 3
SEARCH_PROVIDER_TIMEOUT_ERROR = 4
SEARCH_PROVIDER_ERROR = 5
LOCAL_SEARCH_CURRENT_POSITION_UNKNOWN_ERROR = 6
Local search takes some time
When modRana does local search and no --local-search-location is specified, it starts the GPS and waits for up to 30 seconds for it to supply valid location coordinates.

If the current location is not determined within the 30 second time limit, modRana uses the last known position (if available).

Results
If more results are returned for --return-static-map-url, modRana just returns Url for the first one (this is also usually the result with the best accuracy).

It also shouldn't be difficult to add support for returning multiple results or to return coordinates or other information to stdout (maybe URL + result title ?).

Other supported options
It is also possible to set the zoom level, make modRana focus on a set of coordinates or center on current position.

Routing
There are not yet CLI options for routing, but will be added in near future.

How to use
Example - show address search result in GTK UI on zoom level 10:
Code:
python /opt/modrana/modrana.py -d n900 -u GTK --address-search "Prague" --set-zl 10
Example - return local search result at static map URL on default zoom level (15):
Code:
python /opt/modrana/modrana.py --local-search "pizza" --return-static-map-url
Feedback
Don't hesitate to let me know if you hit any issues or if you have any ideas for improvements.
__________________
modRana: a flexible GPS navigation system
Mieru: a flexible manga and comic book reader
Universal Components - a solution for native looking yet component set independent QML appliactions (QtQuick Controls 2 & Silica supported as backends)

Last edited by MartinK; 2012-06-16 at 09:26.
 

The Following 6 Users Say Thank You to MartinK For This Useful Post: