forked from ifgi/optimetaPortal
-
Notifications
You must be signed in to change notification settings - Fork 0
Features/feeds oceans continents #157
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
Merged
Changes from 12 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
062b432
Added the flow for feeds of continents and oceans
uxairibrar f646ca1
Adding test data for publication
uxairibrar e1301a2
Added different formats
uxairibrar 863b3e6
Merge remote-tracking branch 'origin/main' into features/feeds_oceans…
uxairibrar a88deeb
Updated PR Issues
uxairibrar 1be5672
Merge remote-tracking branch 'origin/main' into features/feeds_oceans…
uxairibrar 95d1829
Merge conflicting 0003 migrations in publications
uxairibrar 9598446
Updated the Readme
uxairibrar cd9ca95
Add comment about manualy data source closing
nuest dab5e56
Discard changes to publications/templates/footer.html
nuest d2b1b30
Re-add feeds without formatting to footer.html
nuest 4feeae1
Remove formatting only changes
nuest ca2d1af
Updated URL and Test File
uxairibrar e7c70ef
Updated Path
uxairibrar 6615e70
Merge branch 'main' into features/feeds_oceans_continents
nuest a95043e
reset migrations and update fixture
nuest 2ce23d6
reformat feeds HTML page
nuest 50b47df
include load_global_regions in README and only download unless existing
nuest a5ff73a
remove unused import
nuest f930f0c
rename test file and add fix most tests for feeds
nuest f59ea74
add admin UI for GlobalRegions
nuest 1416e16
ignore cached global region geometries file
nuest 6b16f9c
Resolved Global_Feeds Issue
uxairibrar 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,273 @@ | ||
| [ | ||
| { | ||
| "model": "publications.publication", | ||
| "pk": 4, | ||
| "fields": { | ||
| "status": "p", | ||
| "title": "First Africa Publication", | ||
| "abstract": "Sample publication covering a cluster of ca. 5–6 major cities in West Africa.", | ||
| "publicationDate": "2025-05-29", | ||
| "doi": "10.5555/africa1", | ||
| "url": null, | ||
| "geometry": "SRID=4326;GEOMETRYCOLLECTION(POLYGON ((3.0000 4.5000, 9.0000 4.5000, 9.0000 12.5000, 3.0000 12.5000, 3.0000 4.5000)))", | ||
| "creationDate": "2025-05-29T12:00:00Z", | ||
| "lastUpdate": "2025-05-29T12:00:00Z", | ||
| "source": "Africa Test Journal", | ||
| "timeperiod_startdate": "[\"2025-01-01\"]", | ||
| "timeperiod_enddate": "[\"2025-12-31\"]", | ||
| "provenance": "Manually added for Africa multi-city test." | ||
| } | ||
| }, | ||
|
|
||
| { | ||
| "model": "publications.publication", | ||
| "pk": 5, | ||
| "fields": { | ||
| "status": "p", | ||
| "title": "First Asia Publication", | ||
| "abstract": "Sample publication covering a cluster of ca. 5–6 major cities in the Beijing area.", | ||
| "publicationDate": "2025-05-29", | ||
| "doi": "10.5555/asia1", | ||
| "url": null, | ||
| "geometry": "SRID=4326;GEOMETRYCOLLECTION(POLYGON ((116.0000 39.0000, 118.0000 39.0000, 118.0000 41.0000, 116.0000 41.0000, 116.0000 39.0000)))", | ||
| "creationDate": "2025-05-29T12:00:00Z", | ||
| "lastUpdate": "2025-05-29T12:00:00Z", | ||
| "source": "Asia Test Journal", | ||
| "timeperiod_startdate": "[\"2025-01-01\"]", | ||
| "timeperiod_enddate": "[\"2025-12-31\"]", | ||
| "provenance": "Manually added for Asia multi-city test." | ||
| } | ||
| }, | ||
|
|
||
| { | ||
| "model": "publications.publication", | ||
| "pk": 6, | ||
| "fields": { | ||
| "status": "p", | ||
| "title": "First Europe Publication", | ||
| "abstract": "Sample publication covering a cluster of ca. 5–6 major cities around Berlin.", | ||
| "publicationDate": "2025-05-29", | ||
| "doi": "10.5555/europe1", | ||
| "url": null, | ||
| "geometry": "SRID=4326;GEOMETRYCOLLECTION(POLYGON ((13.1300 52.3700, 13.6800 52.3700, 13.6800 52.6700, 13.1300 52.6700, 13.1300 52.3700)))", | ||
| "creationDate": "2025-05-29T12:00:00Z", | ||
| "lastUpdate": "2025-05-29T12:00:00Z", | ||
| "source": "Europe Test Journal", | ||
| "timeperiod_startdate": "[\"2025-01-01\"]", | ||
| "timeperiod_enddate": "[\"2025-12-31\"]", | ||
| "provenance": "Manually added for Europe multi-city test." | ||
| } | ||
| }, | ||
|
|
||
| { | ||
| "model": "publications.publication", | ||
| "pk": 7, | ||
| "fields": { | ||
| "status": "p", | ||
| "title": "First North America Publication", | ||
| "abstract": "Sample publication covering a cluster of ca. 5–6 major cities around New York City.", | ||
| "publicationDate": "2025-05-29", | ||
| "doi": "10.5555/northamerica1", | ||
| "url": null, | ||
| "geometry": "SRID=4326;GEOMETRYCOLLECTION(POLYGON ((-74.1600 40.5400, -73.8100 40.5400, -73.8100 40.9400, -74.1600 40.9400, -74.1600 40.5400)))", | ||
| "creationDate": "2025-05-29T12:00:00Z", | ||
| "lastUpdate": "2025-05-29T12:00:00Z", | ||
| "source": "North America Test Journal", | ||
| "timeperiod_startdate": "[\"2025-01-01\"]", | ||
| "timeperiod_enddate": "[\"2025-12-31\"]", | ||
| "provenance": "Manually added for North America multi-city test." | ||
| } | ||
| }, | ||
|
|
||
| { | ||
| "model": "publications.publication", | ||
| "pk": 8, | ||
| "fields": { | ||
| "status": "p", | ||
| "title": "First South America Publication", | ||
| "abstract": "Sample publication covering a cluster of ca. 5–6 major cities around São Paulo.", | ||
| "publicationDate": "2025-05-29", | ||
| "doi": "10.5555/southamerica1", | ||
| "url": null, | ||
| "geometry": "SRID=4326;GEOMETRYCOLLECTION(POLYGON ((-47.0000 -23.8000, -46.2500 -23.8000, -46.2500 -23.3000, -47.0000 -23.3000, -47.0000 -23.8000)))", | ||
| "creationDate": "2025-05-29T12:00:00Z", | ||
| "lastUpdate": "2025-05-29T12:00:00Z", | ||
| "source": "South America Test Journal", | ||
| "timeperiod_startdate": "[\"2025-01-01\"]", | ||
| "timeperiod_enddate": "[\"2025-12-31\"]", | ||
| "provenance": "Manually added for South America multi-city test." | ||
| } | ||
| }, | ||
|
|
||
| { | ||
| "model": "publications.publication", | ||
| "pk": 9, | ||
| "fields": { | ||
| "status": "p", | ||
| "title": "First Antarctica Publication", | ||
| "abstract": "Sample publication located in the small site-sized polygon around McMurdo Station.", | ||
| "publicationDate": "2025-05-29", | ||
| "doi": "10.5555/antarctica1", | ||
| "url": null, | ||
| "geometry": "SRID=4326;GEOMETRYCOLLECTION(POLYGON ((166.60 -77.90, 166.70 -77.90, 166.70 -77.80, 166.60 -77.80, 166.60 -77.90)))", | ||
| "creationDate": "2025-05-29T12:00:00Z", | ||
| "lastUpdate": "2025-05-29T12:00:00Z", | ||
| "source": "Antarctica Test Journal", | ||
| "timeperiod_startdate": "[\"2025-01-01\"]", | ||
| "timeperiod_enddate": "[\"2025-12-31\"]", | ||
| "provenance": "Manually added for Antarctica site test." | ||
| } | ||
| }, | ||
| { | ||
| "model": "publications.publication", | ||
| "pk": 10, | ||
| "fields": { | ||
| "status": "p", | ||
| "title": "First Australia Publication", | ||
| "abstract": "Sample publication located in the small city-sized polygon around central Sydney.", | ||
| "publicationDate": "2025-05-29", | ||
| "doi": "10.5555/australia1", | ||
| "url": null, | ||
| "geometry": "SRID=4326;GEOMETRYCOLLECTION(POLYGON ((151.20 -33.90, 151.30 -33.90, 151.30 -33.80, 151.20 -33.80, 151.20 -33.90)))", | ||
| "creationDate": "2025-05-29T12:00:00Z", | ||
| "lastUpdate": "2025-05-29T12:00:00Z", | ||
| "source": "Australia Test Journal", | ||
| "timeperiod_startdate": "[\"2025-01-01\"]", | ||
| "timeperiod_enddate": "[\"2025-12-31\"]", | ||
| "provenance": "Manually added for Australia city test." | ||
| } | ||
| }, | ||
| { | ||
| "model": "publications.publication", | ||
| "pk": 11, | ||
| "fields": { | ||
| "status": "p", | ||
| "title": "First South Atlantic Ocean Publication", | ||
| "abstract": "Sample publication covering a small survey area in the South Atlantic Ocean.", | ||
| "publicationDate": "2025-05-29", | ||
| "doi": "10.5555/southatlantic1", | ||
| "url": null, | ||
| "geometry": "SRID=4326;GEOMETRYCOLLECTION(POLYGON ((-25.0000 -25.0000, -15.0000 -25.0000, -15.0000 -15.0000, -25.0000 -15.0000, -25.0000 -25.0000)))", | ||
| "creationDate": "2025-05-29T12:00:00Z", | ||
| "lastUpdate": "2025-05-29T12:00:00Z", | ||
| "source": "Marine Test Journal", | ||
| "timeperiod_startdate": "[\"2025-01-01\"]", | ||
| "timeperiod_enddate": "[\"2025-12-31\"]", | ||
| "provenance": "Manually added for South Atlantic Ocean small‐area test." | ||
| } | ||
| }, | ||
| { | ||
| "model": "publications.publication", | ||
| "pk": 12, | ||
| "fields": { | ||
| "status": "p", | ||
| "title": "First Southern Ocean Publication", | ||
| "abstract": "Sample publication covering a small research area in the Southern Ocean.", | ||
| "publicationDate": "2025-05-29", | ||
| "doi": "10.5555/southernocean1", | ||
| "url": null, | ||
| "geometry": "SRID=4326;GEOMETRYCOLLECTION(POLYGON ((-30.0000 -60.0000, 30.0000 -60.0000, 30.0000 -50.0000, -30.0000 -50.0000, -30.0000 -60.0000)))", | ||
| "creationDate": "2025-05-29T12:00:00Z", | ||
| "lastUpdate": "2025-05-29T12:00:00Z", | ||
| "source": "Marine Test Journal", | ||
| "timeperiod_startdate": "[\"2025-01-01\"]", | ||
| "timeperiod_enddate": "[\"2025-12-31\"]", | ||
| "provenance": "Manually added for Southern Ocean small‐area test." | ||
| } | ||
| }, | ||
| { | ||
| "model": "publications.publication", | ||
| "pk": 13, | ||
| "fields": { | ||
| "status": "p", | ||
| "title": "First Indian Ocean Publication", | ||
| "abstract": "Sample publication covering a small survey area in the Indian Ocean.", | ||
| "publicationDate": "2025-05-29", | ||
| "doi": "10.5555/indianocean1", | ||
| "url": null, | ||
| "geometry": "SRID=4326;GEOMETRYCOLLECTION(POLYGON ((70.0000 -10.0000, 80.0000 -10.0000, 80.0000 0.0000, 70.0000 0.0000, 70.0000 -10.0000)))", | ||
| "creationDate": "2025-05-29T12:00:00Z", | ||
| "lastUpdate": "2025-05-29T12:00:00Z", | ||
| "source": "Marine Test Journal", | ||
| "timeperiod_startdate": "[\"2025-01-01\"]", | ||
| "timeperiod_enddate": "[\"2025-12-31\"]", | ||
| "provenance": "Manually added for Indian Ocean small‐area test." | ||
| } | ||
| }, | ||
| { | ||
| "model": "publications.publication", | ||
| "pk": 14, | ||
| "fields": { | ||
| "status": "p", | ||
| "title": "First North Pacific Ocean Publication", | ||
| "abstract": "Sample publication covering a small sampling area in the North Pacific Ocean.", | ||
| "publicationDate": "2025-05-29", | ||
| "doi": "10.5555/northpacific1", | ||
| "url": null, | ||
| "geometry": "SRID=4326;GEOMETRYCOLLECTION(POLYGON ((-140.0000 30.0000, -130.0000 30.0000, -130.0000 40.0000, -140.0000 40.0000, -140.0000 30.0000)))", | ||
| "creationDate": "2025-05-29T12:00:00Z", | ||
| "lastUpdate": "2025-05-29T12:00:00Z", | ||
| "source": "Marine Test Journal", | ||
| "timeperiod_startdate": "[\"2025-01-01\"]", | ||
| "timeperiod_enddate": "[\"2025-12-31\"]", | ||
| "provenance": "Manually added for North Pacific Ocean small‐area test." | ||
| } | ||
| }, | ||
| { | ||
| "model": "publications.publication", | ||
| "pk": 15, | ||
| "fields": { | ||
| "status": "p", | ||
| "title": "First North Atlantic Ocean Publication", | ||
| "abstract": "Sample publication covering a small sampling area in the North Atlantic Ocean.", | ||
| "publicationDate": "2025-05-29", | ||
| "doi": "10.5555/northatlantic1", | ||
| "url": null, | ||
| "geometry": "SRID=4326;GEOMETRYCOLLECTION(POLYGON((-40.0000 30.0000, -30.0000 30.0000, -30.0000 40.0000, -40.0000 40.0000, -40.0000 30.0000)),POLYGON((-20.0000 35.0000, -10.0000 35.0000, -10.0000 45.0000, -20.0000 45.0000, -20.0000 35.0000)))", | ||
| "creationDate": "2025-05-29T12:00:00Z", | ||
| "lastUpdate": "2025-05-29T12:00:00Z", | ||
| "source": "Marine Test Journal", | ||
| "timeperiod_startdate": "[\"2025-01-01\"]", | ||
| "timeperiod_enddate": "[\"2025-12-31\"]", | ||
| "provenance": "Manually added for North Atlantic Ocean small‐area test." | ||
| } | ||
| }, | ||
| { | ||
| "model": "publications.publication", | ||
| "pk": 16, | ||
| "fields": { | ||
| "status": "p", | ||
| "title": "First Arctic Ocean Publication", | ||
| "abstract": "Sample publication covering a small survey area in the Arctic Ocean.", | ||
| "publicationDate": "2025-05-29", | ||
| "doi": "10.5555/arcticocean1", | ||
| "url": null, | ||
| "geometry": "SRID=4326;GEOMETRYCOLLECTION(LINESTRING(-50.0000 85.0000, 0.0000 85.0000, 50.0000 85.0000))", | ||
| "creationDate": "2025-05-29T12:00:00Z", | ||
| "lastUpdate": "2025-05-29T12:00:00Z", | ||
| "source": "Marine Test Journal", | ||
| "timeperiod_startdate": "[\"2025-01-01\"]", | ||
| "timeperiod_enddate": "[\"2025-12-31\"]", | ||
| "provenance": "Manually added for Arctic Ocean small‐area test." | ||
| } | ||
| }, | ||
| { | ||
| "model": "publications.publication", | ||
| "pk": 17, | ||
| "fields": { | ||
| "status": "p", | ||
| "title": "First South Pacific Ocean Publication", | ||
| "abstract": "Sample publication covering a small research area in the South Pacific Ocean.", | ||
| "publicationDate": "2025-05-29", | ||
| "doi": "10.5555/southpacific1", | ||
| "url": null, | ||
| "geometry": "SRID=4326;GEOMETRYCOLLECTION(POINT(-135.0000 -15.0000))", | ||
| "creationDate": "2025-05-29T12:00:00Z", | ||
| "lastUpdate": "2025-05-29T12:00:00Z", | ||
| "source": "Marine Test Journal", | ||
| "timeperiod_startdate": "[\"2025-01-01\"]", | ||
| "timeperiod_enddate": "[\"2025-12-31\"]", | ||
| "provenance": "Manually added for South Pacific Ocean small‐area test." | ||
| } | ||
| } | ||
| ] | ||
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,50 @@ | ||
|
|
||
| import logging | ||
| import urllib.parse | ||
| from django.http import JsonResponse | ||
| from django.contrib.syndication.views import Feed | ||
| from .feeds import GeoFeed | ||
| from .models import GlobalRegion, Publication | ||
| from django.conf import settings | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class GeoFeedByGeometry(GeoFeed): | ||
| def __init__(self, feed_type_variant="georss"): | ||
| super().__init__(feed_type_variant=feed_type_variant) | ||
|
|
||
| def get_object(self, request, geometry_slug): | ||
nuest marked this conversation as resolved.
Show resolved
Hide resolved
nuest marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| decoded = urllib.parse.unquote(geometry_slug).strip().lower() | ||
| if decoded.endswith(".geojson"): | ||
| decoded = decoded[:-len(".geojson")] | ||
| decoded = decoded.replace("_", " ").replace("-", " ") | ||
| try: | ||
| region = GlobalRegion.objects.get(name__iexact=decoded) | ||
| return region | ||
|
|
||
| except GlobalRegion.DoesNotExist: | ||
| logger.warning("GeoFeedByGeometry: no GlobalRegion match for %r at URL %s", | ||
| decoded, request.build_absolute_uri()) | ||
| return None | ||
|
|
||
| def items(self, region): | ||
| if region is None: | ||
| logger.warning( | ||
| "GeoFeedByGeometry.items was called with None region") | ||
| return [] | ||
|
|
||
| prepared_geom = region.geom.prepared | ||
| candidates = Publication.objects.filter( | ||
| status="p", | ||
| geometry__isnull=False, | ||
| geometry__bboverlaps=region.geom, | ||
| ).order_by("-creationDate") | ||
|
|
||
| return [pub for pub in candidates if prepared_geom.intersects(pub.geometry)][:10] | ||
|
|
||
| def item_link(self, item): | ||
| if item.url: | ||
| return item.url | ||
| else: | ||
| return "" | ||
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.