-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7380a19
commit dc6d515
Showing
3 changed files
with
26 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
# 2007-11-04 OJW Modified from pyroute.py | ||
# 2007-11-05 OJW Multiple forms of transport | ||
# 2017-09-24 MK Code cleanup | ||
# 2017-09-30 MK LocalFile - Only router | ||
#---------------------------------------------------------------------------- | ||
import os | ||
import re | ||
|
@@ -44,22 +45,26 @@ | |
__copyright__ = "Copyright 2007, Oliver White; Modifications: Copyright 2017, Mikolaj Kuranowski" | ||
__credits__ = ["Oliver White", "Mikolaj Kuranowski"] | ||
__license__ = "GPL v3" | ||
__version__ = "0.2" | ||
__version__ = "0.3" | ||
__maintainer__ = "Mikolaj Kuranowski" | ||
__email__ = "[email protected]" | ||
|
||
|
||
class Datastore(object): | ||
"""Parse an OSM file looking for routing information""" | ||
def __init__(self, transport): | ||
def __init__(self, transport, localfile=""): | ||
"""Initialise an OSM-file parser""" | ||
self.routing = {} | ||
self.rnodes = {} | ||
self.transport = transport | ||
self.localFile = localfile | ||
self.tiles = {} | ||
self.weights = weights.RoutingWeights() | ||
self.api = osmapi.OsmApi(api="api.openstreetmap.org") | ||
|
||
if self.localFile: | ||
self.loadOsm(self.localFile) | ||
|
||
def getArea(self, lat, lon): | ||
"""Download data in the vicinity of a lat/long. | ||
Return filename to existing or newly downloaded .osm file.""" | ||
|
@@ -68,9 +73,9 @@ def getArea(self, lat, lon): | |
(x,y) = tilenames.tileXY(lat, lon, z) | ||
|
||
tileID = '%d,%d'%(x,y) | ||
if(self.tiles.get(tileID,False)): | ||
#print "Already got %s" % tileID | ||
if self.tiles.get(tileID,False) or self.localFile: | ||
return | ||
|
||
self.tiles[tileID] = True | ||
|
||
filename = tiledata.GetOsmTileData(z,x,y) | ||
|
@@ -277,8 +282,8 @@ def report(self): | |
print("Loaded %d %s routes" % (len(list(self.routing.keys())), self.transport)) | ||
|
||
class Router(object): | ||
def __init__(self, transport): | ||
self.data = Datastore(transport) | ||
def __init__(self, transport, localfile=""): | ||
self.data = Datastore(transport, localfile) | ||
|
||
def distance(self,n1,n2): | ||
"""Calculate distance between two nodes""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,14 +7,14 @@ | |
name = "pyroutelib3", | ||
packages = ["pyroutelib3"], | ||
license = "GPL v3", | ||
version = "0.2", | ||
version = "0.3", | ||
description = "Library for simple routing on OSM data", | ||
long_description = readme, | ||
author = "Oliver White", | ||
maintainer = "Mikolaj Kuranowski", | ||
maintainer_email = "[email protected]", | ||
url = "https://github.com/MKuranowski/pyroutelib3", | ||
download_url = "https://github.com/MKuranowski/pyroutelib3/archive/0.1.tar.gz", | ||
download_url = "https://github.com/MKuranowski/pyroutelib3/archive/0.3.tar.gz", | ||
keywords = "osm routing pyroutelib", | ||
classifiers = [], | ||
install_requires = ["osmapi"] | ||
|