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
120af7fb
Commit
120af7fb
authored
Aug 15, 2019
by
Anne Blankert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle zero result, zoom map to bbox if available
parent
d53a469f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
7 deletions
+31
-7
bbox.js
bbox.js
+9
-1
attrinfo.html
public/attrinfo.html
+8
-2
info.html
public/info.html
+1
-1
tableinfo.html
public/tableinfo.html
+13
-3
No files found.
bbox.js
View file @
120af7fb
...
...
@@ -75,8 +75,16 @@ module.exports = function(app, pool) {
srid
:
row
.
srid
,
bboxsrid
:
row
.
bboxsrid
?
row
.
bboxsrid
.
match
(
/BOX
\((
.*
)\)
/
)[
1
].
split
(
','
).
map
(
coord
=>
coord
.
split
(
' '
).
map
(
c
=>
parseFloat
(
c
))):
null
})
}
else
if
(
result
.
rows
.
length
===
0
)
{
res
.
json
({
allrows
:
0
,
geomrows
:
0
,
bboxll
:
null
,
srid
:
0
,
bboxsrid
:
null
})
}
else
{
throw
(
new
Error
(
'bbox query
did not retur
n 1 row'
));
throw
(
new
Error
(
'bbox query
returned more tha
n 1 row'
));
}
}
catch
(
err
)
{
console
.
log
(
err
);
...
...
public/attrinfo.html
View file @
120af7fb
...
...
@@ -73,7 +73,7 @@
function
initMap
()
{
map
=
new
mapboxgl
.
Map
(
{
const
mapDefinition
=
{
container
:
'map'
,
"style"
:
{
"version"
:
8
,
...
...
@@ -98,7 +98,13 @@
}
]
}
});
}
const
urlParams
=
new
URLSearchParams
(
window
.
location
.
search
);
const
bboxll
=
urlParams
.
get
(
'bboxll'
);
if
(
bboxll
)
{
mapDefinition
.
bounds
=
JSON
.
parse
(
bboxll
);
}
map
=
new
mapboxgl
.
Map
(
mapDefinition
);
map
.
on
(
'mousemove'
,
function
(
e
)
{
var
features
=
map
.
queryRenderedFeatures
(
e
.
point
).
map
(
function
(
feature
){
return
{
layer
:
{
id
:
feature
.
layer
.
id
,
type
:
feature
.
layer
.
type
},
properties
:(
feature
.
properties
)};});
document
.
getElementById
(
'info'
).
innerHTML
=
JSON
.
stringify
(
features
.
map
(
feature
=>
feature
.
properties
),
null
,
2
);
...
...
public/info.html
View file @
120af7fb
...
...
@@ -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>
<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>
${
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>
${
item
.
f_geometry_column
}
</td>
<td>
${
item
.
srid
}
</td>
<td>
${
item
.
type
}
</td>
...
...
public/tableinfo.html
View file @
120af7fb
...
...
@@ -7,11 +7,20 @@
<title>
Info
</title>
<script>
function
addBboxllToLinks
(
bboxll
)
{
if
(
bboxll
)
{
document
.
querySelectorAll
(
'#columns > li > a'
)
.
forEach
(
a
=>
(
a
.
setAttribute
(
'href'
,
a
.
getAttribute
(
'href'
)
+
'&bboxll='
+
JSON
.
stringify
(
bboxll
))))
}
}
function
init
()
{
const
urlParams
=
new
URLSearchParams
(
window
.
location
.
search
);
const
fullTableName
=
urlParams
.
get
(
'table'
);
const
geomType
=
urlParams
.
get
(
'geomtype'
);
const
geomcolumn
=
urlParams
.
get
(
'geom_column'
)
const
geomcolumn
=
urlParams
.
get
(
'geom_column'
);
let
bboxll
=
null
;
document
.
querySelector
(
'#tablename'
).
innerHTML
=
fullTableName
;
const
parts
=
fullTableName
.
split
(
'.'
);
const
tableName
=
(
parts
.
length
>
1
)
?
parts
[
1
]
:
parts
[
0
];
...
...
@@ -35,11 +44,12 @@
const
bbox
=
document
.
querySelector
(
'#bbox'
);
if
(
response
.
ok
)
{
response
.
json
().
then
(
json
=>
{
addBboxllToLinks
(
json
.
bboxll
);
bbox
.
innerHTML
=
`number of rows:
${
json
.
allrows
}
<br>
number of geometries:
${
json
.
geomrows
}
<br>
srid: EPSG:
${
json
.
srid
}
<br>
bbox lon/lat:
sw:
${
json
.
bboxll
[
0
][
0
]}
,
${
json
.
bboxll
[
0
][
1
]}
, ne:
${
json
.
bboxll
[
1
][
0
]}
,
${
json
.
bboxll
[
1
][
1
]
}
<br>
bbox (EPSG:
${
json
.
srid
}
):
ll:
${
json
.
bboxsrid
[
0
][
0
]}
,
${
json
.
bboxsrid
[
0
][
1
]}
, tr:
${
json
.
bboxsrid
[
1
][
0
]}
,
${
json
.
bboxsrid
[
1
][
1
]
}
<br>
bbox lon/lat:
${
json
.
bboxll
?
`sw:
${
json
.
bboxll
[
0
][
0
]}
,
${
json
.
bboxll
[
0
][
1
]}
, ne:
${
json
.
bboxll
[
1
][
0
]}
,
${
json
.
bboxll
[
1
][
1
]}
`
:
'not defined'
}
<br>
bbox (EPSG:
${
json
.
srid
}
):
${
json
.
srid
?
`ll:
${
json
.
bboxsrid
[
0
][
0
]}
,
${
json
.
bboxsrid
[
0
][
1
]}
, tr:
${
json
.
bboxsrid
[
1
][
0
]}
,
${
json
.
bboxsrid
[
1
][
1
]}
`
:
'not defined'
}
<br>
`
})
}
else
{
...
...
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