Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
OGC
node-3DPSx
Commits
be207d7d
Commit
be207d7d
authored
Jul 15, 2020
by
athanasios
Browse files
boundingbox now optional
parent
972dcd68
Changes
7
Hide whitespace changes
Inline
Side-by-side
config.js
View file @
be207d7d
const
config
=
{
port
:
9000
port
:
9000
,
boundingBoxBufferPercent
:
15
}
module
.
exports
=
config
;
\ No newline at end of file
routes/v1.js
View file @
be207d7d
const
express
=
require
(
"
express
"
);
const
{
check
,
validationResult
,
oneOf
}
=
require
(
"
express-validator
"
)
const
{
check
,
validationResult
}
=
require
(
"
express-validator
"
)
const
{
toLower
}
=
require
(
"
../src/customSanitizers
"
);
const
{
errorHandler
}
=
require
(
"
../src/errorHandler
"
);
const
checkFactory
=
require
(
"
../src/validationCheckFactory
"
);
const
{
getSceneHandler
}
=
require
(
"
../src/getSceneHandler
"
);
const
{
getCapabilitiesHandler
}
=
require
(
"
../src/getCapabilitiesHandler
"
);
const
assets
=
require
(
"
../src/assets
"
);
const
bb
=
require
(
"
../src/boundingbox
"
);
const
redirectTo
=
require
(
"
../src/redirectTo
"
);
...
...
@@ -56,8 +57,11 @@ const sceneChecks = [
.
exists
().
withMessage
(
"
MissingParameterValue
"
)
.
customSanitizer
(
toLower
)
.
equals
(
"
getscene
"
).
withMessage
(
"
InvalidParameterValue
"
),
check
(
"
boundingbox
"
)
check
(
"
layers
"
)
.
exists
().
withMessage
(
"
MissingParameterValue
"
)
.
custom
(
value
=>
assets
.
allLayersExist
(
value
)).
withMessage
(
"
UnknownLayer
"
),
check
(
"
boundingbox
"
)
.
optional
()
.
matches
(
/^
((\-?\d
+
(\.\d
+
)?)
,
){3}(\-?\d
+
(\.\d
+
)?)
$/
).
withMessage
(
"
InvalidParameterValue
"
)
.
custom
(
value
=>
bb
.
isValid
(
value
)).
withMessage
(
"
InvalidParameterValue
"
),
check
(
"
cullingvolume
"
)
...
...
@@ -74,11 +78,7 @@ const sceneChecks = [
.
matches
(
/^
((\-?\d
+
(\.\d
+
)?)
,
){1}(\-?\d
+
(\.\d
+
)?)
$/
).
withMessage
(
"
InvalidParameterValue
"
),
check
(
"
time
"
)
.
exists
().
withMessage
(
"
MissingParameterValue
"
)
.
matches
(
/
\d
+/
).
withMessage
(
"
InvalidParameterValue
"
),
check
(
"
intersect
"
)
.
exists
().
withMessage
(
"
MissingParameterValue
"
)
.
customSanitizer
(
toLower
)
.
isIn
([
"
true
"
,
"
false
"
]).
withMessage
(
"
InvalidParameterValue
"
)
.
matches
(
/
\d
+/
).
withMessage
(
"
InvalidParameterValue
"
)
];
router
.
route
(
"
/scene
"
).
get
(
sceneChecks
,
(
req
,
res
)
=>
{
...
...
src/assets.js
View file @
be207d7d
...
...
@@ -2,6 +2,22 @@ const fs = require("fs");
const
boxIntersect
=
require
(
"
box-intersect
"
);
const
path
=
require
(
'
path
'
);
const
getLayers
=
(
layers
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
readFile
(
"
./assets/assets.json
"
,
(
err
,
data
)
=>
{
if
(
err
)
{
reject
();
}
let
assets
=
JSON
.
parse
(
data
);
let
requestedLayers
=
layers
.
split
(
"
,
"
);
assets
=
assets
.
filter
(
asset
=>
requestedLayers
.
includes
(
asset
.
id
));
assets
=
assets
.
filter
(
asset
=>
asset
.
scope
==
"
public
"
);
resolve
(
assets
);
});
});
}
const
getIntersectingLayers
=
(
bb
,
layers
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
@@ -124,4 +140,4 @@ const isPublic = (url) => {
}
module
.
exports
=
{
getIntersectingLayers
,
getIntersecting
,
allLayersExist
,
getPublicLayers
,
isPublic
};
\ No newline at end of file
module
.
exports
=
{
getIntersectingLayers
,
getIntersecting
,
allLayersExist
,
getPublicLayers
,
isPublic
,
getLayers
};
\ No newline at end of file
src/context.js
View file @
be207d7d
...
...
@@ -12,8 +12,7 @@ const fromRequest = (req) => {
camera
:
camera
.
fromString
(
req
.
query
.
camera
),
offCenterFrustum
:
offCenterFrustum
.
fromString
(
req
.
query
.
frustum
),
drawingBuffer
:
drawingBuffer
.
fromString
(
req
.
query
.
drawingbuffer
),
requestTime
:
req
.
query
.
time
,
intersect
:
JSON
.
parse
(
req
.
query
.
intersect
.
toLowerCase
())
requestTime
:
req
.
query
.
time
};
}
...
...
src/geographicBoundingBox.js
View file @
be207d7d
...
...
@@ -61,6 +61,7 @@ class GeographicBoundingBox {
}
const
fromString
=
(
str
)
=>
{
if
(
!
str
)
return
null
;
let
tokens
=
str
.
split
(
"
,
"
);
return
new
GeographicBoundingBox
(...
tokens
.
map
(
token
=>
parseFloat
(
token
)));
}
...
...
src/getSceneHandler.js
View file @
be207d7d
...
...
@@ -3,7 +3,7 @@ const Traverse = require("./traverse");
const
getSceneHandler
=
(
req
,
res
)
=>
{
assets
.
get
Intersecting
(
req
.
query
.
boundingbox
).
then
(
layers
=>
{
assets
.
get
Layers
(
req
.
query
.
layers
).
then
(
layers
=>
{
let
traverse
=
new
Traverse
();
traverse
.
begin
(
req
,
layers
[
0
].
url
)
...
...
src/nodes.js
View file @
be207d7d
const
config
=
require
(
"
../config
"
);
class
Nodes
{
constructor
()
{
...
...
@@ -21,9 +23,9 @@ class Nodes {
time
:
context
.
requestTime
};
if
(
context
.
intersect
)
{
if
(
context
.
bb
!=
null
)
{
let
requestedBB
=
context
.
bb
.
clone
();
requestedBB
.
extend
(
25
);
requestedBB
.
extend
(
config
.
boundingBoxBufferPercent
);
if
(
requestedBB
.
intersectWithGeographic
(
boundingSphere
.
geographicCenter
))
{
this
.
nodes
.
push
(
entry
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment