packages feed

streaming-osm 1.0.1 → 1.0.2

raw patch · 7 files changed

+71/−16 lines, 7 filessetup-changedPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

+ CHANGELOG.md view
@@ -0,0 +1,19 @@+# streaming-osm++## 1.0.2 (2020-07-16)++#### Fixed++- Member IDs for Relations will now parse properly. [#3](https://github.com/fosskers/streaming-osm/issues/3)++## 1.0.1++- Small tweaks and modernizations.++## 1.0.0.1++- Massaging bounds and future-proofing.++## 1.0.0++- Initial release.
− ChangeLog.md
@@ -1,11 +0,0 @@-## 1.0.1--- Small tweaks and modernizations.--## 1.0.0.1--- Massaging bounds and future-proofing.--## 1.0.0--- Initial release.
+ README.md view
@@ -0,0 +1,19 @@+# `streaming-osm`++This library provides the ability to read and process+[OpenStreetMap](http://www.openstreetmap.org/) data via the+[streaming](https://hackage.haskell.org/package/streaming) ecosystem. Since+*streaming* allows for very little RAM overhead despite file size, we can+process very large OSM PBF files just by providing a file path:++```haskell+import           Streaming+import           Streaming.Osm+import qualified Streaming.Prelude as S++-- | Count all nodes.+count :: IO ()+count = do+  len <- runResourceT . S.length_ . nodes . blocks $ blobs "yourfile.osm.pbf"+  print len+```
− Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
lib/Streaming/Osm/Internal/Parser.hs view
@@ -116,7 +116,7 @@   vs <- packed <$> (A.word8 0x1a *> varint >>= A.take) <|> pure []                -- vals   oi <- optional (A.word8 0x22 *> varint *> info i st)                            -- info   rs <- packed <$> (A.word8 0x42 *> varint >>= A.take) <|> pure []                -- roles_sid-  ms <- map unzig . packed <$> (A.word8 0x4a *> varint >>= A.take) <|> pure []    -- memids+  ms <- ints <$> (A.word8 0x4a *> varint >>= A.take) <|> pure []                  -- memids   ts <- map memtype . packed <$> (A.word8 0x52 *> varint >>= A.take) <|> pure []  -- types   let tags = M.fromList $ zip (map (V.unsafeIndex st) ks) (map (V.unsafeIndex st) vs)       mems = zipWith3 Member ms ts $ map (V.unsafeIndex st) rs
streaming-osm.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.2 name:               streaming-osm-version:            1.0.1+version:            1.0.2 synopsis:   A hand-written streaming byte parser for OpenStreetMap Protobuf data. @@ -13,9 +13,11 @@ maintainer:         colin@fosskers.ca copyright:          Copyright (c) 2017 - 2020 Azavea category:           Streaming+homepage:           https://github.com/fosskers/streaming-osm build-type:         Simple extra-source-files:-  ChangeLog.md+  CHANGELOG.md+  README.md   test/*.osm.pbf  common commons
test/Test.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE LambdaCase #-}+ module Main where  import           Codec.Compression.Zlib (decompress)@@ -83,6 +85,10 @@     , testCase "North Van" $ fileS "test/north-van.osm.pbf" (48596, 7757, 52) --    , testCase "Vancouver" $ fileS "test/vancouver.osm.pbf" (804749, 156053, 1689)     ]+  , testGroup "Misc."+    [ testCase "Relation Ref Values: Diomede" diomedeRefValues+    , testCase "Relation Ref Values: Ajishima" ajishimaRefValues+    ]   ]  assertRight :: Either t1 t -> Assertion@@ -234,3 +240,25 @@     Left err -> pure $ Left err     Right (Blob (Left bs)) -> pure $ A.parseOnly block bs     Right (Blob (Right (_, bs))) -> pure $ A.parseOnly block . BL.toStrict . decompress $ BL.fromStrict bs++diomedeRefValues :: Assertion+diomedeRefValues = fileT "test/diomede.osm.pbf" >>= \case+  Left _ -> assertFailure "Couldn't parse the file."+  Right (Block _ _ ((Relation [m0, m1] _ _):_)) -> do+    _mref m0 @?= 32973894+    _mref m1 @?= 4571349198+  Right (Block _ _ _) -> assertFailure "Incorrect relation structure."++ajishimaRefValues :: Assertion+ajishimaRefValues = fileT "test/ajishima.osm.pbf" >>= \case+  Left _ -> assertFailure "Couldn't parse the file."+  Right (Block _ _ rs) -> case filter p rs of+    [] -> assertFailure "Couldn't find the expected Relation."+    (Relation ms _ ts : _) -> do+      length ms @?= 19+      length ts @?= 6+      _mref (head ms) @?= 179786323+      _mref (last ms) @?= 91476273+  where+    p (Relation _ (Just i) _) = _id i == 1341344+    p _                       = False