Commit 523afcce authored by Santhanavanich's avatar Santhanavanich
Browse files

upload

parent bed6d349
Showing with 1200 additions and 0 deletions
+1200 -0
File added
File added
File added
File added
File added
File added
This diff is collapsed.
{
"links": [
{
"rel": "self",
"href": "host_url/collections/NewYork",
"type": "application/json",
"title": "All geospatial data available in the New York area"
}
],
"collections": [
{
"id": "NewYork",
"title": "NewYork Data Source",
"description": "All Supported 3D Containers for the city of NewYork",
"collectiontype": "3d-container",
"extent": {
"spatial": {
"bbox": [
[
-74.01900887327089,
40.700475291581974,
-11.892070104139751,
-73.9068954348699,
40.880256294183646,
547.7591871983744
]
],
"crs": "http://www.opengis.net/def/crs/OGC/0/CRS84h"
}
},
"links": [
{
"rel": "collections",
"href": "host_url/collections/",
"type": "application/json"
},
{
"title": "NewYork - 3D Buildings Manhattan",
"rel": "self",
"href": "host_url/collections/NewYork/",
"type": "application/json"
},
{
"title": "NewYork - 3D Buildings Manhattan: 3D Tiles",
"rel": "items",
"href": "host_url/collections/NewYork/3dtiles",
"type": "application/json+3dtiles"
},
{
"title": "NewYork - 3D Buildings Manhattan: i3s",
"rel": "items",
"href": "host_url/collections/NewYork/i3s",
"type": "application/json+i3s"
}
],
"children": [
],
"content": [
{
"title": "NewYork - 3D Buildings Manhattan: 3D Tiles",
"rel": "original",
"href": "host_url/collections/NewYork/3dtiles/",
"type": "application/json+3dtiles"
},
{
"title": "NewYork - 3D Buildings Manhattan: i3s",
"rel": "original",
"href": "https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_NewYork_17/SceneServer/layers/0/",
"type": "application/json+i3s"
}
]
}
]
}
\ No newline at end of file
{
"links": [
{
"rel": "self",
"href": "host_url/collections",
"type": "application/json",
"title": "All geospatial data available from this API"
}
],
"collections": [
{
"id": "NewYork",
"title": "NewYork Data Source",
"description": "All Supported 3D Containers for the city of NewYork",
"collectiontype": "3d-container",
"extent": {
"spatial": {
"bbox": [
[
-74.01900887327089,
40.700475291581974,
-11.892070104139751,
-73.9068954348699,
40.880256294183646,
547.7591871983744
]
],
"crs": "http://www.opengis.net/def/crs/OGC/0/CRS84h"
}
},
"links": [
{
"rel": "collections",
"href": "host_url/collections/",
"type": "application/json"
},
{
"title": "NewYork - Collections",
"rel": "self",
"href": "host_url/collections/NewYork/",
"type": "application/json"
},
{
"title": "NewYork - 3D Buildings Manhattan: 3D Tiles",
"rel": "items",
"href": "host_url/collections/NewYork/3dtiles",
"type": "application/json+3dtiles"
},
{
"title": "NewYork - 3D Buildings Manhattan: i3s",
"rel": "items",
"href": "host_url/collections/NewYork/i3s",
"type": "application/json+i3s"
}
],
"children": [
],
"content": [
{
"title": "NewYork - 3D Buildings Manhattan: 3D Tiles",
"rel": "original",
"href": "host_url/collections/NewYork/3dtiles/",
"type": "application/json+3dtiles"
},
{
"title": "NewYork - 3D Buildings Manhattan: i3s",
"rel": "original",
"href": "host_url/collections/NewYork/i3s",
"type": "application/json+i3s"
}
]
}
]
}
\ No newline at end of file
{
"conformsTo": [
"http://www.opengis.net/spec/OAPI_Common/1.0/req/core"
]
}
\ No newline at end of file
{
"title": "3D GeoVolumes API Server",
"description": "The 3D GeoVolumes API Server by the Steinbeis Transfer Center Technology Consultancy @ HFT Stuttgart",
"links": [
{
"type": "application/openapi+json;version=3.0",
"title": "Service Description",
"href": "https://app.swaggerhub.com/apis/Thunyathep/OGC_GeoVolumes_API/0.0.1",
"rel": "service-desc"
},
{
"type": "application/json",
"title": "Conformance",
"href": "host_url/conformance/",
"rel": "conformance"
},
{
"type": "application/json",
"title": "Collections",
"href": "host_url/collections/",
"rel": "data"
}
]
}
\ No newline at end of file
# 3DGeoVolumesAPI
### Live Demo: https://steinbeis-3dps.eu/3DGeoVolumes/
![Steinbeis GeoVolumes API](./img/ResourceArchitecture2.jpg)
## Installation
Use the package manager [npm](https://npmjs.com/) to install 3D GeoVolumes API.
```bash
npm install
```
## Usage
```bash
node server.js
```
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
## Team
- [Prof. Dr. Volker Coors](https://www.hft-stuttgart.de/p/volker-coors)
- [Joe Thunyathep Santhanavanich](https://www.hft-stuttgart.de/p/thunyathep-santhanavanich)
## Link
| Document | URL |
|------------------------------------------------------------------|-------------------------------------|
| 3D Data Container and Tiles API Pilot Summary Engineering Report | http://docs.ogc.org/per/20-031.html |
| Interoperable Simulation and Gaming Sprint Engineering Report | http://docs.ogc.org/per/20-087.html |
| Steinbeis Demo | https://steinbeis-3dps.eu |
\ No newline at end of file
img/ResourceArchitecture.jpg

46.1 KB

img/ResourceArchitecture2.jpg

308 KB

This diff is collapsed.
server.js 0 → 100644
(function () {
"use strict";
const express = require('express');
const boxIntersect = require('box-intersect');
const bodyParser = require('body-parser');
const compression = require('compression');
const app = express();
const http = require('http');
const useragent = require('useragent');
const port = 80;
app.use(compression());
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(express.static(__dirname));
const geovolumes_server_url = "http://localhost"
// const geovolumes_server_url = "https://steinbeis-3dps.eu/3DGeoVolumes"
// GeoVolume - A function to replace the geovolumes_server_url
var replace_server_url = function (const_json) {
var input_str = JSON.stringify(const_json)
input_str = input_str.replace(/host_url/g, geovolumes_server_url);
var input_output = JSON.parse(input_str)
return input_output;
}
// GeoVolume Check if bbox intersection
// This version only check 2D !!!!
var validate_bbox = function (collections_input, req) {
if (typeof req.query.bbox == "string") {
try {
// user request with bbox
// var collections_json = JSON.parse(collections_input);
var collections_json = collections_input;
var req_query_bbox = req.query.bbox;
var bbox = JSON.parse("[" + req_query_bbox + "]");
// remove the req-height if exist
if (config.server_full_log) {
console.log(`bbox lenght: ${bbox.lenght}`)
}
if (bbox.length == 6) {
bbox = [bbox[0], bbox[1], bbox[3], bbox[4]]
} else if (bbox.lenght == 0 || typeof bbox.lenght == 'undefined') {
return collections_input
}
// prepare result array
var resultJSON = {}
resultJSON["links"] = collections_json["links"]
resultJSON["collections"] = [] // prepare empty collection
for (let index = 0; index < collections_json["collections"].length; index++) {
var collection_bbox_minx = collections_json["collections"][index].extent.spatial.bbox[0][0]
var collection_bbox_miny = collections_json["collections"][index].extent.spatial.bbox[0][1]
var collection_bbox_maxx = collections_json["collections"][index].extent.spatial.bbox[0][3]
var collection_bbox_maxy = collections_json["collections"][index].extent.spatial.bbox[0][4]
var bbox_collection = [];
bbox_collection.push(collection_bbox_minx)
bbox_collection.push(collection_bbox_miny)
bbox_collection.push(collection_bbox_maxx)
bbox_collection.push(collection_bbox_maxy)
var boxes = [bbox, bbox_collection];
var overlap = boxIntersect(boxes);
if (overlap == '') {} else {
resultJSON["collections"].push(collections_json["collections"][index])
}
if (index == collections_json["collections"].length - 1) {
// Return only the last loop
return resultJSON
}
}
} catch (error) {
console.log(`Error in the BBOX function validate_bbox() :`)
console.log(error)
return collections_input
}
} else {
// user request without bbox
return collections_input
}
}
app.get('/', function (req, res) {
var landingpage_json = require('./3DGeoVolumes/landingpage.json')
var landingpage_output = replace_server_url(landingpage_json)
try {
var agent = useragent.parse(req.headers['user-agent']);
var agentString = agent.toString()
if (req.query.f === "json" || req.query.format === "json" || agentString.includes("Other")) {
res.json(landingpage_output);
} else {
// browser
res.render('geovolumes/landing.ejs', {
landingpage_output
})
}
} catch (error) {
console.log(error)
}
})
// GeoVolume - conformance
const conformance_json = require('./3DGeoVolumes/conformance.json')
app.get('/conformance', function (req, res) {
res.json(conformance_json);
})
// GeoVolume - Collections
app.get('/collections', function (req, res) {
try {
var collection_resource = require('./3DGeoVolumes/collections/collections.json')
var collection_resource_updated = replace_server_url(collection_resource)
var collection_resource_updated_bbox = validate_bbox(collection_resource_updated, req)
// check user-agent
var is_ajax = req.xhr;
var agent = useragent.parse(req.headers['user-agent']);
var agentString = agent.toString()
console.log(`request agent: ${agentString}`)
if (req.query.f === "json" || req.query.format === "json" || agentString.includes("Other")) {
res.json(collection_resource_updated_bbox);
} else {
// browser
res.render('geovolumes/collections.ejs', {
collection_resource_updated_bbox
})
}
} catch (error) {
console.log(error)
}
})
app.get('/collections/:collectionsId', function (req, res) {
try {
var collection_json = require(`./3DGeoVolumes/collections/${req.params.collectionsId}/${req.params.collectionsId}.json`)
res.json(collection_json);
} catch (error) {
res.send("internal error at /3DGeoVolumes/collections/:collectionsId")
}
})
// request 3D Tiles
app.get('/collections/:collectionsId/3dtiles', function (req, res) {
try {
var collections_3dtiles_json = require(`./3DGeoVolumes/collections/${req.params.collectionsId}/3dtiles/tileset.json`)
var collections_3dtiles_output = replace_server_url(collections_3dtiles_json)
res.json(collections_3dtiles_output);
} catch (error) {
res.send("internal error at /3DGeoVolumes/collections/:collectionsId/3dtiles")
}
})
// request i3s - New York Manual Redirect
app.get('/collections/NewYork/i3s', function (req, res) {
res.redirect("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_NewYork_17/SceneServer/layers/0/")
})
const httpServer = http.createServer(app);
httpServer.listen(port, () => {
console.log(`HTTP Server running on port ${port}`);
console.log(`server at http://localhost:${port}/`);
})
})();
\ No newline at end of file
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<title>GeoVolumes Server</title>
</head>
<body>
<div class="container">
<!-- <h1>
<img src="https://transfer.hft-stuttgart.de/pages/buildicipate/webpage/assets/images/hft_logo.svg" alt=""
width="50px">
<img src="https://steinbeis-3dps.eu/images/stw-stuttgart.jpg" alt="" width="50px">
STT GeoVolumes Server
</h1> -->
<nav class="navbar navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<h3>
<img src="https://steinbeis-3dps.eu/images/stw-stuttgart.jpg" alt="" width="50px">
<img src="https://transfer.hft-stuttgart.de/pages/buildicipate/webpage/assets/images/hft_logo.svg"
alt="" width="50px">
STT GeoVolumes Server
</h3>
</a>
</div>
</nav>
<!-- <header class="d-flex flex-wrap justify-content-center py-3 mb-4 border-bottom">
<a href="/" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-dark text-decoration-none">
</a>
</header> -->
<nav aria-label="breadcrumb" style="--bs-breadcrumb-divider: '>';" class="fs-4">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="../../">Home</a></li>
<li class="breadcrumb-item"><a href="../">3DGeoVolumes</a></li>
<li class="breadcrumb-item active" aria-current="page">Collections</li>
</ol>
</nav>
See this response in raw <code>JSON</code> format: <a href="?f=json">json</a> <br>
<!-- <input class="form-control mb-3 mt-3" id="searchBar" type="text" placeholder="Search Collections..."> -->
<hr>
<div id="collections_div">
<% for(var i=0; i < collection_resource_updated_bbox["collections"].length; i++) { %>
<div class="collections_contents">
<h5><%= collection_resource_updated_bbox["collections"][i].title %></h5> <br>
<b>ID</b>: <%= collection_resource_updated_bbox["collections"][i].id %> <br>
<b>Description</b>: <%= collection_resource_updated_bbox["collections"][i].description %> <br>
<b>Bbox</b>:
<%= JSON.stringify(collection_resource_updated_bbox["collections"][i].extent.spatial.bbox[0]) %>
<!-- BBOX 2D -->
<!-- <%= JSON.stringify(
collection_resource_updated_bbox["collections"][i].extent.spatial.bbox[0][0],
collection_resource_updated_bbox["collections"][i].extent.spatial.bbox[0][1],
collection_resource_updated_bbox["collections"][i].extent.spatial.bbox[0][3],
collection_resource_updated_bbox["collections"][i].extent.spatial.bbox[0][4],
) %> -->
<br><br>
<img src="https://server.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer/export?bbox=<%= collection_resource_updated_bbox["collections"][i].extent.spatial.bbox[0][0] %>%2C<%=collection_resource_updated_bbox["collections"][i].extent.spatial.bbox[0][1]%>%2C<%=collection_resource_updated_bbox["collections"][i].extent.spatial.bbox[0][3]%>%2C<%=collection_resource_updated_bbox["collections"][i].extent.spatial.bbox[0][4]%>&bboxSR=4326&layers=&layerDefs=&size=240%2C240&imageSR=&format=png&transparent=true&dpi=&time=&layerTimeOptions=&dynamicLayers=&gdbVersion=&mapScale=&rotation=&datumTransformations=&layerParameterValues=&mapRangeValues=&layerRangeValues=&f=image" alt="">
<br>
<b>Links</b>: <br>
<% for(var j=0; j < collection_resource_updated_bbox["collections"][i].links.length; j++) { %>
<% if (collection_resource_updated_bbox["collections"][i].links[j]["title"]) { %>
<a href="<%= collection_resource_updated_bbox["collections"][i].links[j]["href"]%>" target="_blank">
<%= collection_resource_updated_bbox["collections"][i].links[j]["title"]%>
</a> <br>
<% } %>
<% } %>
<b>Children:</b>
<%if (collection_resource_updated_bbox["collections"][i].children.length == 0) { %>
-
<% } %>
<br>
<% for(var j=0; j < collection_resource_updated_bbox["collections"][i].children.length; j++) { %>
<div class="card">
<div class="card-body">
<h6><%= collection_resource_updated_bbox["collections"][i].children[j].title %></h6>
<b>ID:</b> <%= collection_resource_updated_bbox["collections"][i].children[j].id %> <br>
<b>Description:</b> <%= collection_resource_updated_bbox["collections"][i].children[j].description %> <br>
<b>Bbox:</b> <%= JSON.stringify(collection_resource_updated_bbox["collections"][i].children[j].extent.spatial.bbox[0]) %> <br>
<br>
<img src="https://server.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer/export?bbox=<%= collection_resource_updated_bbox["collections"][i].children[j].extent.spatial.bbox[0][0] %>%2C<%=collection_resource_updated_bbox["collections"][i].children[j].extent.spatial.bbox[0][1]%>%2C<%=collection_resource_updated_bbox["collections"][i].children[j].extent.spatial.bbox[0][3]%>%2C<%=collection_resource_updated_bbox["collections"][i].children[j].extent.spatial.bbox[0][4]%>&bboxSR=4326&layers=&layerDefs=&size=240%2C240&imageSR=&format=png&transparent=true&dpi=&time=&layerTimeOptions=&dynamicLayers=&gdbVersion=&mapScale=&rotation=&datumTransformations=&layerParameterValues=&mapRangeValues=&layerRangeValues=&f=image" alt="">
<br>
<b>Links:</b> <br>
<% for(var k=0; k < collection_resource_updated_bbox["collections"][i].children[j].links.length; k++) { %>
<% if (collection_resource_updated_bbox["collections"][i].children[j].links[k]["title"]) { %>
<a href="<%= collection_resource_updated_bbox["collections"][i].children[j].links[k]["href"]%>" target="_blank">
<%= collection_resource_updated_bbox["collections"][i].children[j].links[k]["title"]%>
</a> <br>
<% } %>
<% } %>
</div>
</div>
<% } %>
<hr>
<% } %>
</div>
<%- include('footer.ejs') %>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js"
integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous">
</script>
<!-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> -->
<!-- <script>
$(document).ready(function () {
$("#searchBar").on("keyup", function () {
var value = $(this).val().toLowerCase();
$(".collections_contents").filter(function () {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});
</script> -->
</body>
</html>
\ No newline at end of file
<span class="text-muted">Found technical issue? Please contact <a
href="https://www.hft-stuttgart.de/p/thunyathep-santhanavanich"> Joe </a>
</span>
<footer class="footer mt-auto py-3 bg-light">
<div class="container">
<span class="text-muted text-center">
<img src="https://steinbeis-3dps.eu/images/stw-stuttgart.jpg" alt="" width="32">
The Steinbeis Transfer Center Technology Consultancy @ HFT Stuttgart. 2018 - 2021
</span>
</div>
</footer>
\ No newline at end of file
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<title>GeoVolumes Server</title>
</head>
<body>
<div class="container">
<!-- <h1>
<img src="https://transfer.hft-stuttgart.de/pages/buildicipate/webpage/assets/images/hft_logo.svg" alt=""
width="50px">
<img src="https://steinbeis-3dps.eu/images/stw-stuttgart.jpg" alt="" width="50px">
STT GeoVolumes Server
</h1> -->
<nav class="navbar navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<h3>
<img src="https://steinbeis-3dps.eu/images/stw-stuttgart.jpg" alt="" width="50px">
<img src="https://transfer.hft-stuttgart.de/pages/buildicipate/webpage/assets/images/hft_logo.svg"
alt="" width="50px">
STT GeoVolumes Server
</h3>
</a>
</div>
</nav>
<!-- <header class="d-flex flex-wrap justify-content-center py-3 mb-4 border-bottom">
<a href="/" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-dark text-decoration-none">
</a>
</header> -->
<nav aria-label="breadcrumb" style="--bs-breadcrumb-divider: '>';" class="fs-4">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="../">Home</a></li>
<li class="breadcrumb-item" aria-current="page">3DGeoVolumes</li>
<li class="breadcrumb-item active"><a href="/collections"></a>Collections</li>
</ol>
</nav>
See this response in raw <code>JSON</code> format: <a href="?f=json">json</a> <br>
<hr>
<div id="collections_div">
<h3> <%= landingpage_output["title"] %> </h3>
<span class="mb-4"> <%= landingpage_output["description"] %> </span> <br>
<b>Links</b>: <br>
<div class="collections_contents"></div>
<% for(var i=0; i < landingpage_output["links"].length; i++) { %>
<a href="<%= landingpage_output["links"][i]["href"]%>" target="_blank">
<%= landingpage_output["links"][i]["title"]%> </a>
<br>
<% } %>
</div>
<hr>
<%- include('footer.ejs') %>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js"
integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous">
</script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
</script>
</body>
</html>
\ No newline at end of file
Supports Markdown
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