GithubHelp home page GithubHelp logo

motionless's Introduction

motionless

fury.io Build Status Coverage Status

motionless is a Python library that takes the pain out of generating Google Static Map URLs. Three map types are supported. Each is illustrated below. For fully worked code see the examples directory for code that parses and visualizes both GeoRSS feeds and GPX files.

motionless is tested with Python versions 2.7 and 3.7 to 3.10.

Code is licensed under Apache 2.0

For DecoratedMaps, paths are encoded using gpolyencode (shipped with motionless). This is useful for keeping URLs with in the 2048 character limit imposed by the service.

Important

As of October 2018, Google Static Map API no longer supports keyless access. This means that if you want to continue using motionless, you'll need to generate and use a personal API key.

Installation instructions

Motionless is a pure python package. Install it with conda (or mamba):

$ conda install -c conda-forge motionless

or pip:

$ pip install motionless

CenterMap

CenterMaps show a map with no markers or paths, centered on a single location.

from motionless import CenterMap
cmap = CenterMap(address='151 third st, san francisco, ca', key=key)
print(cmap.generate_url())

SFMOMA

from motionless import CenterMap
cmap = CenterMap(lat=48.858278, lon=2.294489, maptype='satellite', key=key)
print(cmap.generate_url())

La Tour Eiffel

VisibleMap

VisibleMaps show a map with no markers or paths, automatically sized and zoomed to make the specified locations visible.

from motionless import VisibleMap
vmap = VisibleMap(maptype='terrain', key=key)
vmap.add_address('Sugarbowl, Truckee, CA')
vmap.add_address('Tahoe City, CA')
print(vmap.generate_url())

Sugarbowl and Tahoe City

DecoratedMap

DecoratedMaps contain markers and/or paths. They are automatically sized and zoomed to make the specified elements visible.

from motionless import DecoratedMap, LatLonMarker
dmap = DecoratedMap(maptype='satellite', key=key)
dmap.add_marker(LatLonMarker(27.988056, 86.925278, label='S'))
dmap.add_marker(LatLonMarker(28.007222, 86.859444, label='B'))
print(dmap.generate_url())

Everest Basecamp

You can add a list of style definitions to add custom styling to your map.

from motionless import DecoratedMap, AddressMarker
road_styles = [{
    'feature': 'road.highway',
    'element': 'geomoetry',
    'rules': {
        'visibility': 'simplified',
        'color': '#c280e9'
    }
}, {
    'feature': 'transit.line',
    'rules': {
        'visibility': 'simplified',
        'color': '#bababa'
    }
}]
dmap = DecoratedMap(style=road_styles, key=key)
dmap.add_marker(AddressMarker('1 Infinite Loop, Cupertino, CA',label='A'))
dmap.add_marker(AddressMarker('1600 Amphitheatre Parkway Mountain View, CA',label='G'))
print(dmap.generate_url())

Apple and Google

Further examples

Munich

Produced from parsing GPX file. See examples/munich.py

Earthquakes

Produced from geojson feed. See examples/earthquakes.py

motionless's People

Contributors

btbn avatar evstratbg avatar fmaussion avatar garymonson avatar hanneshapke avatar jairot avatar jmswag avatar mpaolino avatar neonihil avatar riggsd avatar ryancox avatar synapticarbors avatar timoroth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

motionless's Issues

there is no installation instructions in the readme

This would help new users who have never heard of motionless before today. It seems like it is available in the oggm channel which is a non-standard channel so it would not be obvious to new users:

https://anaconda.org/oggm/motionless

However, it may be that you only plan to have the package installed with other oggm modules and thus it should only be installed via oggm-dep. But this is not at all clear from the readme so the readme should be updated to reflect this.

gpolyencode.py is not installed

The gpolyencode.py file is not being installed.

$ pip install motionless
Collecting motionless
  Downloading motionless-1.3.tar.gz
Requirement already satisfied: setuptools in ./anaconda3/envs/motionless_test/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg (from motionless)
Collecting six (from motionless)
  Using cached six-1.10.0-py2.py3-none-any.whl
