Giter Site home page Giter Site logo

swifttileservercache's Introduction

SwiftTileserverCache

Installing

  • Install Docker
  • Create a new folder to store the yml file in and change into it: mkdir TileServer && cd TileServer
  • Load the yml: wget https://raw.githubusercontent.com/123FLO321/SwiftTileserverCache/master/docker-compose.yml
  • Edit the docker-compose.yml file if you want to change defaults. Default will work fine.
  • Create a new folder to store TileServer data in and chagne into it: mkdir TileServer && cd TileServer
  • Get Download command from https://openmaptiles.com/downloads/planet/ for your region.
  • Download the file using wget.
  • Rename file to end in .mbtiles if it got named incorrectly
  • Change one layer back into the folder where the docker-compose.yml file is located: cd ..
  • Start and attach to logs: docker-compose up -d && docker-compose logs -f

Formats

  • Tiles:
    • GET tile/{style}/{z}/{x}/{y}/{scale}/{format}
  • StaticMap:
    • POST /staticmap (StaticMap Object in JSON Format as POST body)
    • GET /staticmap (SaticMap Object in URL Parameters using URL-encoding)
    • GET /staticmap/:template (Template Enviroment parsed from URL Parameters)
    • POST /staticmap/:template (Template Enviroment in JSON Format Format as POST body)
    • GET /staticmap/pregenerated/:id (Get image from pregenerated map. Use GET or POST to /staticmap with pregenerate=true as URL Parameter to get pregenerate the map)
  • MutliStaticMap:
    • POST /multistaticmap (MultiStaticMap Object in JSON Format as POST body)
    • POST /multistaticmap (MultiStaticMap Object in URL Parameters using URL-encoding)
    • GET /multistaticmap/:template (Template Enviroment parsed from URL Parameters. Parameters ending in json will be parsed as json. Multiple instances of same Parameter will be parsed as array)
    • POST /multistaticmap/:template (Template Enviroment in JSON Format Format as POST body)
    • GET /multistaticmap/pregenerated/:id (Get image from pregenerated map. Use GET or POST to /staticmap with pregenerate=true as URL Parameter to get pregenerate the map)

Style

Get a list of styles by visiting /styles Checkout https://tileserver.readthedocs.io for a guide on how to add more styles.

StaticMap

StaticMap route accepts an StaticMap Object JSON Object as POST body: Example:

{
  "style": string (check avilable styles at /styles),
  "latitude": double,
  "longitude": double,
  "zoom": int,
  "width": int,
  "height": int,
  "scale": int,
  "format": string? (png, jpg, ...),
  "bearing": double?,
  "pitch": double?,
  "markers": [Marker]?,
  "polygons": [Geofence]?,
  "circles": [Circle]?"
}

MultiStaticMap

MultiStaticMap route accepts an MultiStaticMap JSON Object as POST Body: Example:

{
  "grid": [
    {
      "direction": string (always "first"),
      "maps": [
        {
          "direction": string (always "first"),
          "map": StaticMap
        }, {
          "direction": string ("right", or "bottom"),
          "map": StaticMap
        }, 
        ...
      ]
    }, {
      "direction": string ("right", or "bottom"),
      "maps": [
        {
          "direction": string (always "first"),
          "map": StaticMap
        }, {
          "direction": string ("right", or "bottom"),
          "map": StaticMap
        }, 
        ...
      ]
    },
    ...
  ]
}

Marker

Marker JSON used in StaticMap: Example:

{
  "url": string,
  "height": int,
  "width": int,
  "x_offset": int,
  "y_offset": int,
  "latitude": double,
  "longitude": double
}

Polygon

Polygon JSON used in StaticMap: Example:

{
  "fill_color": string (imagemagick color string),
  "stroke_color": string (imagemagick color string),
  "stroke_width": int,
  "path": [
    [double (lat), double (lon)],
    [double, double],
    ...
  ]
}

Circle

Circle JSON used in StaticMap: Example:

{
  "fill_color": string (imagemagick color string),
  "stroke_color": string (imagemagick color string),
  "stroke_width": int,
  "radius": double,
  "latitude": double,
  "longitude": double
}

