geonode.thumbs.tests
Submodules
Attributes
Classes
A document is any kind of information that can be attached to a map such as pdf, images, videos, xls... |
|
A GeoApp it is a generic container for every client applications the user might want to create or define. |
|
Dataset (inherits ResourceBase fields) |
|
Python3 class temporarily disabling django signals on model creation. |
|
A Map aggregates several layers together and annotates them with a viewport |
|
The MapLayer model represents a layer included in a map. This doesn't just |
|
A Map aggregates several layers together and annotates them with a viewport |
|
The MapLayer model represents a layer included in a map. This doesn't just |
|
Python3 class temporarily disabling django signals on model creation. |
|
Dataset (inherits ResourceBase fields) |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Functions
|
Check that geonode use a particular OGC Backend integration |
|
Decorator for function specific to a certain ogc backend. |
|
Create a thumbnail with a GeoServer request. |
|
Function generating and saving a thumbnail of the given instance (Dataset or Map), which is composed of |
Ensure all layers, maps and documents are publicly available |
|
|
|
|
|
|
|
|
Package Contents
- class geonode.thumbs.tests.Document[source]
Bases:
geonode.base.models.ResourceBaseA document is any kind of information that can be attached to a map such as pdf, images, videos, xls…
- extension
- doc_url
- property name
- property name_long
- property href
- property is_local
- property download_is_ajax_safe
- property is_file
- property mime_type
- property is_audio
- property is_image
- property is_video
- property class_name
- property embed_url
- property download_url
- class Meta
- class geonode.thumbs.tests.GeoApp(*args, **kwargs)[source]
Bases:
geonode.base.models.ResourceBaseA GeoApp it is a generic container for every client applications the user might want to create or define.
- PERMISSIONS
- name
- last_modified
- property class_name
- property sender
- property center
- .
A handy shortcut for the center_x and center_y properties as a tuple (read only)
- property type
- property is_public
- .
Returns True if anonymous (public) user can view geoapp.
- property keywords_list
- property embed_url
- class geonode.thumbs.tests.Dataset(*args, **kwargs)[source]
Bases:
geonode.base.models.ResourceBaseDataset (inherits ResourceBase fields)
- PERMISSIONS
- objects
- workspace
- store
- name
- typename
- ows_url
- is_mosaic
- has_time
- has_elevation
- time_regex
- elevation_regex
- ptype
- default_style
- styles
- remote_service
- charset
- use_featureinfo_custom_template
- featureinfo_custom_template
- property is_raster
- property display_type
- property data_model
- property data_objects
- property attributes
- property service_typename
- property gtype
- property capabilities_url
- property dataset_ows_url
- property embed_url
- class Meta
Bases:
geonode.base.models.ResourceBase.Meta- permissions = (('change_dataset_data', 'Can edit layer data'), ('change_dataset_style', 'Can change layer style'))
- unique_together = ('store', 'workspace', 'name')
- LEVEL_READ = 'dataset_readonly'
- LEVEL_WRITE = 'dataset_readwrite'
- LEVEL_ADMIN = 'dataset_admin'
- property maps
- get_linked_resources(as_target: bool = False)[source]
Get all the linked resources to this ResourceBase instance. This is implemented as a method so that derived classes can override it (for instance, Maps may add related datasets)
- property download_url
- property maplayers
- property class_name
- class geonode.thumbs.tests.DisableDjangoSignals(disabled_signals=None, skip=False)[source]
Python3 class temporarily disabling django signals on model creation.
usage: with DisableDjangoSignals():
- skip
- stashed_signals
- disabled_signals
- class geonode.thumbs.tests.Map(*args, **kwargs)[source]
Bases:
geonode.base.models.ResourceBaseA Map aggregates several layers together and annotates them with a viewport configuration.
- last_modified
- urlsuffix
- featuredurl
- property datasets
- get_linked_resources(as_target: bool = False)[source]
Get all the linked resources to this ResourceBase instance. This is implemented as a method so that derived classes can override it (for instance, Maps may add related datasets)
- json(dataset_filter)[source]
Get a JSON representation of this map suitable for sending to geoserver for creating a download of all layers
- property embed_url
- get_bbox_from_datasets(layers)[source]
Calculate the bbox from a given list of Dataset objects
bbox format: [xmin, xmax, ymin, ymax]
- property sender
- property class_name
- property is_public
- Returns True if anonymous (public) user can view map.
- property dataset_group
- Returns layer group name from local OWS for this map instance.
- class Meta
- class geonode.thumbs.tests.MapLayer[source]
Bases:
django.db.models.ModelThe MapLayer model represents a layer included in a map. This doesn’t just identify the dataset, but also extra options such as which style to load and the file format to use for image tiles.
- map
- dataset
- extra_params
- name
- store
- current_style
- ows_url
- local
- order
- visibility
- opacity
- property dataset_title
- Used by geonode/maps/templates/maps/map_download.html
- property local_link
- Used by geonode/maps/templates/maps/map_download.html
- property get_legend
- class geonode.thumbs.tests.GeoNodeBaseTestSupport[source]
Bases:
django.test.testcases.TestCase- type = None
- obj_ids = []
- integration = False
- fixtures = ['initial_data.json', 'group_test_data.json', 'default_oauth_apps.json']
- class geonode.thumbs.tests.GeoNodeBaseSimpleTestSupport[source]
Bases:
django.test.testcases.SimpleTestCase
- class geonode.thumbs.tests.ThumbnailsUnitTest[source]
Bases:
geonode.tests.base.GeoNodeBaseTestSupport- fixtures
- re_uuid = '[0-F]{8}-([0-F]{4}-){3}[0-F]{12}'
- class geonode.thumbs.tests.Map(*args, **kwargs)[source]
Bases:
geonode.base.models.ResourceBaseA Map aggregates several layers together and annotates them with a viewport configuration.
- last_modified
- urlsuffix
- featuredurl
- property datasets
- get_linked_resources(as_target: bool = False)[source]
Get all the linked resources to this ResourceBase instance. This is implemented as a method so that derived classes can override it (for instance, Maps may add related datasets)
- json(dataset_filter)[source]
Get a JSON representation of this map suitable for sending to geoserver for creating a download of all layers
- property embed_url
- get_bbox_from_datasets(layers)[source]
Calculate the bbox from a given list of Dataset objects
bbox format: [xmin, xmax, ymin, ymax]
- property sender
- property class_name
- property is_public
- Returns True if anonymous (public) user can view map.
- property dataset_group
- Returns layer group name from local OWS for this map instance.
- class Meta
- class geonode.thumbs.tests.MapLayer[source]
Bases:
django.db.models.ModelThe MapLayer model represents a layer included in a map. This doesn’t just identify the dataset, but also extra options such as which style to load and the file format to use for image tiles.
- map
- dataset
- extra_params
- name
- store
- current_style
- ows_url
- local
- order
- visibility
- opacity
- property dataset_title
- Used by geonode/maps/templates/maps/map_download.html
- property local_link
- Used by geonode/maps/templates/maps/map_download.html
- property get_legend
- geonode.thumbs.tests.check_ogc_backend(backend_package)[source]
Check that geonode use a particular OGC Backend integration
- Parameters:
backend_package (str) – django app of backend to use
- Returns:
bool
- Return type:
bool
- geonode.thumbs.tests.on_ogc_backend(backend_package)[source]
Decorator for function specific to a certain ogc backend.
This decorator will wrap function so it only gets executed if the specified ogc backend is currently used. If not, the function will just be skipped.
Useful to decorate features/tests that only available for specific backend.
- class geonode.thumbs.tests.ResourceManager(concrete_manager=None)[source]
Bases:
ResourceManagerInterface- _concrete_resource_manager
- classmethod _get_instance(uuid: str) geonode.base.models.ResourceBase[source]
- search(filter: dict, /, resource_type: object | None) django.db.models.query.QuerySet[source]
Returns a QuerySet of the filtered resources into the DB.
The ‘filter’ parameter should be an dictionary with the filtering criteria; - ‘filter’ = None won’t return any result - ‘filter’ = {} will return the whole set
The ‘resource_type’ parameter allows to specify the concrete resource model (e.g. Dataset, Document, Map, …) - ‘resource_type’ must be a class - ‘resource_type’ = Dataset will return a set of the only available Layers
- exists(uuid: str, /, instance: geonode.base.models.ResourceBase = None) bool[source]
Returns ‘True’ or ‘False’ if the resource exists or not.
If ‘instance’ is provided, it will take precedence on ‘uuid’
The existance criteria might be subject to the ‘concrete resource manager’ one, dependent on the resource type e.g.: a local Dataset existance check will be constrained by the existance of the layer on the GIS backend
- delete(uuid: str, /, instance: geonode.base.models.ResourceBase = None) int[source]
Deletes a resource from the DB.
If ‘instance’ is provided, it will take precedence on ‘uuid’
It will also fallback to the ‘concrete resource manager’ delete model.
This will eventually delete the related resources on the GIS backend too.
- create(uuid: str, /, resource_type: object | None = None, defaults: dict = {}) geonode.base.models.ResourceBase[source]
The method will just create a new ‘resource_type’ on the DB model and invoke the ‘post save’ triggers.
It assumes any GIS backend resource (e.g. layers on GeoServer) already exist.
It is possible to pass initial default values, like the ‘files’ from the ‘storage_manager’ trhgouh the ‘defaults’ dictionary
- update(uuid: str, /, instance: geonode.base.models.ResourceBase = None, xml_file: str = None, metadata_uploaded: bool = False, vals: dict = {}, regions: list = [], keywords: list = [], custom: dict = {}, notify: bool = True, extra_metadata: list = [], *args, **kwargs) geonode.base.models.ResourceBase[source]
The method will update an existing ‘resource_type’ on the DB model and invoke the ‘post save’ triggers.
It assumes any GIS backend resource (e.g. layers on GeoServer) already exist.
It is possible to pass initial default values, like the ‘files’ from the ‘storage_manager’ trhgouh the ‘vals’ dictionary
The ‘xml_file’ parameter allows to fetch metadata values from a file
The ‘notify’ parameter allows to notify the members that the resource has been updated
- ingest(files: List[str], /, uuid: str = None, resource_type: object | None = None, defaults: dict = {}, **kwargs) geonode.base.models.ResourceBase[source]
The method allows to create a resource by providing the list of files.
- e.g.:
In [1]: from geonode.resource.manager import resource_manager
In [2]: from geonode.layers.models import Dataset
In [3]: from django.contrib.auth import get_user_model
In [4]: admin = get_user_model().objects.get(username=’admin’)
In [5]: files = [“/…/san_andres_y_providencia_administrative.dbf”, “/…/san_andres_y_providencia_administrative.prj”, …: “/…/san_andres_y_providencia_administrative.shx”, “/…/san_andres_y_providencia_administrative.sld”, “/…/san_andres_y_providencia_administrative.shp”]
In [6]: resource_manager.ingest(files, resource_type=Dataset, defaults={‘owner’: admin})
- copy(instance: geonode.base.models.ResourceBase, /, uuid: str = None, owner: django.conf.settings.AUTH_USER_MODEL = None, defaults: dict = {}) geonode.base.models.ResourceBase[source]
The method makes a copy of the existing resource.
It makes a copy of the files
It creates a new layer on the GIS backend in the case the ResourceType is a Dataset
- append(instance: geonode.base.models.ResourceBase, vals: dict = {}, *args, **kwargs)[source]
The method appends data to an existing resource.
It assumes any GIS backend resource (e.g. layers on GeoServer) already exist.
- replace(instance: geonode.base.models.ResourceBase, vals: dict = {}, *args, **kwargs)[source]
The method replaces data of an existing resource.
It assumes any GIS backend resource (e.g. layers on GeoServer) already exist.
- _validate_resource(instance: geonode.base.models.ResourceBase, action_type: str) bool[source]
- exec(method: str, uuid: str, /, instance: geonode.base.models.ResourceBase = None, **kwargs) geonode.base.models.ResourceBase[source]
A generic ‘exec’ method allowing to invoke specific methods of the concrete resource manager not exposed by the interface.
The parameter ‘method’ represents the actual name of the concrete method to invoke.
- remove_permissions(uuid: str, /, instance: geonode.base.models.ResourceBase = None) bool[source]
Remove object permissions on given resource. If is a layer removes the layer specific permissions then the resourcebase permissions.
- set_permissions(uuid: str, /, instance: geonode.base.models.ResourceBase = None, owner: django.conf.settings.AUTH_USER_MODEL = None, permissions: dict = {}, created: bool = False, approval_status_changed: bool = False, group_status_changed: bool = False) bool[source]
Sets the permissions of a resource.
It optionally gets a JSON ‘perm_spec’ through the ‘permissions’ parameter
If no ‘perm_spec’ is provided, it will set the default permissions (owner only)
- set_thumbnail(uuid: str, /, instance: geonode.base.models.ResourceBase = None, overwrite: bool = True, check_bbox: bool = True, thumbnail=None) bool[source]
Allows to generate or re-generate the Thumbnail of a Resource.
- class geonode.thumbs.tests.DisableDjangoSignals(disabled_signals=None, skip=False)[source]
Python3 class temporarily disabling django signals on model creation.
usage: with DisableDjangoSignals():
- skip
- stashed_signals
- disabled_signals
- class geonode.thumbs.tests.GeoNodeBaseTestSupport[source]
Bases:
django.test.testcases.TestCase- type = None
- obj_ids = []
- integration = False
- fixtures = ['initial_data.json', 'group_test_data.json', 'default_oauth_apps.json']
- geonode.thumbs.tests.create_gs_thumbnail_geonode(instance, overwrite=False, check_bbox=False)[source]
Create a thumbnail with a GeoServer request.
- geonode.thumbs.tests.create_thumbnail(instance: geonode.layers.models.Dataset | geonode.maps.models.Map, wms_version: str = settings.OGC_SERVER['default'].get('WMS_VERSION', '1.3.0'), bbox: List | Tuple | None = None, forced_crs: str | None = None, styles: List | None = None, overwrite: bool = False, background_zoom: int | None = None) None[source]
Function generating and saving a thumbnail of the given instance (Dataset or Map), which is composed of outcomes of WMS GetMap queries to the instance’s datasets providers, and an outcome of querying background provider for thumbnail’s background (by default Slippy Map provider).
- Parameters:
instance – instance of Dataset or Map models
wms_version – WMS version of the query
bbox – bounding box of the thumbnail in format: (west, east, south, north, CRS), where CRS is in format “EPSG:XXXX”
forced_crs – CRS which should be used to fetch data from WMS services in format “EPSG:XXXX”. By default all data is translated and retrieved in EPSG:3857, since this enables background fetching from Slippy Maps providers. Forcing another CRS can cause skipping background generation in the thumbnail
styles – styles, which OGC server should use for rendering an image
overwrite – overwrite existing thumbnail
background_zoom – zoom of the XYZ Slippy Map used to retrieve background image, if Slippy Map is used as background
- class geonode.thumbs.tests.Dataset(*args, **kwargs)[source]
Bases:
geonode.base.models.ResourceBaseDataset (inherits ResourceBase fields)
- PERMISSIONS
- objects
- workspace
- store
- name
- typename
- ows_url
- is_mosaic
- has_time
- has_elevation
- time_regex
- elevation_regex
- ptype
- default_style
- styles
- remote_service
- charset
- use_featureinfo_custom_template
- featureinfo_custom_template
- property is_raster
- property display_type
- property data_model
- property data_objects
- property attributes
- property service_typename
- property gtype
- property capabilities_url
- property dataset_ows_url
- property embed_url
- class Meta
Bases:
geonode.base.models.ResourceBase.Meta- permissions = (('change_dataset_data', 'Can edit layer data'), ('change_dataset_style', 'Can change layer style'))
- unique_together = ('store', 'workspace', 'name')
- LEVEL_READ = 'dataset_readonly'
- LEVEL_WRITE = 'dataset_readwrite'
- LEVEL_ADMIN = 'dataset_admin'
- property maps
- get_linked_resources(as_target: bool = False)[source]
Get all the linked resources to this ResourceBase instance. This is implemented as a method so that derived classes can override it (for instance, Maps may add related datasets)
- property download_url
- property maplayers
- property class_name
- class geonode.thumbs.tests.OSMTileBackground(thumbnail_width: int, thumbnail_height: int, max_retries: int = 3, retry_delay: int = 1)[source]
Bases:
GenericXYZBackgroundHelper class that provides a standard way to create an ABC using inheritance.
- url = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
- tile_size = 256
- class geonode.thumbs.tests.WikiMediaTileBackground(thumbnail_width: int, thumbnail_height: int, max_retries: int = 3, retry_delay: int = 1)[source]
Bases:
GenericXYZBackgroundHelper class that provides a standard way to create an ABC using inheritance.
- url = 'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png'
- tile_size = 256
- class geonode.thumbs.tests.GenericXYZBackground(thumbnail_width: int, thumbnail_height: int, max_retries: int = 3, retry_delay: int = 1)[source]
Bases:
BaseThumbBackgroundHelper class that provides a standard way to create an ABC using inheritance.
- options
- url
- tile_size
- tms = False
- crs = 'EPSG:3857'
- _epsg3857_max_x = 20026376.39
- _epsg3857_max_y = 20048966.1
- _mercantile_bbox = None
- bbox3857to4326(x_min, x_max, y_min, y_max)[source]
Function converting BBOX from EPSG:3857 to EPSG:4326, keeping the order of the coordinates. To ensure no additional change is performed, conversion is based on top-left and bottom-right points conversion.
- bbox4326to3857(x_min, x_max, y_min, y_max)[source]
Function converting BBOX from EPSG:4326 to EPSG:3857, keeping the order of the coordinates. To ensure no additional change is performed, conversion is based on top-left and bottom-right points conversion.
- fetch(bbox: List, zoom: int = None, *args, **kwargs)[source]
The function fetching tiles from a Slippy Map provider, composing them into a single image, and cropping it to match the given BBOX. Retrieval of each tile is repeated self.max_retries times, waiting self.retry_delay seconds between consecutive requests.
- Parameters:
bbox – bounding box of the background image, dataset compliant format: [west, east, south, north, CRS]
zoom – zoom with which to retrieve Slippy Map’s tiles (by default, it’s calculated based on width, height)
- Returns:
None if the CRS is different from self.tiles_crs, or background Image
- class geonode.thumbs.tests.GenericWMSBackground(thumbnail_width: int, thumbnail_height: int, max_retries: int = 3, retry_delay: int = 1)[source]
Bases:
BaseThumbBackgroundHelper class that provides a standard way to create an ABC using inheritance.
- options
- service_url
- dataset_name
- format
- version
- styles
- srid
- bbox_to_projection(bbox: List)[source]
Function converting BBOX to target projection system, keeping the order of the coordinates. To ensure no additional change is performed, conversion is based on top-left and bottom-right points conversion.
- Parameters:
bbox – a dataset compliant BBOX: [west, east, south, north, CRS]
- fetch(bbox: List, *args, **kwargs)[source]
Function fetching background image, based on the given BBOX. On error should raise an exception or return None.
- Parameters:
bbox – a dataset compliant BBOX: [west, east, south, north, CRS]
args – not used, kept for API compatibility
kargs – not used, kept for API compatibility
- geonode.thumbs.tests.all_public()[source]
Ensure all layers, maps and documents are publicly available
- geonode.thumbs.tests.create_single_dataset(name, keywords=None, owner=None, group=None, **kwargs)[source]
- class geonode.thumbs.tests.GeoNodeThumbnailTileBackground[source]
Bases:
geonode.tests.base.GeoNodeBaseTestSupport- dataset_coast_line = None
- fixtures = ['initial_data.json', 'group_test_data.json', 'default_oauth_apps.json']
- class geonode.thumbs.tests.GeoNodeThumbnailsIntegration[source]
Bases:
geonode.tests.base.GeoNodeBaseTestSupport- dataset_coast_line = None
- dataset_highway = None
- map_composition = None
- class geonode.thumbs.tests.GeoNodeBaseTestSupport[source]
Bases:
django.test.testcases.TestCase- type = None
- obj_ids = []
- integration = False
- fixtures = ['initial_data.json', 'group_test_data.json', 'default_oauth_apps.json']
- class geonode.thumbs.tests.GenericWMTSBackground(thumbnail_width: int, thumbnail_height: int, max_retries: int = 3, retry_delay: int = 1)[source]
Bases:
BaseThumbBackgroundHelper class that provides a standard way to create an ABC using inheritance.
- options
- levels
- thumbnail_width
- thumbnail_height
- geonode.thumbs.tests.base_request_url = 'https://myserver.com/WMTS?&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png&layer=Hos...[source]