Git Product home page Git Product logo

python-overpy's Introduction

Python Overpass Wrapper

A Python Wrapper to access the Overpass API.

Have a look at the documentation to find additional information.

Latest Version

License

image

image

Features

  • Query Overpass API
  • Parse JSON and XML response data
  • Additional helper functions

Install

Requirements:

Supported Python versions:

  • Python >= 3.7
  • PyPy3

Install:

$ pip install overpy

Examples

Additional examples can be found in the documentation and in the examples directory.

import overpy

api = overpy.Overpass()

# fetch all ways and nodes
result = api.query("""
    way(50.746,7.154,50.748,7.157) ["highway"];
    (._;>;);
    out body;
    """)

for way in result.ways:
    print("Name: %s" % way.tags.get("name", "n/a"))
    print("  Highway: %s" % way.tags.get("highway", "n/a"))
    print("  Nodes:")
    for node in way.nodes:
        print("    Lat: %f, Lon: %f" % (node.lat, node.lon))

Helper

Helper methods are available to provide easy access to often used requests.

import overpy.helper

# 3600062594 is the OSM id of Chemnitz and is the bounding box for the request
street = overpy.helper.get_street(
    "Straße der Nationen",
    "3600062594"
)

# this finds an intersection between Straße der Nationen and Carolastraße in Chemnitz
intersection = overpy.helper.get_intersection(
    "Straße der Nationen",
    "Carolastraße",
    "3600062594"
)

License

Published under the MIT (see LICENSE for more information)

python-overpy's People

Contributors

eumiro avatar ezheidtmann avatar firefly-cpp avatar gloix avatar gregrs-uk avatar karthikb351 avatar matthew-law avatar morrisjobke avatar movermeyer avatar namarrgon avatar phibos avatar pre-commit-ci[bot] avatar talespaiva avatar wx0wk 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  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-overpy's Issues

Timeout returns empty result instead of error

Issue type
  • Bug Report
OverPy version
0.4
OS
  • OSX 10.12.3

Python version

  • Python 3.5
Summary

When setting a short timeout (1-30s), such that the timeout is reached, an empty result is returned instead of a timeout error. Looking into the query() function code determines that there is a <remark> describing the timeout in the xml result, and that the error code '200' is raised, but the parse_xml() function is being used to resolve it to an empty result. A similar issue is discussed in the Overpass API #94.

Steps to reproduce

Run a short timeout query like

[out:xml][timeout:10];
area["name"="France"]->.searchArea;
(
node["amenity"="embassy"](area.searchArea);
way["amenity"="embassy"](area.searchArea);
relation["amenity"="embassy"](area.searchArea);
);
out center;

via
result = overpy.Overpass().query(query))

Expected results

raise overpy.exception.OverpassGatewayTimeout or some relevant error

Actual results

returns a result for which

print(result.get_nodes())
print(result.get_ways())
print(result.get_relations())

returns an empty list [] for each.

XML result looked like:

b'<?xml version="1.0" encoding="UTF-8"?>\n<osm version="0.6" generator="Overpass API">\n<note>The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.</note>\n<meta osm_base="2017-03-17T15:40:02Z" areas="2017-03-17T06:44:02Z"/>\n\n<remark> runtime error: Query timed out in "query" at line 1 after 2 seconds. </remark>\n\n</osm>\n'

f.code: 200

Export xml

Is there a way to write the Result object to an XML file as it might come from geofabrik? Eventually I'd like to write code that would process the downloaded data directly, but right now I'm just trying to pull custom query that I can feed into something else.

please include LICENSE, CHANGELOG.rst, docs, examples in the pypi tarball

Hello!
I'm preparing overpy to be included in Debian, but i noticed that the tarball on pypi misses the LICENSE file: that is required to formally be included in Debian (and from a legal point of view to specify explicitly the license you are applying to your module) - could you include it in the next upload?

it would also be great if you can add a other files like CHANGELOG.rst, docs, examples which would allow me to include them in the packages distributed with Debian and improve the user experience.

thanks for considering,
Sandro

unable to install on Fedora 24, with pip, Python3

pip3 install fails:

$ sudo pip3 install overpy                                                                                     
Collecting overpy                                                                                                                   
  Using cached overpy-0.3.1.tar.gz                                                                                                  
    Complete output from command python setup.py egg_info:                                                                          
    Traceback (most recent call last):                                                                                              
      File "<string>", line 1, in <module>                                                                                          
      File "/tmp/pip-build-e9c50bzk/overpy/setup.py", line 12, in <module>                                                          
        long_description = f.read()                                                                                                 
      File "/usr/lib64/python3.5/encodings/ascii.py", line 26, in decode                                                            
        return codecs.ascii_decode(input, self.errors)[0]                                                                           
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1883: ordinal not in range(128)                            

    ----------------------------------------                                                                                        
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-e9c50bzk/overpy                                       
You are using pip version 8.0.2, however version 8.1.2 is available.                                                                
You should consider upgrading via the 'pip install --upgrade pip' command.       

but it works for python2

$ sudo pip install overpy                                                                                      
Collecting overpy                                                                                                                   
  Using cached overpy-0.3.1.tar.gz                                                                                                  
Installing collected packages: overpy                                                                                               
  Running setup.py install for overpy ... done                                                                                      
Successfully installed overpy-0.3.1                                                                                                 
You are using pip version 8.0.2, however version 8.1.2 is available.                                                                
You should consider upgrading via the 'pip install --upgrade pip' command.                                                          

Any ideas?

Quering data from a localhost or patrticular osm file

Hi,

I am using OpenStreetMap (josm) to create a map with nodes and ways .. etc. and I am uploading my data to a localhost "http://localhost:3000/api". If I wanna query data using overpy api can I use this host in order to query data from ? and in case not !! is there any other way to query data from particular osm file using overpy?
Thanks,

Jad

Support for Overpass API /api/status

Issue type
  • Feature Idea
OverPy version
0.4
OS
  • Windows 7

Python version

  • Python 3.6
Summary

It is possible to encounter several HTTP errors when using the Overpass API, relating to the status of a user's queries. For experienced users, helpful information is available regarding these errors from /api/status. The ability to catch and access the information from /api/status would be beneficial to users trying to make a significant number of queries while respecting the rules of the Overpass servers.

Expected results

Something like the following would be expected:

query_string = ('way["highway"~"."](around:20,{},{},);out;').format(lat, lon)
    while True:
        try:
            result = api.query(query_string)
            break
        except (overpy.exception.AnyOverpassError):
            print(result.api_status)

Which gives some output:

'Connected as: 2557965506
Current time: 2017-05-01T16:17:38Z
Rate limit: 2
2 slots available now.
Currently running queries (pid, space limit, time limit, start time):'

As found on the /api/status site.

This would allow users to see information like rate limit and available slots, and adjust the code to respect the status of the server.

Get osm_timestamp

Hi,

is that possible to get osm_timestamp ? i dont' find command in documentation

thanks

Unknown content type: text/html; charset="utf-8"

I tried to get the very fist basic example going but I always get the error: Unknown content type: text/html; charset="utf-8"

My code:
api = overpy.Overpass()
result = api.query("node(50.745,7.17,50.75,7.18);out;")

Any suggestions on how to solve this issue?
Thx

Release 0.3.2 or 0.4.0-beta with latest bugfixes

I am using this awesome library in one of my projects. Thanks a lot for it! :)

The last release was more than one and a half years ago. There have been many important fixes since then, but they haven't been released. Could you please make a release that includes some of the fixes?

I am personally interested in ac7df97 to be included in a bugfix release.

Documentation custom url parameter

Maybe add some documentation on the custom url parameter?
Didn't find it in documentation, but only in #73

E.g. something like this

