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) => { ...@@ -93,7 +93,7 @@ const sql = (params, query) => {
* 422: * 422:
* description: invalid datasource or columnname * 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) { if (!req.query.geom_column) {
req.query.geom_column = 'geom'; req.query.geom_column = 'geom';
} }
......
...@@ -93,7 +93,7 @@ module.exports = function(app, pool) { ...@@ -93,7 +93,7 @@ module.exports = function(app, pool) {
* 422: * 422:
* description: invalid datasource or columnname * 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) { if (!req.query.geom_column) {
req.query.geom_column = 'geom'; req.query.geom_column = 'geom';
} }
......
...@@ -78,7 +78,7 @@ const geojsonSQL = (params, query) => { ...@@ -78,7 +78,7 @@ const geojsonSQL = (params, query) => {
} }
module.exports = function(app, pool) { module.exports = function(app, pool) {
app.get('/data/geojsonmvt/:table', async (req, res) => { app.get('/geojsonmvt/:table', async (req, res) => {
//console.log(req) //console.log(req)
......
...@@ -88,7 +88,7 @@ const sql = () => { ...@@ -88,7 +88,7 @@ const sql = () => {
* 500: * 500:
* description: unexpected error * description: unexpected error
*/ */
app.get('/data/list_layers', async (req, res)=>{ app.get('/list_layers', async (req, res)=>{
try { try {
const sqlString = sql() const sqlString = sql()
const result = await pool.query(sqlString); const result = await pool.query(sqlString);
......
...@@ -12,7 +12,7 @@ let header = { ...@@ -12,7 +12,7 @@ let header = {
// Route which handles requests like the following: /<mbtiles-name>/0/1/2.pbf // Route which handles requests like the following: /<mbtiles-name>/0/1/2.pbf
module.exports = function(app) { 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) { 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) { mbtiles.getTile(req.params.z, req.params.x, req.params.y, function(err, tile, headers) {
if (err) { if (err) {
......
...@@ -168,7 +168,7 @@ module.exports = function(app, pool, cache) { ...@@ -168,7 +168,7 @@ module.exports = function(app, pool, cache) {
* 422: * 422:
* description: invalid datasource or columnname * 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) { if (!req.query.geom_column) {
req.query.geom_column = 'geom'; // default req.query.geom_column = 'geom'; // default
} }
......
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
/* global mapboxgl, turf */ /* 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" }}], //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); // selectedIDs = selectedMunis.map(m => m.id);
let selectedMunis = [], let selectedMunis = [],
...@@ -22,7 +24,7 @@ const tileSource = (mbtiles, minZoom, maxZoom) => { ...@@ -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" // if serving directly from PostGIS, use "source-layer": table, if using mbtiles, use "source-layer": "denue"
let pbfSource = { let pbfSource = {
"type": "vector", "type": "vector",
"tiles": [`${baseUrl}/${mbtiles}/mbtiles/{z}/{x}/{y}.pbf`], "tiles": [`${baseUrl}${mbtiles}/mbtiles/{z}/{x}/{y}.pbf`],
"minzoom": minZoom, "minzoom": minZoom,
"maxzoom": maxZoom, "maxzoom": maxZoom,
/*"type": "symbol", /*"type": "symbol",
...@@ -66,7 +68,7 @@ map.on("style.load", async () => { ...@@ -66,7 +68,7 @@ map.on("style.load", async () => {
// add municipios source // add municipios source
map.addSource("dim_municipio", { map.addSource("dim_municipio", {
"type": "vector", "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, "maxzoom": 14,
"minzoom": 8, "minzoom": 8,
"promoteId": {"dim_municipio": "municipio_cvegeo"} "promoteId": {"dim_municipio": "municipio_cvegeo"}
...@@ -236,7 +238,7 @@ map.on("click", "denue", async e => { ...@@ -236,7 +238,7 @@ map.on("click", "denue", async e => {
let features = map.queryRenderedFeatures(e.point, { layers: ["denue"] }); let features = map.queryRenderedFeatures(e.point, { layers: ["denue"] });
if (features.length != 0) { if (features.length != 0) {
let denue_cve = features[0].properties["denue_cve"]; 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 response = await fetch(denueQuery);
const denueData = await response.json(); const denueData = await response.json();
new mapboxgl.Popup() 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