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
a641707c
Commit
a641707c
authored
Jul 18, 2020
by
Athanasios
Browse files
modify temporary assets
parent
e6e18900
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/assets.js
View file @
a641707c
...
...
@@ -2,6 +2,7 @@ const fs = require("fs");
const
fsprom
=
require
(
'
fs
'
).
promises
;
const
boxIntersect
=
require
(
"
box-intersect
"
);
const
path
=
require
(
'
path
'
);
const
tempAssets
=
require
(
"
../src/tempAssets
"
);
// const getLayers = (layers) => {
// return new Promise((resolve, reject) => {
...
...
@@ -21,15 +22,12 @@ const path = require('path');
const
getLayers
=
async
(
layers
)
=>
{
let
assets
=
await
getAllAssets
();
let
requestedLayers
=
layers
.
split
(
"
,
"
);
assets
=
assets
.
filter
(
asset
=>
requestedLayers
.
includes
(
asset
.
id
));
assets
=
assets
.
filter
(
asset
=>
asset
.
scope
==
"
public
"
);
return
assets
;
}
const
getAllAssets
=
async
()
=>
{
...
...
@@ -38,8 +36,7 @@ const getAllAssets = async () => {
let
assetsJson
=
await
fsprom
.
readFile
(
'
./assets/assets.json
'
,
'
utf8
'
);
let
assets
=
JSON
.
parse
(
assetsJson
);
let
tempassetsJson
=
await
fsprom
.
readFile
(
'
./assets/temporaryAssets.json
'
,
'
utf8
'
);
let
tempassets
=
JSON
.
parse
(
tempassetsJson
);
let
tempassets
=
await
tempAssets
.
getTempAssets
();
assets
.
push
(...
tempassets
);
return
assets
;
...
...
@@ -166,13 +163,10 @@ const allLayersExist = async (layers) => {
const
getPublicLayers
=
async
()
=>
{
let
assets
=
await
getAllAssets
();
assets
=
assets
.
filter
(
asset
=>
asset
.
scope
==
"
public
"
);
return
assets
;
}
const
isPublic
=
(
url
)
=>
{
...
...
src/tempAssets.js
View file @
a641707c
...
...
@@ -14,13 +14,13 @@ const addTempLayer = (req, res) => {
await
removeExpired
();
let
doc
=
await
fetch
(
req
.
body
.
url
);
let
nd
=
await
doc
.
json
();
doc
=
await
doc
.
json
();
let
tempLayer
=
{
name
:
`(tmp)
${
req
.
body
.
name
}
`
,
id
:
uuidv4
(),
boundingbox
:
n
d
.
store
.
extent
,
boundingbox
:
d
oc
.
store
.
extent
,
url
:
req
.
body
.
url
,
creationTime
:
Date
.
now
(),
scope
:
"
public
"
...
...
@@ -68,5 +68,22 @@ const removeExpired = async () => {
}
const
getTempAssets
=
async
()
=>
{
module
.
exports
=
{
addTempLayer
};
\ No newline at end of file
try
{
await
removeExpired
();
let
tempassetsJson
=
await
fs
.
readFile
(
'
./assets/temporaryAssets.json
'
,
'
utf8
'
);
let
tempassets
=
JSON
.
parse
(
tempassetsJson
);
return
tempassets
;
}
catch
(
error
)
{
console
.
log
(
error
);
}
}
module
.
exports
=
{
addTempLayer
,
getTempAssets
};
\ No newline at end of file
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