Giter VIP home page Giter VIP logo

pyo5m's Introduction

pyo5m

o5m openstreetmap format encoder/decoder in python v2 and v3. Includes both stream decoding and static interpretations of data. It also includes a standard osm xml encoder/decoder.

To install in the python distribution:

python setup.py build

python setup.py install

To install locally:

python setup.py build_ext --inplace

Example usage:

from pyo5m import OsmData

if __name__=="__main__":

	fi = open("o5mtest.o5m", "rb")
	osmData = OsmData.OsmData()
	osmData.LoadFromO5m(fi)
	print ("nodes", len(osmData.nodes))
	print ("ways", len(osmData.ways))
	print ("relations", len(osmData.relations))

	fi2 = open("o5mtest2.o5m", "wb")
	osmData.SaveToO5m(fi2)
	fi2.close()

	print ("Read data back")
	fi3 = open("o5mtest2.o5m", "rb")
	osmData2 = OsmData.OsmData()
	osmData2.LoadFromO5m(fi3)
	print ("nodes", len(osmData2.nodes))
	print ("ways", len(osmData2.ways))
	print ("relations", len(osmData2.relations))

pyo5m's People

Contributors

timsc avatar

Watchers

 avatar  avatar

pyo5m's Issues

Need to optimise

st.strip_dirs().sort_stats(1).print_stats(50)
Mon Dec 21 23:14:30 2015 prof

     157457260 function calls (157457241 primitive calls) in 690.237 seconds

Ordered by: internal time
List reduced from 291 to 50 due to restriction <50>

ncalls tottime percall cumtime percall filename:lineno(function)
13102559 129.700 0.000 216.661 0.000 StringIO.py:208(write)
5511803 82.185 0.000 345.303 0.000 o5m.py:36(EncodeNumber)
2250919 50.397 0.000 109.962 0.000 gzip.py:220(write)
30864919/30864917 48.049 0.000 48.049 0.000 {len}
6362680 44.030 0.000 65.677 0.000 StringIO.py:54(init)
6362680 41.065 0.000 62.898 0.000 StringIO.py:258(getvalue)
21716243 40.473 0.000 40.473 0.000 {isinstance}
19465239 31.183 0.000 31.183 0.000 StringIO.py:38(_complain_ifclosed)
649731 31.136 0.000 468.172 0.001 o5m.py:454(StoreNode)
13896536 23.442 0.000 23.442 0.000 {method 'append' of 'list' objects}
2 21.169 10.584 39.342 19.671 mappacktoosm.py:18(ConvertNodeData)
8194889 16.374 0.000 16.374 0.000 {_struct.pack}
2250919 15.313 0.000 15.313 0.000 {built-in method compress}
263598 14.413 0.000 14.413 0.000 {method 'index' of 'list' objects}
6362686 11.510 0.000 11.510 0.000 {method 'join' of 'str' objects}
750304 10.120 0.000 113.072 0.000 o5m.py:402(EncodeMetaData)
99059 9.681 0.000 156.419 0.002 o5m.py:484(StoreWay)
2250919 9.316 0.000 13.454 0.000 gzip.py:150(_check_closed)
3751520 6.905 0.000 6.905 0.000 mappacktoosm.py:13(GetValOrNone)
2250929 6.516 0.000 6.516 0.000 {method 'write' of 'file' objects}
2250920 5.209 0.000 5.209 0.000 {zlib.crc32}
1 4.386 4.386 15.006 15.006 mappacktoosm.py:65(ConvertWayData)
2250919 4.137 0.000 4.137 0.000 gzip.py:360(closed)
242788 3.895 0.000 39.165 0.000 o5m.py:432(WriteStringPair)
750304 3.708 0.000 3.708 0.000 {msgpack._unpacker.unpackb}
506388 3.462 0.000 3.462 0.000 {_codecs.utf_8_decode}
1 3.446 3.446 634.091 634.091 OsmData.py:26(SaveToO5m)
1299462 2.926 0.000 2.926 0.000 {round}
1500624 2.842 0.000 2.842 0.000 {_struct.unpack}
649731 2.696 0.000 3.761 0.000 OsmData.py:66(StoreNode)
506388 2.597 0.000 8.357 0.000 {method 'decode' of 'str' objects}
506388 2.299 0.000 5.761 0.000 utf_8.py:15(decode)
506388 1.504 0.000 1.504 0.000 {method 'encode' of 'unicode' objects}
28 1.112 0.040 1.112 0.040 {method 'read' of 'file' objects}
8 0.759 0.095 0.759 0.095 {zlib.decompress}
1 0.647 0.647 690.241 690.241 mappacktoosm.py:1()
99059 0.507 0.000 0.705 0.000 OsmData.py:69(StoreWay)
1514 0.471 0.000 6.020 0.004 o5m.py:517(StoreRelation)
1 0.221 0.221 0.221 0.221 {built-in method flush}
1 0.215 0.215 0.875 0.875 mappacktoosm.py:110(ConvertRelationData)
22799 0.123 0.000 0.192 0.000 o5m.py:447(AddToRefTable)
1 0.031 0.031 0.031 0.031 {method 'encode' of 'str' objects}
1514 0.009 0.000 0.012 0.000 OsmData.py:72(StoreRelation)
1 0.006 0.006 0.007 0.007 socket.py:45()
1 0.004 0.004 0.016 0.016 urllib.py:23()
3 0.003 0.001 0.009 0.003 collections.py:288(namedtuple)
12 0.003 0.000 1.874 0.156 decode.py:39(read)
1 0.003 0.003 689.317 689.317 mappacktoosm.py:159(MapPackToO5m)
1 0.002 0.002 0.008 0.008 o5m.py:1()
1 0.002 0.002 0.005 0.005 six.py:1()

