Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Polygon Query on Raster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FACT
FACT Utils
Polygon Query on Raster
Commits
c9a619fc
Commit
c9a619fc
authored
5 months ago
by
Riccardo Boero
Browse files
Options
Downloads
Patches
Plain Diff
Reverted directory routing logic
parent
a6ea57fa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#2009
failed
5 months ago
Stage: test
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
polygonqueryonraster/app.py
+4
-29
4 additions, 29 deletions
polygonqueryonraster/app.py
with
4 additions
and
29 deletions
polygonqueryonraster/app.py
+
4
−
29
View file @
c9a619fc
...
@@ -50,40 +50,15 @@ class GeoTIFFService:
...
@@ -50,40 +50,15 @@ class GeoTIFFService:
"""
"""
Sets up the Flask routes for the service. It creates a default route for the root directory
Sets up the Flask routes for the service. It creates a default route for the root directory
and additional routes for each subdirectory within the GeoTIFF tiles directory.
and additional routes for each subdirectory within the GeoTIFF tiles directory.
Each route corresponds to a POST endpoint for submitting geospatial queries.
Each route corresponds to a POST endpoint for submitting geospatial queries.
If the directory doesn
'
t exist or contains no subdirectories, it logs a message.
This method ensures the directory exists and handles missing or empty subdirectories gracefully.
The root directory (
'
/
'
) will always have a route created, while additional routes
are created dynamically based on the presence of subdirectories in the specified GeoTIFF directory.
Raises:
ValueError: If the main directory does not exist.
"""
"""
# Create a route for the root directory (default route)
# Create a route for the root directory (default route)
self
.
create_route
(
'
/
'
,
self
.
directory
)
self
.
create_route
(
'
/
'
,
self
.
directory
)
# Ensure the directory exists before attempting to find subdirectories
# Discover and create routes for subdirectories
if
not
os
.
path
.
exists
(
self
.
directory
):
for
subdir
in
next
(
os
.
walk
(
self
.
directory
))[
1
]:
raise
ValueError
(
f
"
Directory
{
self
.
directory
}
does not exist.
"
)
subdir_path
=
os
.
path
.
join
(
self
.
directory
,
subdir
)
self
.
create_route
(
f
'
/
{
subdir
}
'
,
subdir_path
)
# Discover and create routes for subdirectories (if any exist)
try
:
subdirs
=
next
(
os
.
walk
(
self
.
directory
))[
1
]
# Extract subdirectories from the directory
except
StopIteration
:
subdirs
=
[]
# If no subdirectories are found, log a message (useful for debugging)
if
not
subdirs
:
print
(
f
"
No subdirectories found in
{
self
.
directory
}
"
)
else
:
for
subdir
in
subdirs
:
subdir_path
=
os
.
path
.
join
(
self
.
directory
,
subdir
)
self
.
create_route
(
f
'
/
{
subdir
}
'
,
subdir_path
)
def
create_route
(
self
,
route_suffix
,
directory
):
def
create_route
(
self
,
route_suffix
,
directory
):
"""
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment