geotile_sdk
Version:
A tile sdk for Cloud Optimised Geotiff and shapefile
77 lines (69 loc) • 1.65 kB
JavaScript
/*
* @Description:外部接口:获取瓦片
* @Author: luojun1
* @Date: 2021-11-12 10:27:13
* @LastEditTime: 2021-12-14 16:43:44
*/
var routes = require('./routes')
// Setup the expressjs server
var express = require('express')
var cors = require('cors')
var bodyParser = require('body-parser')
var geotileSDK = require('../src')
var app = express()
app.use(cors())
app.use(bodyParser.json())
app.use('/', routes)
var args = process.argv.splice(2)
console.log('args', args)
geotileSDK.setMapnikDir()
const port = process.env.PORT || 5000
app.listen(port, () => {
console.log(`Listening on ${port}`)
// 时间周期循环 1s
function timeLoop () {
setTimeout(function () {
// 预加载低级别瓦片
geotileSDK.preload()
timeLoop()
}, 1000)
}
timeLoop()
})
var styleJson_postgis = {
'style': [{
'styleName': 'ploygon_style',
'Type': 'Polygon',
'Color': 'black',
'LineWidth': 1,
'FillColor': '#bee826'
},
{
'styleName': 'raster_style',
'Type': 'Raster'
}
],
'layer': [{
'type': 'postgis',
'style': 'ploygon_style',
'host': '172.20.52.202',
'dbname': 'gis',
'user': 'gis',
'password': 'gis',
'sql': 'select wkb_geometry from data.c0kag5rtsgyxj3dwjeuv',
'SRS': '4326'
},
{
'type': 'gdal',
'style': 'raster_style',
'path': '/luojun/github/sl-component-vis-raster-v2/test/data/clip2_cog.tif',
'SRS': '4326'
}
]
}
// const jsonStr = JSON.stringify(styleJson_postgis)
// // geotileSDK.generateXML(jsonStr, (err, uuid) => {
// // if (err) {
// // console.log(err)
// // } else { console.log(uuid) }
// // })