<pstats.Stats instance at 0xb748902c>

st.strip_dirs().sort_stats(2).print_stats(50)
Mon Dec 21 23:14:30 2015 prof

     157457260 function calls (157457241 primitive calls) in 690.237 seconds

Ordered by: cumulative time
List reduced from 291 to 50 due to restriction <50>

ncalls tottime percall cumtime percall filename:lineno(function)
1 0.647 0.647 690.241 690.241 mappacktoosm.py:1()
1 0.003 0.003 689.317 689.317 mappacktoosm.py:159(MapPackToO5m)
1 3.446 3.446 634.091 634.091 OsmData.py:26(SaveToO5m)
649731 31.136 0.000 468.172 0.001 o5m.py:454(StoreNode)
5511803 82.185 0.000 345.303 0.000 o5m.py:36(EncodeNumber)
13102559 129.700 0.000 216.661 0.000 StringIO.py:208(write)
99059 9.681 0.000 156.419 0.002 o5m.py:484(StoreWay)
750304 10.120 0.000 113.072 0.000 o5m.py:402(EncodeMetaData)
2250919 50.397 0.000 109.962 0.000 gzip.py:220(write)
6362680 44.030 0.000 65.677 0.000 StringIO.py:54(init)
6362680 41.065 0.000 62.898 0.000 StringIO.py:258(getvalue)
30864919/30864917 48.049 0.000 48.049 0.000 {len}
21716243 40.473 0.000 40.473 0.000 {isinstance}
2 21.169 10.584 39.342 19.671 mappacktoosm.py:18(ConvertNodeData)
242788 3.895 0.000 39.165 0.000 o5m.py:432(WriteStringPair)
19465239 31.183 0.000 31.183 0.000 StringIO.py:38(_complain_ifclosed)
13896536 23.442 0.000 23.442 0.000 {method 'append' of 'list' objects}
8194889 16.374 0.000 16.374 0.000 {_struct.pack}
2250919 15.313 0.000 15.313 0.000 {built-in method compress}
1 4.386 4.386 15.006 15.006 mappacktoosm.py:65(ConvertWayData)
263598 14.413 0.000 14.413 0.000 {method 'index' of 'list' objects}
2250919 9.316 0.000 13.454 0.000 gzip.py:150(_check_closed)
6362686 11.510 0.000 11.510 0.000 {method 'join' of 'str' objects}
506388 2.597 0.000 8.357 0.000 {method 'decode' of 'str' objects}
3751520 6.905 0.000 6.905 0.000 mappacktoosm.py:13(GetValOrNone)
2250929 6.516 0.000 6.516 0.000 {method 'write' of 'file' objects}
1514 0.471 0.000 6.020 0.004 o5m.py:517(StoreRelation)
506388 2.299 0.000 5.761 0.000 utf_8.py:15(decode)
2250920 5.209 0.000 5.209 0.000 {zlib.crc32}
2250919 4.137 0.000 4.137 0.000 gzip.py:360(closed)
649731 2.696 0.000 3.761 0.000 OsmData.py:66(StoreNode)
750304 3.708 0.000 3.708 0.000 {msgpack._unpacker.unpackb}
506388 3.462 0.000 3.462 0.000 {_codecs.utf_8_decode}
1299462 2.926 0.000 2.926 0.000 {round}
1500624 2.842 0.000 2.842 0.000 {_struct.unpack}
12 0.003 0.000 1.874 0.156 decode.py:39(read)
506388 1.504 0.000 1.504 0.000 {method 'encode' of 'unicode' objects}
28 1.112 0.040 1.112 0.040 {method 'read' of 'file' objects}
1 0.215 0.215 0.875 0.875 mappacktoosm.py:110(ConvertRelationData)
8 0.759 0.095 0.759 0.095 {zlib.decompress}
99059 0.507 0.000 0.705 0.000 OsmData.py:69(StoreWay)
1 0.002 0.002 0.224 0.224 gzip.py:364(close)
1 0.221 0.221 0.221 0.221 {built-in method flush}
22799 0.123 0.000 0.192 0.000 o5m.py:447(AddToRefTable)
1 0.002 0.002 0.033 0.033 saxutils.py:4()
1 0.000 0.000 0.031 0.031 o5m.py:377(StoreIsDiff)
1 0.031 0.031 0.031 0.031 {method 'encode' of 'str' objects}
1 0.004 0.004 0.016 0.016 urllib.py:23()
1 0.001 0.001 0.013 0.013 urlparse.py:29()
1514 0.009 0.000 0.012 0.000 OsmData.py:72(StoreRelation)

<pstats.Stats instance at 0xb748902c>

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.