forked from ifgi/optimetaPortal
-
Notifications
You must be signed in to change notification settings - Fork 0
Download GeoJSON and GeoPackage #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nuest
merged 31 commits into
main
from
enhancement/Download_all_geometries_and_metadata_as_GeoJSON_61
May 15, 2025
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
ace5ee0
Changes for testing warnings with js
BharatVe e987387
Update APi to API&Data
BharatVe 7c145c0
Merge branch 'main' into enhancement/Download_all_geometries_and_meta…
nuest ba487d4
Addition of GeoPackage + Dynamic Size Calculation ( GeoPackage needs …
af50835
Upadted implemntation for Geopackage download
83cc473
Updated test file
699e78b
Merge remote-tracking branch 'origin/main' into enhancement/Download_…
1cc2193
Merge remote-tracking branch 'origin/main' into enhancement/Download_…
b21233d
update test( with pygdal)
823ad18
Update test_geo_data.py
BharatVe bcec9a1
Update requirements.txt
BharatVe aca2962
updated views.py, requirements.txt using fiona and shapely (vs osgeo)
7869a82
Changes for updated pull request. (Work in progress)
17965b0
Update tasks.py, minor updates
BharatVe 988b5e1
Completed implemeentation with recommeded changes(final check needed)
c4cc194
Minor corrections tasks.py
BharatVe f135ef3
updated test
052c42f
Update data.html
BharatVe acfe536
Updated data message
BharatVe 30cb5f1
now to timezone (Fix unittest issue)
9d24d63
add logos and colours to README, closes #33
nuest fc02e9b
Updated scripts- changed time fomats, modified test added humanize time
daed800
Merge branch 'main' into enhancement/Download_all_geometries_and_meta…
BharatVe a9f7a8d
fixed tests, removed fiona and updated requirements.txt
939e0b8
install GDAL package form PyPI
nuest e7d9701
fix test
nuest a2f829f
Updated links, changed URLs, corrected footer, added automated cache …
479e10e
Updated apps and tests
0e4b16b
Update apps.py
BharatVe 6c072ed
Use Humanize, added checks for link validity.
100dc2a
added humanize
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,39 @@ | ||
| import logging | ||
| from django.apps import AppConfig | ||
| from django.db.models.signals import post_migrate | ||
| from django.conf import settings | ||
| from django.utils import timezone | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| def schedule_data_dump(sender, **kwargs): | ||
| from django_q.models import Schedule | ||
| from django_q.tasks import schedule | ||
|
|
||
| func_name = "publications.tasks.regenerate_geopackage_cache" | ||
| if not Schedule.objects.filter(func=func_name).exists(): | ||
| schedule( | ||
| func_name, | ||
| schedule_type="I", | ||
| minutes=settings.DATA_DUMP_INTERVAL_HOURS * 60, | ||
| next_run=timezone.now(), | ||
| repeats=-1, | ||
| ) | ||
| logger.info( | ||
| "Scheduled data‐dump task '%s' every %d hours", | ||
| func_name, | ||
| settings.DATA_DUMP_INTERVAL_HOURS, | ||
| ) | ||
|
|
||
| class PublicationsConfig(AppConfig): | ||
| default_auto_field = 'django.db.models.BigAutoField' | ||
| name = 'publications' | ||
| name = "publications" | ||
| default_auto_field = "django.db.models.BigAutoField" | ||
|
|
||
| def ready(self): | ||
| # Implicitly connect signal handlers decorated with @receiver. | ||
| from . import signals | ||
| import publications.signals | ||
| post_migrate.connect( | ||
| schedule_data_dump, | ||
| sender=self, | ||
| weak=False, | ||
| dispatch_uid="publications.schedule_data_dump", | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| from django.core.management.base import BaseCommand | ||
| from django_q.tasks import schedule | ||
| from django_q.models import Schedule | ||
|
|
||
| class Command(BaseCommand): | ||
| help = "Schedule the GeoJSON regeneration task every 6 hours." | ||
|
|
||
| def handle(self, *args, **options): | ||
| func_name = 'publications.tasks.regenerate_geojson_cache' | ||
| if not Schedule.objects.filter(func=func_name).exists(): | ||
| schedule( | ||
| func_name, | ||
| schedule_type='I', # interval | ||
| minutes=360, # every 6 hours | ||
| repeats=-1 | ||
| ) | ||
| self.stdout.write(self.style.SUCCESS("Scheduled GeoJSON regeneration every 6h.")) | ||
| else: | ||
| self.stdout.write("GeoJSON regeneration already scheduled.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,77 @@ | ||
| {% extends "main.html" %} | ||
| {% load optimap_extras humanize %} | ||
| {% block title %}Data & API | {% endblock %} | ||
|
|
||
| {% load optimap_extras %} | ||
| {% block content %} | ||
| <div class="row justify-content-center"> | ||
| <div class="col-md-6 py-5"> | ||
|
|
||
| {% block title %}API | {% endblock %} | ||
| <h1 class="mb-4">OPTIMAP Data & API Access</h1> | ||
| <p class="lead"> | ||
| All publication metadata published in OPTIMAP is licensed under a Creative Commons Zero | ||
| (<a href="https://creativecommons.org/publicdomain/zero/1.0/" target="_blank">CC-0</a>) license. | ||
| </p> | ||
|
|
||
| {% block content %} | ||
| <h2 class="py-2">API Endpoint</h2> | ||
| <p> | ||
| The API endpoint is <b>{{ site|addstr:"/api"|urlize }}</b>. Visit in your browser for | ||
| an interactive interface. | ||
| </p> | ||
|
|
||
| <div class="row justify-content-center"> | ||
| <div class="col-4 py-5 text-wrap"> | ||
| <h1 class="py-2">OPTIMAP data access</h1> | ||
| <p> | ||
| Query all publications via: | ||
| <pre class="bg-light p-2"> | ||
| curl -X GET {{ site|addstr:"/api" }}/api/optimap/ | jq | ||
| </pre> | ||
| </p> | ||
|
|
||
| <p class="lead">All publication metadata published in OPTIMAP is licensed under a Create Commons Zero (<a href='https://creativecommons.org/publicdomain/zero/1.0/'>CC-0</a>) license.</p> | ||
| <h2 class="py-2">OpenAPI Schema</h2> | ||
| <p> | ||
| Download the OpenAPI spec at <b>{{ site|addstr:"/api/schema"|urlize }}</b>. | ||
| </p> | ||
|
|
||
| <h2 class="py-2">API endpoint</h2> | ||
| <p>The API endpoint is <b>{{ site|addstr:"/api"|urlize }}</b>. Visit the URL in your browser to get an interactive interface for exploring the API.</p> | ||
| <h2 class="py-2">OpenAPI UI</h2> | ||
| <p> | ||
| Explore interactively at <b>{{ site|addstr:"/api/schema/ui"|urlize }}</b>. | ||
| </p> | ||
|
|
||
| <p>You can query all publications with the following request (using <a href="https://stedolan.github.io/jq/" title="Link to jq project website"><code>jq</code></a> for formatting of the response):</p> | ||
| <pre> | ||
| curl -X GET {{ site|addstr:"/api" }}/api/publications/ | jq | ||
| </pre> | ||
| <hr> | ||
|
|
||
| <h2 class="py-2">OpenAPI schema</h2> | ||
| <p>You can download an OpenAPI specification of the api at <b>{{ site|addstr:"/api/schema"|urlize }}</b>.</p> | ||
| <h2 class="py-2">Download Publication Data</h2> | ||
| <ul class="list-unstyled mb-4"> | ||
| {% if geojson_size %} | ||
| <li class="mb-3"> | ||
| <div class="d-flex align-items-center"> | ||
| <a class="btn btn-primary btn-sm" href="{% url 'optimap:download_geojson' %}"> | ||
| Download GeoJSON | ||
| </a> | ||
| (<a href="https://geojson.org/" target="_blank" class="ms-2 small">GeoJSON spec</a>) | ||
| </div> | ||
| <div class="small text-muted mt-1"> | ||
| File size: {{ geojson_size }} | ||
| </div> | ||
| </li> | ||
| {% endif %} | ||
|
|
||
| <h2 class="py-2">OpenAPI user interface</h2> | ||
| <p>You can explore the API with an interactive user intreface built based on the OpenAPI schema at <b>{{ site|addstr:"/api/schema/ui"|urlize }}</b>.</p> | ||
| {% if geopackage_size %} | ||
| <li> | ||
| <div class="d-flex align-items-center"> | ||
| <a class="btn btn-primary btn-sm" href="{% url 'optimap:download_geopackage' %}"> | ||
| Download GeoPackage | ||
| </a> | ||
| (<a href="https://www.geopackage.org/" target="_blank" class="ms-2 small">GeoPackage spec</a>) | ||
| </div> | ||
| <div class="small text-muted mt-1"> | ||
| File size: {{ geopackage_size }} | ||
| </div> | ||
| </li> | ||
| {% endif %} | ||
| </ul> | ||
| <p class="small text-muted text-center mb-0"> | ||
| Data dumps run every {{ interval }} hour{{ interval|pluralize }}.<br> | ||
| Last updated: {{ last_updated|naturaltime }} | ||
| </p> | ||
|
|
||
| </div> | ||
| </div> | ||
|
|
||
| {% endblock %} | ||
| {% endblock %} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.