Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fordecyt_2019
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rodrigo Tapia-McClung
fordecyt_2019
Commits
3b5cf385
Commit
3b5cf385
authored
Aug 16, 2019
by
Anne Blankert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cache bbox,translate to english,support views
parent
0a9d9246
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
16 deletions
+71
-16
bbox.js
bbox.js
+64
-9
attrinfo.html
public/attrinfo.html
+6
-6
info.html
public/info.html
+1
-1
No files found.
bbox.js
View file @
3b5cf385
// based on https://raw.githubusercontent.com/tobinbradley/dirt-simple-postgis-http-api/master/routes/bbox.js
// based on https://raw.githubusercontent.com/tobinbradley/dirt-simple-postgis-http-api/master/routes/bbox.js
const
sqlTableName
=
require
(
'./utils/sqltablename.js'
);
const
sqlTableName
=
require
(
'./utils/sqltablename.js'
);
const
DirCache
=
require
(
'./utils/dircache.js'
)
const
cache
=
new
DirCache
(
'./cache'
);
const
sql
=
(
params
,
query
)
=>
{
const
sql
=
(
params
,
query
)
=>
{
...
@@ -18,6 +20,30 @@ select allrows, geomrows, bboxll,srid,bboxsrid from bboxll,srid,bboxsrid
...
@@ -18,6 +20,30 @@ select allrows, geomrows, bboxll,srid,bboxsrid from bboxll,srid,bboxsrid
`
`
}
}
let
cacheMiddleware
=
async
(
req
,
res
,
next
)
=>
{
const
cacheDir
=
`
${
req
.
params
.
table
}
/bbox`
const
key
=
((
req
.
query
.
geom_column
?
req
.
query
.
geom_column
:
'geom'
)
+
(
req
.
query
.
columns
?
'_'
+
req
.
query
.
columns
:
''
)
+
(
req
.
query
.
filter
?
'_'
+
req
.
query
.
filter
:
''
))
.
replace
(
/
[\W]
+/g
,
'_'
);
const
bbox
=
await
cache
.
getCachedFile
(
cacheDir
,
key
);
if
(
bbox
)
{
console
.
log
(
`bbox cache hit for
${
cacheDir
}
?
${
key
}
`
);
res
.
header
(
'Content-Type'
,
'application/json'
).
send
(
bbox
);
return
;
}
else
{
res
.
sendResponse
=
res
.
send
;
res
.
send
=
(
body
)
=>
{
if
(
res
.
statusCode
>=
200
&&
res
.
statusCode
<
300
)
{
cache
.
setCachedFile
(
cacheDir
,
key
,
body
);
}
res
.
sendResponse
(
body
);
}
next
();
}
}
module
.
exports
=
function
(
app
,
pool
)
{
module
.
exports
=
function
(
app
,
pool
)
{
/**
/**
* @swagger
* @swagger
...
@@ -38,11 +64,6 @@ module.exports = function(app, pool) {
...
@@ -38,11 +64,6 @@ module.exports = function(app, pool) {
* description: name of geometry column (default 'geom')
* description: name of geometry column (default 'geom')
* in: query
* in: query
* required: false
* required: false
* - name: strid
* description: 'The SRID for the returned centroid. The default is <em>4326</em> WGS84 Lat/Lng.'
* in: query
* required: false
* type: integer
* - name: filter
* - name: filter
* type: string
* type: string
* description: 'Optional filter parameters for a SQL WHERE statement.'
* description: 'Optional filter parameters for a SQL WHERE statement.'
...
@@ -50,13 +71,47 @@ module.exports = function(app, pool) {
...
@@ -50,13 +71,47 @@ module.exports = function(app, pool) {
* required: false
* required: false
* responses:
* responses:
* 200:
* 200:
* description: vector tile
* description: boundingboxes and row counters
* 204:
* content:
* description: no data (empty tile)
* application/json
* schema:
* type: object
* properties:
* allrows:
* type: integer
* description: number of rows in table
* geomrows:
* type: integer
* description: number of non-null geometries in table
* bboxll:
* description: boundingbox of geometries defined in latitude and longitude
* type: array
* minItems: 2
* maxItems: 2
* items:
* type: array
* minItems: 2
* maxItems: 2
* items:
* type: number
* srid:
* type: integer
* description: id of spatial reference system (EPSG code) used by geometries
* bboxsrid:
* description: boundingbox of geometries defined using geometry srid
* type: array
* minItems: 2
* maxItems: 2
* items:
* type: array
* minItems: 2
* maxItems: 2
* items:
* type: number
* 422:
* 422:
* description: invalid datasource or columnname
* description: invalid datasource or columnname
*/
*/
app
.
get
(
'/api/bbox/:table'
,
async
(
req
,
res
)
=>
{
app
.
get
(
'/api/bbox/:table'
,
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
}
}
...
...
public/attrinfo.html
View file @
3b5cf385
...
@@ -252,10 +252,10 @@
...
@@ -252,10 +252,10 @@
if
(
response
.
ok
)
{
if
(
response
.
ok
)
{
response
.
json
().
then
(
json
=>
{
response
.
json
().
then
(
json
=>
{
const
div
=
document
.
querySelector
(
'#attrinfo'
);
const
div
=
document
.
querySelector
(
'#attrinfo'
);
div
.
innerHTML
=
`<b>
aantal
</b>:
${
json
[
0
].
count
}
<br>
div
.
innerHTML
=
`<b>
count
</b>:
${
json
[
0
].
count
}
<br>
<b>
verschillend
</b>:
${
json
[
0
].
distinct
}
<br>
<b>
nr of unique values
</b>:
${
json
[
0
].
distinct
}
<br>
<b>min</b>:
${
json
[
0
].
min
}
<br>
<b>min
imum
</b>:
${
json
[
0
].
min
}
<br>
<b>max</b>:
${
json
[
0
].
max
}
<br>`
;
<b>max
imum
</b>:
${
json
[
0
].
max
}
<br>`
;
})
})
}
}
})
})
...
@@ -358,7 +358,7 @@ linearTicks.min: ${linearTicks.min}, linearTicks.max: ${linearTicks.max}, linear
...
@@ -358,7 +358,7 @@ linearTicks.min: ${linearTicks.min}, linearTicks.max: ${linearTicks.max}, linear
data
:
{
data
:
{
labels
:
histLabels
,
labels
:
histLabels
,
datasets
:
[{
datasets
:
[{
label
:
`
aantal
${
tableName
}
`
,
label
:
`
count of
${
tableName
}
`
,
data
:
values
,
data
:
values
,
backgroundColor
:
"blue"
,
backgroundColor
:
"blue"
,
borderColor
:
"white"
,
borderColor
:
"white"
,
...
@@ -426,7 +426,7 @@ linearTicks.min: ${linearTicks.min}, linearTicks.max: ${linearTicks.max}, linear
...
@@ -426,7 +426,7 @@ linearTicks.min: ${linearTicks.min}, linearTicks.max: ${linearTicks.max}, linear
</script>
</script>
</head>
</head>
<body
onload=
"init()"
>
<body
onload=
"init()"
>
<h1>
Attribuut-informati
e
</h1>
<h1>
Attribuut-informati
on
</h1>
<h2
id=
"tablename"
></h2>
<h2
id=
"tablename"
></h2>
<h2
id=
"columnname"
></h2>
<h2
id=
"columnname"
></h2>
<div
id=
"attrinfo"
></div>
<div
id=
"attrinfo"
></div>
...
...
public/info.html
View file @
3b5cf385
...
@@ -67,7 +67,7 @@
...
@@ -67,7 +67,7 @@
table
.
innerHTML
=
'<tr><th>schema</th><th>name</th><th>geom_column</th><th>srid</th><th>geom_type</th><th>dim</th><th>count</th></tr>'
+
table
.
innerHTML
=
'<tr><th>schema</th><th>name</th><th>geom_column</th><th>srid</th><th>geom_type</th><th>dim</th><th>count</th></tr>'
+
layerInfo
.
map
(
item
=>
`<tr>
layerInfo
.
map
(
item
=>
`<tr>
<td>
${
item
.
f_table_schema
}
</td>
<td>
${
item
.
f_table_schema
}
</td>
<td>
${
Number
(
item
.
estimated_rows
)?
`<a href="tableinfo.html?table=
${
item
.
f_table_schema
}
.
${
item
.
f_table_name
}
&geom_column=
${
item
.
f_geometry_column
}
&srid=
${
item
.
srid
}
&geomtype=
${
item
.
type
}
&dimensions=
${
item
.
coord_dimension
}
&estimated_rows=
${
item
.
estimated_rows
}
">
${
item
.
f_table_name
}
</a>`
:
`
${
item
.
f_table_name
}
`
}
</td>
<td>
<a href="tableinfo.html?table=
${
item
.
f_table_schema
}
.
${
item
.
f_table_name
}
&geom_column=
${
item
.
f_geometry_column
}
&srid=
${
item
.
srid
}
&geomtype=
${
item
.
type
}
&dimensions=
${
item
.
coord_dimension
}
&estimated_rows=
${
item
.
estimated_rows
}
">
${
item
.
f_table_name
}
</a>
</td>
<td>
${
item
.
f_geometry_column
}
</td>
<td>
${
item
.
f_geometry_column
}
</td>
<td>
${
item
.
srid
}
</td>
<td>
${
item
.
srid
}
</td>
<td>
${
item
.
type
}
</td>
<td>
${
item
.
type
}
</td>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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