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
Project 'adan.salazar/GeoSentinel' was moved to 'mario.chirinos/GeoSentinel'. Please update any links and bookmarks that may still have the old path.
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
const
sqlTableName
=
require
(
'./utils/sqltablename.js'
);
const
DirCache
=
require
(
'./utils/dircache.js'
)
const
cache
=
new
DirCache
(
'./cache'
);
const
sql
=
(
params
,
query
)
=>
{
...
...
@@ -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
)
{
/**
* @swagger
...
...
@@ -38,11 +64,6 @@ module.exports = function(app, pool) {
* description: name of geometry column (default 'geom')
* in: query
* 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
* type: string
* description: 'Optional filter parameters for a SQL WHERE statement.'
...
...
@@ -50,13 +71,47 @@ module.exports = function(app, pool) {
* required: false
* responses:
* 200:
* description: vector tile
* 204:
* description: no data (empty tile)
* description: boundingboxes and row counters
* content:
* 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:
* 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
)
{
req
.
query
.
geom_column
=
'geom'
;
//default
}
...
...
public/attrinfo.html
View file @
3b5cf385
...
...
@@ -252,10 +252,10 @@
if
(
response
.
ok
)
{
response
.
json
().
then
(
json
=>
{
const
div
=
document
.
querySelector
(
'#attrinfo'
);
div
.
innerHTML
=
`<b>
aantal
</b>:
${
json
[
0
].
count
}
<br>
<b>
verschillend
</b>:
${
json
[
0
].
distinct
}
<br>
<b>min</b>:
${
json
[
0
].
min
}
<br>
<b>max</b>:
${
json
[
0
].
max
}
<br>`
;
div
.
innerHTML
=
`<b>
count
</b>:
${
json
[
0
].
count
}
<br>
<b>
nr of unique values
</b>:
${
json
[
0
].
distinct
}
<br>
<b>min
imum
</b>:
${
json
[
0
].
min
}
<br>
<b>max
imum
</b>:
${
json
[
0
].
max
}
<br>`
;
})
}
})
...
...
@@ -358,7 +358,7 @@ linearTicks.min: ${linearTicks.min}, linearTicks.max: ${linearTicks.max}, linear
data
:
{
labels
:
histLabels
,
datasets
:
[{
label
:
`
aantal
${
tableName
}
`
,
label
:
`
count of
${
tableName
}
`
,
data
:
values
,
backgroundColor
:
"blue"
,
borderColor
:
"white"
,
...
...
@@ -426,7 +426,7 @@ linearTicks.min: ${linearTicks.min}, linearTicks.max: ${linearTicks.max}, linear
</script>
</head>
<body
onload=
"init()"
>
<h1>
Attribuut-informati
e
</h1>
<h1>
Attribuut-informati
on
</h1>
<h2
id=
"tablename"
></h2>
<h2
id=
"columnname"
></h2>
<div
id=
"attrinfo"
></div>
...
...
public/info.html
View file @
3b5cf385
...
...
@@ -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>'
+
layerInfo
.
map
(
item
=>
`<tr>
<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
.
srid
}
</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