Examples

Tiles

GET https://tileserverurl/tile/klokantech-basic/{z}/{x}/{y}/2/png

StaticMap

GET https://tileserverurl/staticmap?style=klokantech-basic&latitude=47.263416&longitude=11.400512&zoom=17&width=500&height=500&scale=2

Pregenerate StaticMap

Pregenerate: GET https://tileserverurl/staticmap?style=klokantech-basic&latitude=47.263416&longitude=11.400512&zoom=17&width=500&height=500&scale=2&pregenerate=true Returns: id View: GET https://tileserverurl/staticmap/pregenerated/{id}

StaticMap with Markers

POST https://tileserverurl/staticmap

{
    "style": "klokantech-basic",
    "latitude": 47.263416,
    "longitude": 11.400512,
    "zoom": 17,
    "width": 500,
    "height": 500,
    "scale": 1,
    "markers": [
        {
            "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/8/88/Map_marker.svg/1200px-Map_marker.svg.png",
            "latitude": 47.263416,
            "longitude": 11.400512,
            "width": 50,
            "height": 50
        }
    ]
}

staticmap response

MultiStaticMap

POST https://tileserverurl/multistaticmap

{
    "grid": [
        {
            "direction": "first",
            "maps": [
                {
                    "direction": "first",
                    "map": {
                        "style": "klokantech-basic",
                        "latitude": 47.263416,
                        "longitude": 11.400512,
                        "zoom": 17,
                        "width": 500,
                        "height": 250,
                        "scale": 1,
                        "markers": [
                            {
                                "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/8/88/Map_marker.svg/1200px-Map_marker.svg.png",
                                "latitude": 47.263416,
                                "longitude": 11.400512,
                                "width": 50,
                                "height": 50
                            }
                        ]
                    }
                }
            ]
        },
        {
            "direction": "bottom",
            "maps": [
                {
                    "direction": "first",
                    "map": {
                        "style": "klokantech-basic",
                        "latitude": 47.263416,
                        "longitude": 11.400512,
                        "zoom": 15,
                        "width": 300,
                        "height": 100,
                        "scale": 1,
                        "markers": [
                            {
                                "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/8/88/Map_marker.svg/1200px-Map_marker.svg.png",
                                "latitude": 47.263416,
                                "longitude": 11.400512,
                                "width": 25,
                                "height": 25
                            }
                        ]
                    }
                },
                {
                    "direction": "right",
                    "map": {
                        "style": "klokantech-basic",
                        "latitude": 47.263416,
                        "longitude": 11.400512,
                        "zoom": 12,
                        "width": 200,
                        "height": 100,
                        "scale": 1,
                        "markers": [
                            {
                                "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/8/88/Map_marker.svg/1200px-Map_marker.svg.png",
                                "latitude": 47.263416,
                                "longitude": 11.400512,
                                "width": 25,
                                "height": 25
                            }
                        ]
                    }
                }
            ]
        }
    ]
}

multistaticmap response

StaticMap using Templates

pokemon.json file in Templates directory (uses Leaf as TemplatingEngine):

{
    "style": "klokantech-basic",
    "latitude": #(lat),
    "longitude": #(lon),
    "zoom": 15,
    "width": 500,
    "height": 250,
    "scale": 1,
    "markers": [
        {
        "url": "https://rdmurl/static/img/pokemon/#(id)#if(form != nil):-#(form)#endif.png",
            "latitude": #(lat),
            "longitude": #(lon),
            "width": 50,
            "height": 50
        }
    ]
}

GET https://tileserverurl/staticmap/pokemon?id=201&lat=47.263416&lon=11.400512&form=5 staticmap-template response

swifttileservercache's People

Contributors

123flo321 avatar lenisko 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

Watchers

 avatar  avatar  avatar

swifttileservercache's Issues

Failed to load base static map

Not sure if this is the best place to ask for support, My Apologies if it isnt.

That said. I setup the TileServer cache per the readme. I downloaded my states mbtile and used that.

I can seem to get the Tileserver cache to work with a staticmap and a custom template. For example:
posting to staticmap/templatename?pregenerate=true&regeneratable=true, Getting that ID and then calling staticmap/pregenerated/.