_
Per default overpy uses the public main api (http://overpass-api.de/api/interpreter), but you may also use a custom api server by providing the url parameter.

.. code-block:: python

import overpy

overpy.Overpass(url='http://localhost/api/interpreter')

_

Updating pip package

Hello, thank you for your work!
Can you update pip package please? Currently it is lacking max_retry_count parameter, contrary to the docs...

Unable to use area filter in Overpass QL

Based on my understanding of QL from this document, we should be able to use node, way, rel and area as filters. However, when i use area it returns an error. Apologies if I'm misunderstanding QL, still a noob.

node, rel, way work ok

r = api.query("""node[name="Foo"]; out meta;""")
r = api.query("""way[name="Foo"]; out meta;""")
r = api.query("""rel[name="Foo"]; out meta;""")

area does not

r = api.query("""area[name="Foo"]; out meta;""")

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/overpy-0.3.1-py2.7.egg/overpy/__init__.py", line 98, in query
    return self.parse_xml(response)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/overpy-0.3.1-py2.7.egg/overpy/__init__.py", line 160, in parse_xml
    return Result.from_xml(data, api=self, parser=parser)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/overpy-0.3.1-py2.7.egg/overpy/__init__.py", line 306, in from_xml
    parser.parse(source)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/sax/expatreader.py", line 110, in parse
    xmlreader.IncrementalParser.parse(self, source)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse
    self.feed(buffer)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/sax/expatreader.py", line 213, in feed
    self._parser.Parse(data, isFinal)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/sax/expatreader.py", line 317, in start_element
    self._cont_handler.startElement(name, AttributesImpl(attrs))
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/overpy-0.3.1-py2.7.egg/overpy/__init__.py", line 1018, in startElement
    raise KeyError("Unknown element start '%s'" % name)
KeyError: u"Unknown element start 'area'"`

Export results

Add an API to export the result data. This might help to speed up the development of proof of concepts.

Road geometry extraction

Hi guys,

I am working on simulations and got stuck on while extracting data from OSM using overpy.Overpass API, I had a GPS data in the form of GPX format which includes the track, lat, long, alt, speed, time.

  • I am able to download the data from overpass API but the data is too large, I need the exact road node on which the car travel.

  • I also plotted the track on OSM and all the nodes are on road but I need the road nodes.

Please have a look towards the code, GPX file and help me in this situation.

CODE:

api = overpy.Overpass()

 #(minimum lat, minimum long, maximum lat, maximum long)
 result = api.query("""
 way(40.725968457, -73.973420095, 40.730816424, -73.971729884)[highway~"."][highway!~"path|track|cycleway|footway"];
(._;>;);
out geom;
  """)

Gpx data:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<gpx version="1.0" creator="GPS Visualizer https://www.gpsvisualizer.com/" xmlns="http://www.topografix.com/GPX/1/0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<trk>
  <name>vid_21_final</name>
  <trkseg>
    <trkpt lat="40.730816424" lon="-73.973420095">
      <time>2017-10-03T11:13:17Z</time>
      <speed>19.71</speed>
    </trkpt>
    <trkpt lat="40.730676991" lon="-73.973266622">
      <time>2017-10-03T11:13:18Z</time>
      <speed>20.27</speed>
    </trkpt>
    <trkpt lat="40.730536343" lon="-73.973101918">
      <time>2017-10-03T11:13:19Z</time>
      <speed>20.84</speed>
    </trkpt>
    <trkpt lat="40.730397748" lon="-73.972929334">
      <time>2017-10-03T11:13:20Z</time>
      <speed>21.07</speed>
    </trkpt>
    <trkpt lat="40.730262757" lon="-73.972753482">
      <time>2017-10-03T11:13:21Z</time>
      <speed>21.14</speed>
    </trkpt>
    <trkpt lat="40.730120475" lon="-73.97258048">
      <time>2017-10-03T11:13:22Z</time>
      <speed>21.09</speed>
    </trkpt>
    <trkpt lat="40.729975845" lon="-73.972413261">
      <time>2017-10-03T11:13:23Z</time>
      <speed>21.06</speed>
    </trkpt>
    <trkpt lat="40.729814787" lon="-73.972260458">
      <time>2017-10-03T11:13:24Z</time>
      <speed>21.20</speed>
    </trkpt>
    <trkpt lat="40.729651004" lon="-73.972128276">
      <time>2017-10-03T11:13:25Z</time>
      <speed>21.13</speed>
    </trkpt>
    <trkpt lat="40.729483492" lon="-73.972018305">
      <time>2017-10-03T11:13:26Z</time>
      <speed>20.91</speed>
    </trkpt>
    <trkpt lat="40.729301688" lon="-73.971919986">
      <time>2017-10-03T11:13:27Z</time>
      <speed>20.89</speed>
    </trkpt>
    <trkpt lat="40.729118669" lon="-73.971847482">
      <time>2017-10-03T11:13:28Z</time>
      <speed>20.90</speed>
    </trkpt>
    <trkpt lat="40.728934435" lon="-73.971789898">
      <time>2017-10-03T11:13:29Z</time>
      <speed>20.99</speed>
    </trkpt>
    <trkpt lat="40.728745549" lon="-73.971752347">
      <time>2017-10-03T11:13:30Z</time>
      <speed>20.94</speed>
    </trkpt>
    <trkpt lat="40.728561441" lon="-73.971729884">
      <time>2017-10-03T11:13:31Z</time>
      <speed>20.52</speed>
    </trkpt>
    <trkpt lat="40.72838387" lon="-73.971730722">
      <time>2017-10-03T11:13:32Z</time>
      <speed>19.55</speed>
    </trkpt>
    <trkpt lat="40.728206341" lon="-73.971751006">
      <time>2017-10-03T11:13:33Z</time>
      <speed>19.95</speed>
    </trkpt>
    <trkpt lat="40.728025376" lon="-73.97177632">
      <time>2017-10-03T11:13:34Z</time>
      <speed>20.15</speed>
    </trkpt>
    <trkpt lat="40.727841016" lon="-73.971800124">
      <time>2017-10-03T11:13:35Z</time>
      <speed>20.52</speed>
    </trkpt>
    <trkpt lat="40.727653638" lon="-73.971818481">
      <time>2017-10-03T11:13:36Z</time>
      <speed>19.94</speed>
    </trkpt>
    <trkpt lat="40.727491616" lon="-73.971830048">
      <time>2017-10-03T11:13:37Z</time>
      <speed>17.90</speed>
    </trkpt>
    <trkpt lat="40.727331396" lon="-73.971863911">
      <time>2017-10-03T11:13:38Z</time>
      <speed>17.08</speed>
    </trkpt>
    <trkpt lat="40.727223815" lon="-73.97189551">
      <time>2017-10-03T11:13:39Z</time>
      <speed>12.15</speed>
    </trkpt>
    <trkpt lat="40.727135134" lon="-73.971920069">
      <time>2017-10-03T11:13:40Z</time>
      <speed>9.68</speed>
    </trkpt>
    <trkpt lat="40.727062379" lon="-73.971932223">
      <time>2017-10-03T11:13:41Z</time>
      <speed>7.87</speed>
    </trkpt>
    <trkpt lat="40.727004963" lon="-73.971937168">
      <time>2017-10-03T11:13:42Z</time>
      <speed>6.94</speed>
    </trkpt>
    <trkpt lat="40.726956851" lon="-73.971947813">
      <time>2017-10-03T11:13:43Z</time>
      <speed>5.83</speed>
    </trkpt>
    <trkpt lat="40.726913097" lon="-73.971958291">
      <time>2017-10-03T11:13:44Z</time>
      <speed>5.89</speed>
    </trkpt>
    <trkpt lat="40.726867919" lon="-73.971968601">
      <time>2017-10-03T11:13:45Z</time>
      <speed>5.84</speed>
    </trkpt>
    <trkpt lat="40.72681637" lon="-73.971978324">
      <time>2017-10-03T11:13:46Z</time>
      <speed>6.32</speed>
    </trkpt>
    <trkpt lat="40.72675711" lon="-73.971979665">
      <time>2017-10-03T11:13:47Z</time>
      <speed>6.98</speed>
    </trkpt>
    <trkpt lat="40.72669303" lon="-73.971989639">
      <time>2017-10-03T11:13:48Z</time>
      <speed>7.24</speed>
    </trkpt>
    <trkpt lat="40.726620066" lon="-73.972006822">
      <time>2017-10-03T11:13:49Z</time>
      <speed>8.17</speed>
    </trkpt>
    <trkpt lat="40.726544755" lon="-73.972028615">
      <time>2017-10-03T11:13:50Z</time>
      <speed>9.49</speed>
    </trkpt>
    <trkpt lat="40.726457331" lon="-73.972061304">
      <time>2017-10-03T11:13:51Z</time>
      <speed>10.21</speed>
    </trkpt>
    <trkpt lat="40.726367142" lon="-73.972098017">
      <time>2017-10-03T11:13:52Z</time>
      <speed>11.09</speed>
    </trkpt>
    <trkpt lat="40.726266224" lon="-73.972132132">
      <time>2017-10-03T11:13:53Z</time>
      <speed>11.50</speed>
    </trkpt>
    <trkpt lat="40.726170712" lon="-73.972169766">
      <time>2017-10-03T11:13:54Z</time>
      <speed>12.13</speed>
    </trkpt>
    <trkpt lat="40.726063591" lon="-73.972223243">
      <time>2017-10-03T11:13:55Z</time>
      <speed>12.71</speed>
    </trkpt>
    <trkpt lat="40.725968457" lon="-73.972284934">
      <time>2017-10-03T11:13:56Z</time>
      <speed>12.75</speed>
    </trkpt>
  </trkseg>
</trk>
</gpx>

Just need the road geometry of the road highlighted with pink line.

image

Unable to print id of relations

I am trying to go through a large set of relations, specifically all those in California.

 result = api.query('relation'
                    '["boundary"="administrative"]'
                    '(32.0,-125.0,42.0,-114.0);'
                    'out body;')

My python is not very sophisticated. I am a almost-intermediate in the language. I have the list of relations and am trying to print this out:

 print '%s\t%s\t%s\t%s\t%s' % (relation.tags.get('name','').encode('utf8'),
                                    relation.tags.get('admin_level','').encode('utf8'),
                                    relation.tags.get('place','').encode('utf8'),
                                    relation.tags.get('boundary','').encode('utf8'),
                                    relation.tags.get('type','').encode('utf8'),
                                    relation.id)

Everything but the id works great. I have tried writing out the id with "%d" and that does not work, but with "%s", it says it is a number. Looking at your recent edit, it might be None. How can one write this out?

Less memory-consuming xml parsing

Currently the whole xml-result is first parsed into a xml.etree.ElementTree and than processed to create overpy structures. While this is perfectly fine for small amounts of data, larger files or requests consume a lot of memory that is not freed after the overpy result is constructed.

A SAX-style parser could reduce the memory footprint and both overpy's architecture and osm_xml's structure would easily support such a parser.

Result.from_xml data argument has a wrong type doc

Passing Element as a data argument to Result.from_xml() as docstring suggests raises Exception.

>>> overpy.Result.from_xml(xml.etree.ElementTree.fromstring("<osm />"))
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/w/osm-borders/lib/python3.5/site-packages/overpy/__init__.py", line 310, in from_xml
    source = StringIO(data)
TypeError: initial_value must be str or None, not xml.etree.ElementTree.Element

It looks like it expects string right now:

>>> overpy.Result.from_xml("<osm />")
<overpy.Result object at 0x7faf632b2eb8>

My python version is:
$ python --version
Python 3.5.2

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.10
DISTRIB_CODENAME=yakkety
DISTRIB_DESCRIPTION="Ubuntu 16.10"

(My guess that Ubuntu's Python 3.5.2 is far more similar to Python 3.6 than to 3.5)

Publish new version (to pypi) ?

Actual version of pypi on git supports (among other things) custom overpass servers ('url' param to constructor).

Would it be possible to publish a new version with all the new fixes ?

Thanks,
Cheers

build is failing according to the readme badge

Issue type
  • Bug Report
OverPy version
8aa4bafc8e9b336d4f8da7c993ca545494a0e5a9
OS
  • Ubuntu 20.04

Python version

  • Python 3.8.2
Summary

build is failing according to the readme badge

Steps to reproduce

See at readme

Expected results

build is not failing according to the readme badge

Actual results

build is failing according to the readme badge

Support "center" out

The "center" feature for the out action can be very handy to easily get specific elements as nodes regardless if they are nodes or areas.
I'd love to see this feature in overpy :)

#27

Query without parsing

In my opinion, there should have a method to query pure json or Xml without parsing it. Because it is not possible, we need to transform the object into json, which is not easy at all...

Thank you!

querying data from local osm file

Hi, I am trying to query the data of a specific osm file from my hard disk. Is it possible to do so directly using overpy without uploading the osm file it to a localhost? Thank you in advance.

List of street name for a city ?

Hey, i try to list all street's name for a city.

For Bordeaux i try this :

result = api.query("""
    area[name="Bordeaux"];way(area)[highway][name];out;
    """)
len(result.ways) #17332

This should be more more or less 2K streets.

Did i do something wrong ? :)

Update/Write to .osm file

Hi,

I am using overpy succesfully to make queries etc. I wonder that is there a way to update(write) to .osm file or maybe query for this to local map(.bz2 or .osm).
I've tried this manually using xml parser after I've extracted the <my_country>.osm.bz2 which is around 9.1Gb. So, I could not manage to update via parser because of the size I guess. Is there a way from overpy side or query side or maybe another tool for this purpose?
Thanks.
BR.

OverpassTooManyRequests: Too many requests

OverPy version 0.4
OS Ubuntu 14.04

Python version Python 2.7.6

I run a script which perform some query starting from data that I read from a list file.
After a few request I obtain the OverpassTooManyRequests: Too many requests error.

I partially solved this problem using a sleep time which I can increase... nevertheless sometime the sleep time is not enough and my script crash.

How can avoid the crash and manage the well-known 429 error of the overpass API?

Probably I can use the exception (exception overpy.exception.OverpassTooManyRequests) ? But I do not understand how?

change BaseException to Exception?

Issue type
  • Bug Report
OverPy version
0.4
OS
  • Ubuntu 16.04

Python version

  • Python 3.5
Summary

When using celery task with overpy, a try-catch Exception block will not catch OverPyException, which is inherited from BaseException, and it will make Celery main process exit.

It's recommended to use Exceptions instead of BaseException in Python's doc

Steps to reproduce
from celery import shared_task
import logging
import overpy

logger = logging.getLogger()

@shared_task
def task(coords):
    api = overpy.Overpass(url='some_inavlid_url')
    try:
        result = api.query('way(around:40,{},{})["maxspeed"];out;'.format(coords[1], coords[0]))
    except Exception as e:
        logger.exception(e)
        # other exception handling code
    else:
        pass # other processing code
    return result
Expected results

Whenever the query fail (time out or whatever), it raise an Exception and been catch by except so I can deal with it and end this task normally.

Actual results

Raise BaseException, cause Celery MainProcess exit, log showing
[ERROR:MainProcess] Task handler raised error: WorkerLostError('Worker exited prematurely: exitcode 0.',)

Using lists is too slow

Hello,

Thanks for the package.
I used it and found that it was really slow to use the property nodes of a way element.
This is basically due to the use of a list for result.nodes.

The time complexity of way.nodes is: O(number_of_nodeId * number_of_nodes).
It can be done in: O(number_of_nodeId) by using a dictionary.

It can also be generalized for relations and ways.

Issue with tests

Issue type
  • Bug Report
OverPy version
0.3.1 and pre 0.4.0
OS
  • all

Python version

  • all
Summary

From time to time the test is unable to lunch the internal web server to test the requests. This results in an error message.

E               urllib.error.URLError: <urlopen error [Errno 32] Broken pipe>
Steps to reproduce

Run a test

Expected results

No error

Actual results

Write to file

Is it possible to dump the output to a GeoJSON file?

Can't pickle overpy.Result

Issue type
  • Bug Report
OverPy version
0.4
OS
  • Windows 7 x64 HP

Python version

  • Python 3.5 x64
Summary

Neither pickle nor _pickle Python modules can't dump query result.

Steps to reproduce
import overpy
import pickle

op = overpy.Overpass()
sample = op.query("""
    way(50.746,7.154,50.748,7.157) ["highway"];
    (._;>;);
    out body;
    """)

with open('sample.pcl', 'wb') as pcl:
    pickle.dump(sample, pcl)
Expected results

pcl-file full of usefull data =)

Actual results

Empty plc-file and exception:

     11 with open('sample.pcl', 'wb') as pcl:
---> 12     pickle.dump(sample, pcl)

AttributeError: Can't pickle local object 'Element.__init__.<locals>.<lambda>'

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.