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
3f99b45c
Commit
3f99b45c
authored
Aug 19, 2019
by
Anne Blankert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
guess geomtype from first non-null geom
parent
580141b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
8 deletions
+23
-8
bbox.js
bbox.js
+6
-5
tableinfo.html
public/tableinfo.html
+17
-3
No files found.
bbox.js
View file @
3f99b45c
...
@@ -29,7 +29,7 @@ const sqlEstimateBbox = (params, query, estimatedRows) => {
...
@@ -29,7 +29,7 @@ const sqlEstimateBbox = (params, query, estimatedRows) => {
const
ts
=
splitTableName
(
params
);
const
ts
=
splitTableName
(
params
);
return
`
return
`
with srid as
with srid as
(select st_srid(
${
query
.
geom_column
}
) srid
(select st_srid(
${
query
.
geom_column
}
) srid
, geometrytype(
${
query
.
geom_column
}
) geomtype
from
${
sqlTableName
(
params
.
table
)}
from
${
sqlTableName
(
params
.
table
)}
where
${
query
.
geom_column
}
is not null limit 1)
where
${
query
.
geom_column
}
is not null limit 1)
,bboxsrid as
,bboxsrid as
...
@@ -37,7 +37,7 @@ const sqlEstimateBbox = (params, query, estimatedRows) => {
...
@@ -37,7 +37,7 @@ const sqlEstimateBbox = (params, query, estimatedRows) => {
,bboxll as
,bboxll as
(select st_extent(st_transform(st_setsrid(st_envelope(bboxsrid), srid),4326)) bboxll
(select st_extent(st_transform(st_setsrid(st_envelope(bboxsrid), srid),4326)) bboxll
from bboxsrid, srid)
from bboxsrid, srid)
select
${
estimatedRows
}
as allrows,
${
estimatedRows
}
as geomrows,
bboxll,srid,bboxsrid
select
${
estimatedRows
}
as allrows,
${
estimatedRows
}
as geomrows,
bboxll,srid,bboxsrid,geomtype
from bboxll,srid,bboxsrid
from bboxll,srid,bboxsrid
`
;
`
;
}
}
...
@@ -45,7 +45,7 @@ const sqlEstimateBbox = (params, query, estimatedRows) => {
...
@@ -45,7 +45,7 @@ const sqlEstimateBbox = (params, query, estimatedRows) => {
const
sqlBbox
=
(
params
,
query
)
=>
{
const
sqlBbox
=
(
params
,
query
)
=>
{
return
`
return
`
with srid as
with srid as
(select st_srid(
${
query
.
geom_column
}
) srid
(select st_srid(
${
query
.
geom_column
}
) srid
, geometrytype(
${
query
.
geom_column
}
) geomtype
from
${
sqlTableName
(
params
.
table
)}
from
${
sqlTableName
(
params
.
table
)}
where
${
query
.
geom_column
}
is not null limit 1)
where
${
query
.
geom_column
}
is not null limit 1)
,bboxll as
,bboxll as
...
@@ -57,7 +57,7 @@ const sqlBbox = (params, query) => {
...
@@ -57,7 +57,7 @@ const sqlBbox = (params, query) => {
,bboxsrid as
,bboxsrid as
(select st_extent(st_transform(st_setsrid(st_envelope(bboxll),4326),srid)) bboxsrid
(select st_extent(st_transform(st_setsrid(st_envelope(bboxll),4326),srid)) bboxsrid
from bboxll,srid)
from bboxll,srid)
select allrows, geomrows, bboxll,srid,bboxsrid
select allrows, geomrows, bboxll,srid,bboxsrid
,geomtype
from bboxll,srid,bboxsrid
from bboxll,srid,bboxsrid
`
;
`
;
}
}
...
@@ -183,9 +183,10 @@ module.exports = function(app, pool, cache) {
...
@@ -183,9 +183,10 @@ module.exports = function(app, pool, cache) {
res
.
json
({
res
.
json
({
estimated
:
estimated
,
estimated
:
estimated
,
allrows
:
Number
(
row
.
allrows
),
allrows
:
Number
(
row
.
allrows
),
geomtype
:
row
.
geomtype
,
geomrows
:
Number
(
row
.
geomrows
),
geomrows
:
Number
(
row
.
geomrows
),
bboxll
:
row
.
bboxll
?
row
.
bboxll
.
match
(
/BOX
\((
.*
)\)
/
)[
1
].
split
(
','
).
map
(
coord
=>
coord
.
split
(
' '
).
map
(
c
=>
parseFloat
(
c
))):
null
,
srid
:
row
.
srid
,
srid
:
row
.
srid
,
bboxll
:
row
.
bboxll
?
row
.
bboxll
.
match
(
/BOX
\((
.*
)\)
/
)[
1
].
split
(
','
).
map
(
coord
=>
coord
.
split
(
' '
).
map
(
c
=>
parseFloat
(
c
))):
null
,
bboxsrid
:
row
.
bboxsrid
?
row
.
bboxsrid
.
match
(
/BOX
\((
.*
)\)
/
)[
1
].
split
(
','
).
map
(
coord
=>
coord
.
split
(
' '
).
map
(
c
=>
parseFloat
(
c
))):
null
bboxsrid
:
row
.
bboxsrid
?
row
.
bboxsrid
.
match
(
/BOX
\((
.*
)\)
/
)[
1
].
split
(
','
).
map
(
coord
=>
coord
.
split
(
' '
).
map
(
c
=>
parseFloat
(
c
))):
null
})
})
}
else
if
(
result
.
rows
.
length
===
0
)
{
}
else
if
(
result
.
rows
.
length
===
0
)
{
...
...
public/tableinfo.html
View file @
3f99b45c
...
@@ -7,11 +7,25 @@
...
@@ -7,11 +7,25 @@
<title>
Info
</title>
<title>
Info
</title>
<script>
<script>
function
addBboxllToLinks
(
bboxll
)
function
replaceGeomType
(
url
,
geomtype
)
{
if
(
geomtype
)
{
const
parts
=
url
.
split
(
'&'
)
.
map
(
part
=>
{
if
(
part
.
startsWith
(
'geomtype='
))
{
part
=
`geomtype=
${
geomtype
}
`
}
return
part
;
})
url
=
parts
.
join
(
'&'
);
}
return
url
;
}
function
addBboxllToLinks
(
bboxll
,
geomtype
)
{
{
if
(
bboxll
)
{
if
(
bboxll
)
{
document
.
querySelectorAll
(
'#columns > li > a'
)
document
.
querySelectorAll
(
'#columns > li > a'
)
.
forEach
(
a
=>
(
a
.
setAttribute
(
'href'
,
a
.
getAttribute
(
'href'
)
+
'&bboxll='
+
JSON
.
stringify
(
bboxll
))))
.
forEach
(
a
=>
(
a
.
setAttribute
(
'href'
,
replaceGeomType
(
a
.
getAttribute
(
'href'
),
geomtype
)
+
'&bboxll='
+
JSON
.
stringify
(
bboxll
))))
}
}
}
}
...
@@ -37,7 +51,7 @@
...
@@ -37,7 +51,7 @@
const
bbox
=
document
.
querySelector
(
'#bbox'
);
const
bbox
=
document
.
querySelector
(
'#bbox'
);
if
(
response
.
ok
)
{
if
(
response
.
ok
)
{
response
.
json
().
then
(
json
=>
{
response
.
json
().
then
(
json
=>
{
addBboxllToLinks
(
json
.
bboxll
);
addBboxllToLinks
(
json
.
bboxll
,
json
.
geomtype
);
bbox
.
innerHTML
=
`number of rows:
${
json
.
allrows
}
<br>
bbox
.
innerHTML
=
`number of rows:
${
json
.
allrows
}
<br>
number of geometries:
${
json
.
geomrows
}
<br>
number of geometries:
${
json
.
geomrows
}
<br>
srid: EPSG:
${
json
.
srid
}
<br>
srid: EPSG:
${
json
.
srid
}
<br>
...
...
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