That being said, I cant seem to get anything else to work. Just following simply the readme, I believe i should be able to visit the /styles directory to view available styles or get a tile by using tile/{style}/{z}/{x}/{y}/{scale}/{format}. Using the examples in the readme results in errors and I am not sure why.

Here are the results of running through a couple of examples:
Tiles:
tile/klokantech-basic/{z}/{x}/{y}/2/png
URL Error: {"reason":"Failed to load tile (The operation could not be completed. (SwiftError error 0.))","error":true}
Logging Error: Abort.400: Failed to load tile (The operation could not be completed. (SwiftError error 0.))

StaticMap:
https://tileserverurl/staticmap?style=klokantech-basic&latitude=47.263416&longitude=11.400512&zoom=17&width=500&height=500&scale=2
URL Error: {"reason":"Failed to load base static map: (The operation could not be completed. (SwiftError error 0.))","error":true}
Logging Error: Abort.400: Failed to load base static map: (The operation could not be completed. (SwiftError error 0.))

PreGenerate StaticMap:
https://tileserverurl/staticmap?style=klokantech-basic&latitude=47.263416&longitude=11.400512&zoom=17&width=500&height=500&scale=2&pregenerate=true
URL Error: {"error":true,"reason":"Failed to load base static map: (The operation could not be completed. (SwiftError error 0.))"}
Logging Error: Abort.400: Failed to load base static map: (The operation could not be completed. (SwiftError error 0.))

All that said, I can get tiles to work if I go directly to the TileServer container. I can do so by using:
https://tileservercontainerurl/styles/klokantech-basic/{z}/{x}/{y}.png

Am I missing something here or not understanding the ReadMe correctly? Any help or assistance would be appreciated.
Thanks!

Combining Datasets not working

I have been trying to upload two different datasets downloaded from maptiler and the “Uploading and Combining” message stays forever
After reloading the page, both datasets appear in the Datasets section. However, when I fetch a staticmap from the second dataset I receive a blank image.

By the way, I am trying to combine Spain and Canary Islands, which are the same country but in two different mbtiles files.

Perhaps I am doing something wrong…

Thanks

[userinterface] tileserver is is exiting

I wanted to test the new userinterface branch and it is working to some extend.

In the logs I can see that the tileserver is exiting with the following information:

tileserver    | Starting tileserver-gl v3.1.1
tileserver    | Using specified config file from config.json
tileserver    | Starting server
tileserver    | The specified path for "sprites" does not exist (/usr/src/app/node_modules/tileserver-gl-styles).
tileserver exited with code 1

Failed to load base staticmap

hi,
i get this error when i try to get a staticmap.
Have forget some configuration?

tileserver-cache | [2020-04-29T22:26:11.036Z] [DEBUG] [HTTPServer.swift] Accepted HTTP connection from: XXX.XXX.XXX.XXX:41270
tileserver-cache | [2020-04-29T22:26:11.036Z] [VERBOSE] [HTTPServerRequest.swift] HTTP request forwarded for=XXX.XXX.XXX.XXX; proto=http; by=XXX.XXX.XXX.XXX;
tileserver-cache | [2020-04-29T22:26:11.039Z] [INFO] [WebServer.swift] Loading Static: StaticMap(style: "osm-bright-gl-style", latitude: XX.263416, longitude: XX.400512, zoom: 12.0, width: 500, height: 250, scale: 1, format: nil, bearing: nil, pitch: nil, markers: nil, polygons: nil)
tileserver    | GET /styles/osm-bright-gl-style/static/XX.400512,XX.263416,[email protected],0.0/500x250.png 404 217 - 1.957 ms
tileserver-cache | [2020-04-29T22:26:11.047Z] [INFO] [APIUtils.swift] Failed to load file. Got 404

Tileserver stops after 3 days

Hello, I'm using SwiftTileserverCache for a Discord channel but after 3 days the messages stops getting maps, I have rebooted Docker and that fixed it, so my question is if I need to reboot Docker every other day or if I have some configuration missing to flush the cache or something like that.

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.