vectortiles-1.2.0.4: GIS Vector Tiles, as defined by Mapbox.

Copyright(c) Azavea 2016
LicenseApache 2
MaintainerColin Woodbury <cwoodbury@azavea.com>
Safe HaskellNone
LanguageHaskell2010

Geography.VectorTile

Contents

Description

GIS Vector Tiles, as defined by Mapbox.

This library implements version 2.1 of the official Mapbox spec, as defined here: https://github.com/mapbox/vector-tile-spec/tree/master/2.1

Note that currently this library ignores top-level protobuf extensions, Value extensions, and UNKNOWN geometries.

The order in which to explore the modules of this library is as follows:

  1. Geography.VectorTile.VectorTile
  2. Geography.VectorTile.Geometry
  3. Geography.VectorTile.Protobuf

Usage

This library reads and writes strict ByteStrings. By importing this module, you use the default protobuf backend. Given some legal VectorTile file called roads.mvt:

import qualified Data.ByteString as BS
import           Data.Text (Text)
import           Geography.VectorTile

-- | Read in raw protobuf data and decode it into a high-level type.
roads :: IO (Either Text VectorTile)
roads = do
  mvt <- BS.readFile "roads.mvt"
  pure $ decode mvt >>= tile

Or encode a VectorTile back into a ByteString:

roadsBytes :: VectorTile -> BS.ByteString
roadsBytes = encode . untile

Synopsis

High-level Types

This module also provides lenses for data field access, as VectorTiles are highly nested objects.

Protobuf Backend

Conversions

ByteString Encoding / Decoding

decode :: ByteString -> Either Text RawVectorTile Source #

Attempt to decode a ByteString of raw protobuf data into a mid-level representation of a RawVectorTile.

encode :: RawVectorTile -> ByteString Source #

Encode a mid-level representation of a RawVectorTile into raw protobuf data.