forked from podolaceklukas/assignment-gis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff6556e
commit 5298d5c
Showing
10 changed files
with
306 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
pdt-marinehelper-server/api/controllers/covesController.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
const db = require("../../db"); | ||
|
||
exports.getAllAnchorages = (req, res, next) => { | ||
const SELECT_ANCHORAGES_QUERY = | ||
'SELECT osm_id, "seamark:type", "seamark:name", "seamark:anchorage:category", ST_AsGeoJSON(ST_Transform(way, 4326)) AS geojson ' + | ||
"FROM planet_osm_point " + | ||
"WHERE \"seamark:type\" = 'anchorage'"; | ||
|
||
db.query(SELECT_ANCHORAGES_QUERY, [], (err, res1) => { | ||
if (err) { | ||
return next(err); | ||
} | ||
|
||
const result = res1.rows.map(row => { | ||
const geojson = JSON.parse(row.geojson); | ||
return { ...row, geojson }; | ||
}); | ||
|
||
res.status(200).json({ | ||
message: "anchorages fetched", | ||
result: result, | ||
error: err | ||
}); | ||
}); | ||
}; | ||
|
||
exports.getAllMoorings = (req, res, next) => { | ||
const SELECT_MOORINGS_QUERY = | ||
'SELECT osm_id, "seamark:type", "seamark:name", ST_AsGeoJSON(ST_Transform(way, 4326)) as geojson ' + | ||
"FROM planet_osm_point " + | ||
"WHERE \"seamark:type\" = 'mooring'"; | ||
|
||
db.query(SELECT_MOORINGS_QUERY, [], (err, res1) => { | ||
if (err) { | ||
return next(err); | ||
} | ||
|
||
const result = res1.rows.map(row => { | ||
const geojson = JSON.parse(row.geojson); | ||
return { ...row, geojson }; | ||
}); | ||
|
||
res.status(200).json({ | ||
message: "moorings fetched", | ||
result: result, | ||
error: err | ||
}); | ||
}); | ||
}; | ||
|
||
exports.getAllRestrictedAreas = (req, res, next) => { | ||
const SELECT_RESTRICTED_AREAS_QUERY = ""; | ||
|
||
db.query(SELECT_RESTRICTED_AREAS_QUERY, [], (err, res1) => { | ||
if (err) { | ||
return next(err); | ||
} | ||
|
||
const result = res1.rows.map(row => { | ||
const geojson = JSON.parse(row.geojson); | ||
return { ...row, geojson }; | ||
}); | ||
|
||
res.status(200).json({ | ||
message: "restricted areas fetched", | ||
result: result, | ||
error: err | ||
}); | ||
}); | ||
}; | ||
|
||
exports.getAllUnderwaterCablesAndPipes = (req, res, next) => { | ||
const SELECT_UNDERWATER_CABLES_AND_PIPES_QUERY = | ||
'SELECT osm_id, "seamark:type", "seamark:name", ST_AsGeoJSON(ST_Transform(way, 4326)) as geojson ' + | ||
"FROM planet_osm_line " + | ||
"WHERE \"seamark:type\" = 'pipeline_submarine' OR \"seamark:type\" = 'cable_submarine'"; | ||
|
||
db.query(SELECT_UNDERWATER_CABLES_AND_PIPES_QUERY, [], (err, res1) => { | ||
if (err) { | ||
return next(err); | ||
} | ||
|
||
const result = res1.rows.map(row => { | ||
const geojson = JSON.parse(row.geojson); | ||
return { ...row, geojson }; | ||
}); | ||
|
||
res.status(200).json({ | ||
message: "underwater cables and pipes fetched", | ||
result: result, | ||
error: err | ||
}); | ||
}); | ||
}; |
Oops, something went wrong.