Building wheels for collected packages: motionless
  Running setup.py bdist_wheel for motionless ... done
  Stored in directory: /home/timo/.cache/pip/wheels/b6/b2/bc/a749ade161f228d95216d76a932cf00546f77cdad93f848cef
Successfully built motionless
Installing collected packages: six, motionless
Successfully installed motionless-1.3 six-1.10.0
$ python -c 'import motionless'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/timo/anaconda3/envs/motionless_test/lib/python3.5/site-packages/motionless.py", line 3, in <module>
    from gpolyencode import GPolyEncoder
ImportError: No module named 'gpolyencode'

Path Simplification for Decorated Map

GPolyEncode has a built-in path simplification algorithm (Ramer–Douglas–Peucker) with configurable distance-based threshold value. That threshold is not currently exposed by the DecoratedMap() constructor. Adding this extra parameter is trivial, however...

As far as I can understand this RDP implementation, the threshold units are in "degrees". Degrees are not a very intuitive end user unit for an API; meters seems more comprehensible. The default value, 0.00001 corresponds approximately to 1.1 meters at the equator. This simple RDP implementation, operating on lat/lon coordinates in degrees, has the property of operating in the Y (latitude) and X (longitude) dimensions differently as a function of latitude. In other words, allowing the user to express simplification threshold in meters would be an approximation that varies depending on where the path is located latitude-wise.

I can submit a PR which adds simplification_threshold as a constructor argument to DecoratedMap(). If this is desired, would you prefer that the units for this value be in "degrees" and passed directly to GPolyEncode, or that units be in "approximate meters" and then converted before being passed to GPolyEncode?

(Note that, whether this API change is made or not, motionless currently uses the default value of 0.00001 degrees so that all paths are being simplified at the ~1.1m level.)

six dependency imported implicitly in setup.py

Implicit import of six dependency in setup.py causes install failure

Hi there; I encountered an issue installing motionless on a fresh virtualenv for python 3.7.0

Great package by the way! Has been very useful!

Error message

user@localhost:~/some_dir $ pip install motionless
Collecting motionless
  Using cached https://files.pythonhosted.org/packages/.../motionless-1.3.2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/.../motionless/setup.py", line 3, in <module>
        from motionless import __version__
      File "/.../motionless/motionless.py", line 2, in <module>
        from six.moves.urllib.parse import quote, urlparse
    ModuleNotFoundError: No module named 'six'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /.../motionless/

Cause

The setup.py script imports the version from motionless.py at line #3.

This import implicitly invokes the import of the six module in motionless.py at line #5.

If six is not yet installed, installing via setuptools/pip will fail

Fix

Maybe move the version out into its own file?

v1.3.2 release?

Hi @ryancox , do you have time this week to push a minor release to pip? If yes let me know, I'll do the tagging/releasing here on github.

Google static map API marker colors

According to the google static maps API documentation it looks like the marker color also takes in a 16 bit hex value
Image 2022-03-03 at 5 23 06 PM

Is there a reason to limit the marker colors to only the color list?

Documentation needed?

Hello,

My name is Leo and I’m a CS student-- Recently, I’ve been working on a platform for editable codebase documentation.

I came across this repo while browsing GitHub and noticed it lacked documentation. Do you mind if I create docs for your repo? I'm sincerely hoping it will be useful for your needs.

About gpolyencode

Hi @ryancox , I have a few questions about gpolyencode, I hope that you can help me out:

Currently, only paths in DecoratedMaps can be encoded. Could it be possible to use gpolyencode to also encode a series of markers? I am asking because when I tried to make a map with many markers (e.g. earthquakes during the last 7 days), the url became too long.

The gpolyencode package is old and I'm not sure it is still maintained. It doesn't support python 3. The gpolyencode.py module which is located in the examples directory does now work with python 3 (it's just about importing from six import StringIO). What do you think about incorporating this piece of code to motionless? It has a non-restrictive license, so all what we have to do is to add their copyright notice to ours. (in fact, it should already be the case since their code is already on our repo)

generate_url method return character "|" instead of "%7C"

Hi Dear Sir/Madam
Thank you for your grate work.
I noticed that after generating url it doesn't convert character "|" to "%7C" so I had to replace it manually.

it's not a big issue but it's good to have in your package.

thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.