Commit 2f079692 authored by Rodrigo Tapia-McClung's avatar Rodrigo Tapia-McClung

Remove '/data' in routes and calls

parent 4dca3da3
......@@ -93,7 +93,7 @@ const sql = (params, query) => {
* 422:
* description: invalid datasource or columnname
*/
app.get('/data/geobuf/:table', async (req, res)=> {
app.get('/geobuf/:table', async (req, res)=> {
if (!req.query.geom_column) {
req.query.geom_column = 'geom';
}
......
......@@ -93,7 +93,7 @@ module.exports = function(app, pool) {
* 422:
* description: invalid datasource or columnname
*/
app.get('/data/geojson/:table', async (req, res) => {
app.get('/geojson/:table', async (req, res) => {
if (!req.query.geom_column) {
req.query.geom_column = 'geom';
}
......
......@@ -78,7 +78,7 @@ const geojsonSQL = (params, query) => {
}
module.exports = function(app, pool) {
app.get('/data/geojsonmvt/:table', async (req, res) => {
app.get('/geojsonmvt/:table', async (req, res) => {
//console.log(req)
......
......@@ -88,7 +88,7 @@ const sql = () => {
* 500:
* description: unexpected error
*/
app.get('/data/list_layers', async (req, res)=>{
app.get('/list_layers', async (req, res)=>{
try {
const sqlString = sql()
const result = await pool.query(sqlString);
......
......@@ -12,7 +12,7 @@ let header = {
// Route which handles requests like the following: /<mbtiles-name>/0/1/2.pbf
module.exports = function(app) {
app.get('/data/:source/mbtiles/:z/:x/:y.pbf', function(req, res) {
app.get('/:source/mbtiles/:z/:x/:y.pbf', function(req, res) {
new MBTiles(p.join(__dirname, `/public/${req.params.source}.mbtiles`), function(err, mbtiles) {
mbtiles.getTile(req.params.z, req.params.x, req.params.y, function(err, tile, headers) {
if (err) {
......
......@@ -168,7 +168,7 @@ module.exports = function(app, pool, cache) {
* 422:
* description: invalid datasource or columnname
*/
app.get('/data/:datasource/mvt/:z/:x/:y', cacheMiddleWare, async (req, res)=>{
app.get('/:datasource/mvt/:z/:x/:y', cacheMiddleWare, async (req, res)=>{
if (!req.query.geom_column) {
req.query.geom_column = 'geom'; // default
}
......
......@@ -7,7 +7,9 @@
/* global mapboxgl, turf */
const baseUrl = new URL(`/data`, window.location.href).href;
const baseUrl = new URL(window.location.href).href; // returns "http://localhost:8093/"
// use `${baseUrl}something` - don't need `${baseUrl}/something`
//let selectedMunis = [{id: "09002", geom: { coordinates: [[ -99.25958633422852, 19.34791392861453 ]], type: "Polygon" }}, {id: "09012", geom: { coordinates: [[ -99.25958633422852, 19.34791392861453 ]], type: "Polygon" }}],
// selectedIDs = selectedMunis.map(m => m.id);
let selectedMunis = [],
......@@ -22,7 +24,7 @@ const tileSource = (mbtiles, minZoom, maxZoom) => {
// if serving directly from PostGIS, use "source-layer": table, if using mbtiles, use "source-layer": "denue"
let pbfSource = {
"type": "vector",
"tiles": [`${baseUrl}/${mbtiles}/mbtiles/{z}/{x}/{y}.pbf`],
"tiles": [`${baseUrl}${mbtiles}/mbtiles/{z}/{x}/{y}.pbf`],
"minzoom": minZoom,
"maxzoom": maxZoom,
/*"type": "symbol",
......@@ -66,7 +68,7 @@ map.on("style.load", async () => {
// add municipios source
map.addSource("dim_municipio", {
"type": "vector",
"tiles": [`${baseUrl}/dim_municipio/mvt/{z}/{x}/{y}?geom_column=municipio_geom_4326&columns=municipio_cvegeo`],
"tiles": [`${baseUrl}dim_municipio/mvt/{z}/{x}/{y}?geom_column=municipio_geom_4326&columns=municipio_cvegeo`],
"maxzoom": 14,
"minzoom": 8,
"promoteId": {"dim_municipio": "municipio_cvegeo"}
......@@ -236,7 +238,7 @@ map.on("click", "denue", async e => {
let features = map.queryRenderedFeatures(e.point, { layers: ["denue"] });
if (features.length != 0) {
let denue_cve = features[0].properties["denue_cve"];
let denueQuery = `${baseUrl}/query/dim_denue2019?columns=denue_nombre&filter=denue_cve=${denue_cve}`;
let denueQuery = `${baseUrl}query/dim_denue2019?columns=denue_nombre&filter=denue_cve=${denue_cve}`;
const response = await fetch(denueQuery);
const denueData = await response.json();
new mapboxgl.Popup()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment