Package eoxserver :: Package resources :: Package coverages :: Module interfaces
[hide private]
[frames] | no frames]

Source Code for Module eoxserver.resources.coverages.interfaces

   1  #------------------------------------------------------------------------------- 
   2  # $Id: interfaces.py 1952 2012-08-10 17:02:59Z martin.paces $ 
   3  # 
   4  # Project: EOxServer <http://eoxserver.org> 
   5  # Authors: Stephan Krause <stephan.krause@eox.at> 
   6  #          Stephan Meissl <stephan.meissl@eox.at> 
   7  #          Martin Paces <martin.paces@eox.at> 
   8  # 
   9  #------------------------------------------------------------------------------- 
  10  # Copyright (C) 2011 EOX IT Services GmbH 
  11  # 
  12  # Permission is hereby granted, free of charge, to any person obtaining a copy 
  13  # of this software and associated documentation files (the "Software"), to deal 
  14  # in the Software without restriction, including without limitation the rights 
  15  # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell  
  16  # copies of the Software, and to permit persons to whom the Software is  
  17  # furnished to do so, subject to the following conditions: 
  18  # 
  19  # The above copyright notice and this permission notice shall be included in all 
  20  # copies of this Software or works derived from this Software. 
  21  # 
  22  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
  23  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
  24  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
  25  # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
  26  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
  27  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
  28  # THE SOFTWARE. 
  29  #------------------------------------------------------------------------------- 
  30   
  31  """ 
  32  This module contains the definition of coverage and dataset series 
  33  interfaces. These provide a harmonized interface to coverage data that 
  34  can be stored in different formats and has different types. 
  35  """ 
  36   
  37  from datetime import datetime 
  38   
  39  from django.contrib.gis.geos import GEOSGeometry 
  40   
  41  from eoxserver.core.interfaces import * 
  42  from eoxserver.core.registry import RegisteredInterface 
  43  from eoxserver.core.records import RecordWrapperInterface 
  44  from eoxserver.core.resources import ResourceInterface 
  45  from eoxserver.resources.coverages.rangetype import RangeType 
  46   
  47  #----------------------------------------------------------------------- 
  48  # Data Interfaces 
  49  #----------------------------------------------------------------------- 
  50   
51 -class DataSourceInterface(RegisteredInterface):
52 """ 53 This interface shall be implemented by Data Sources. They represent 54 locations where information about a collection of Data Packages 55 can be retrieved. 56 57 .. method:: detect 58 59 This method shall return a list of Data Packages, i.e. objects 60 implementing :class:`DataPackageInterface`, related to the 61 Data Source. 62 63 .. method:: contains 64 65 This method shall return ``True`` if a data source references 66 a dataset, ``False`` otherwise. 67 68 """ 69 70 REGISTRY_CONF = { 71 "name": "Data Source Interface", 72 "intf_id": "backends.interfaces.DataSource", 73 "binding_method": "factory" 74 } 75 76 detect = Method( 77 returns = ListArg("@return") 78 ) 79 80 contains = Method( 81 ObjectArg("wrapper"), 82 returns = BoolArg("@return") 83 )
84
85 -class CoverageDataInterface(RecordWrapperInterface):
86 """ 87 This is the common base interface for coverage data. 88 89 .. 90 91 .. method:: getDataStructureType 92 93 This method shall return a string denoting the data structure 94 type of the data. 95 """ 96 97 REGISTRY_CONF = { 98 "name": "Coverage Data Interface", 99 "intf_id": "resources.coverages.interfaces.CoverageData", 100 "binding_method": "factory" 101 } 102 103 getDataStructureType = Method( 104 returns = StringArg("@return") 105 )
106
107 -class DataPackageInterface(CoverageDataInterface):
108 """ 109 This interface shall be implemented by Data Packages. Data Packages 110 provide an abstraction layer for various kinds of file-based or 111 database-based datasets. Internally, data packages store information 112 about the location of the original data and (for remote backends) the 113 location of a locally accessible copy. 114 115 Methods for high-level data access: 116 117 .. method:: open 118 119 This method shall open the data package. It shall return an 120 object representing the underlying dataset in the engine 121 defined by the data format of the data package. 122 123 .. method:: getLocation 124 125 Returns the location of the data, i.e. an object that implements 126 :class:`~.LocationInterface`. Note that this location is not necessarily 127 directly accessible from the local file system or operating system, but 128 may be remote. For fetching an accessible location, see 129 :meth:`prepareAccess` and :meth:`getAccessibleLocation`. 130 131 .. method:: getMetadataLocation 132 133 Returns the location of the metadata, i.e. an object that implements 134 :class:`~.LocationInterface`. 135 136 .. method:: readGeospatialMetadata(default_srid=None) 137 138 This method shall return an object containing the geospatial 139 metadata stored with the data package. It accepts an optional 140 ``default_srid`` parameter which indicates the SRID to use if it cannot 141 be read from the data package. 142 143 .. method:: readEOMetadata 144 145 This method shall return an object containing the EO metadata 146 required by EOxServer and stored with the data package. 147 148 Methods for low-level data access; use these with care: 149 150 .. method:: prepareAccess 151 152 This method has to be called before any attempt to actually 153 access the data. It shall prepare access, e.g. by retrieving 154 remote data or unpacking complex packages, so that subsequent 155 calls to :meth:`getAccessibleLocation` and 156 :meth:`getAccessiblePath` can return meaningful results. It 157 shall raise :exc:`~.DataAccessError` in case of an error. 158 159 .. method:: getAccessibleLocation 160 161 This method shall return a location, i.e. an object implementing 162 :class:`LocationInterface`. An :exc:`InternalError` shall be 163 raised if the data package is not accessible (e.g. because 164 :meth:`prepareAccess` has not been called or the call failed) 165 166 .. method:: getGDALDatasetIdentifier 167 168 This method shall return a string to be used to open the data package 169 in GDAL. It shall raise :exc:`~.InternalError` if the data package 170 cannot be opened in GDAL. 171 172 """ 173 REGISTRY_CONF = { 174 "name": "Data Package Interface", 175 "intf_id": "resources.coverages.interfaces.DataPackage", 176 "binding_method": "factory" 177 } 178 179 getType = Method( 180 returns = StringArg("@return") 181 ) 182 183 open = Method( 184 returns = ObjectArg("@return") 185 ) 186 187 getLocation = Method( 188 returns = ObjectArg("@return") 189 ) 190 191 getMetadataLocation = Method( 192 returns = ObjectArg("@return") 193 ) 194 195 getCoverages = Method( 196 returns = ListArg("@return") 197 ) 198 199 readGeospatialMetadata = Method( 200 IntArg("default_srid", default=None), 201 returns = ObjectArg("@return") 202 ) 203 204 readEOMetadata = Method( 205 returns = ObjectArg("@return") 206 ) 207 208 prepareAccess = Method() 209 210 getAccessibleLocation = Method( 211 returns = ObjectArg("@return") 212 ) 213 214 getGDALDatasetIdentifier = Method( 215 returns = StringArg("@return") 216 )
217 218
219 -class TileIndexInterface(CoverageDataInterface):
220 """ 221 This interface provides the methods necessary to access tile index 222 information for coverages. 223 224 :Interface ID: resources.coverages.interfaces.TileIndex 225 226 .. method:: getShapeFilePath 227 228 This method shall return the path to the shape file that holds 229 information about the tiles the coverage is split up into. 230 """ 231 REGISTRY_CONF = { 232 "name": "Tile Index Interface", 233 "intf_id": "resources.coverages.interfaces.TileIndex", 234 "binding_method": "factory" 235 } 236 237 getShapeFilePath = Method( 238 returns=StringArg("@return") 239 )
240 241 #------------------------------------------------------------------------------- 242 # Metadata Interfaces 243 #------------------------------------------------------------------------------- 244
245 -class MetadataFormatInterface(RegisteredInterface):
246 """ 247 This is a (very basic) interface for metadata formats. So far, it defines 248 only one method: 249 250 .. method:: getName 251 252 This method shall return the name of the format. 253 254 .. method:: getMetadataKeys 255 256 This method shall return a list of metadata keys that are known to the 257 metadata format 258 259 .. method:: getMetadataValues(keys, raw_metadata) 260 261 This method shall return a dictionary of metadata keys and values. The 262 dictionary keys shall correspond to the keys conveyed with the request, 263 the dictionary values shall be the respective metadata values, or 264 ``None`` if the key is not known or no metadata value is defined for the 265 specific metadata instance. 266 267 The ``raw_metadata`` argument shall point to the raw metadata input. 268 The method shall raise :exc:`~.InternalError` if the format cannot 269 decode the raw metadata content, e.g. because it is in the wrong data 270 format. 271 """ 272 273 REGISTRY_CONF = { 274 "name": "Metadata Format Interface", 275 "intf_id": "resources.coverages.interfaces.MetadataFormat", 276 "binding_method": "testing" 277 } 278 279 getName = Method( 280 returns = StringArg("@return") 281 ) 282 283 getMetadataKeys = Method( 284 returns = ListArg("@return") 285 ) 286 287 getMetadataValues = Method( 288 ListArg("keys"), 289 Arg("raw_metadata"), 290 returns = DictArg("@return") 291 )
292
293 -class EOMetadataFormatInterface(MetadataFormatInterface):
294 """ 295 This interface is intended for EO metadata formats and extends 296 :class:`MetadataFormatInterface`. 297 298 .. method:: getEOMetadata(raw_metadata) 299 300 This method shall decode the raw metadata passed to it and return an 301 EO Metadata object, i.e. an implementation of 302 :class:`EOMetadataInterface`. 303 304 The method shall raise :exc:`~.InternalError` if the format cannot 305 decode the raw metadata content, e.g. because it is in the wrong data 306 format. 307 """ 308 309 REGISTRY_CONF = { 310 "name": "EO Metadata Format Interface", 311 "intf_id": "resources.coverages.interfaces.EOMetadataFormat" 312 } 313 314 getEOMetadata = Method( 315 Arg("raw_metadata"), 316 returns = ObjectArg("@return") 317 )
318
319 -class GenericMetadataInterface(RegisteredInterface):
320 """ 321 This is an interface for objects containing metadata of any kind. They can 322 be retrieved using a key-value-pair schema. 323 324 .. method:: getMetadataFormat 325 326 This method shall return the metadata format, i.e. an object implementing 327 :class:`MetadataFormatInterface`. 328 329 .. method:: getMetadataKeys 330 331 This method shall return a list of metadata keys that are understood by 332 the metadata interface. 333 334 .. method:: getMetadataValues(keys) 335 336 This method shall return a dictionary of metadata keys and values. The 337 dictionary keys shall correspond to the keys conveyed with the request, 338 the dictionary values shall be the respective metadata values, or 339 ``None`` if the key is not known or no metadata value is defined for the 340 specific metadata instance. 341 """ 342 343 REGISTRY_CONF = { 344 "name": "Metadata Interface", 345 "intf_id": "resources.coverages.interfaces.Metadata", 346 "binding_method": "direct" 347 } 348 349 getMetadataFormat = Method( 350 returns = ObjectArg("@return") 351 ) 352 353 getMetadataKeys = Method( 354 returns = ListArg("@return") 355 ) 356 357 getMetadataValues = Method( 358 ListArg("keys"), 359 returns = DictArg("@return") 360 ) 361 362 getRawMetadata = Method( 363 returns = StringArg("@return") 364 )
365
366 -class EOMetadataInterface(RegisteredInterface):
367 """ 368 This an interface for objects carrying basic EO Metadata. It is the base 369 for metadata reader interfaces as well as EO-WCS object interfaces. Note 370 that it does NOT inherit from :class:`MetadataInterface`, so key-value-pair 371 access to metadata values is not possible. 372 373 .. method:: getEOID 374 375 This method shall return the EO ID of the coverage wrapped by the 376 implementation 377 378 .. method:: getBeginTime 379 380 This method shall return the acquisition begin date and time of 381 the EO coverage wrapped by the implementation. The type of the 382 return value is expected to be :class:`datetime.datetime`. 383 384 .. method:: getEndTime 385 386 This method shall return the acquisition end date and time of the 387 EO coverage wrapped by the implementation. The type of the return 388 value is expected to be :class:`datetime.datetime`. 389 390 .. method:: getFootprint 391 392 This method shall return the acquisition footprint of the EO 393 coverage wrapped by the implementation. The type of the return 394 value is expected to be :class:`django.contrib.gis.geos.GEOSGeometry`. 395 396 """ 397 398 REGISTRY_CONF = { 399 "name": "EO Metadata Interface", 400 "intf_id": "resources.coverages.interfaces.EOMetadata", 401 "binding_method": "direct" 402 } 403 404 getEOID = Method( 405 returns=StringArg("@return") 406 ) 407 408 getBeginTime = Method( 409 returns=ObjectArg("@return", arg_class=datetime) 410 ) 411 412 getEndTime = Method( 413 returns=ObjectArg("@return", arg_class=datetime) 414 ) 415 416 getFootprint = Method( 417 returns=ObjectArg("@return", arg_class=GEOSGeometry) 418 )
419
420 -class GenericEOMetadataInterface(GenericMetadataInterface, EOMetadataInterface):
421 """ 422 An interface combining generic and EO metadata access. Inherits from 423 :class:`MetadataInterface` and :class:`EOMetadataInterface`. 424 """ 425 REGISTRY_CONF = { 426 "name": "Generic EO Metadata Interface", 427 "intf_id": "resources.coverages.interfaces.GenericEOMetadata" 428 }
429
430 -class EOMetadataReaderInterface(RegisteredInterface):
431 """ 432 This interfaces shall be implemented by objects that can read EO Metadata 433 sources and translate them to EO Metadata objects. Implementations can be 434 found in the registry by key-value-pair matching. The interface defines two 435 registry keys: 436 437 * ``resources.coverages.interfaces.location_type``: the type of the 438 location, e.g. ``local`` (this is two abstract from file or catalogue 439 record access) 440 * ``resources.coverages.interfaces.encoding_type``: the way how the 441 metadata was encoded; most common are XML encoding in a metadata file or 442 catalogue record and metadata tags in a data file 443 444 .. method:: readEOMetadata(location) 445 446 This method shall read the object at the given ``location`` and return 447 the decoded EO Metadata found in it. It shall raise 448 :exc:`~.InternalError` if the location or encoding type do not match the 449 implementation specification or :exc:`~.DataAccessError` if the 450 underlying resource cannot be accessed. 451 """ 452 453 REGISTRY_CONF = { 454 "name": "EO Metadata Reader Interface", 455 "intf_id": "resources.coverages.interfaces.EOMetadataReader", 456 #"binding_method": "kvp", 457 "binding_method": "testing", 458 "registry_keys": ( 459 "resources.coverages.interfaces.location_type", 460 "resources.coverages.interfaces.encoding_type" 461 ) 462 } 463 464 readEOMetadata = Method( 465 ObjectArg("location"), 466 returns = ObjectArg("@return") 467 )
468 469 #----------------------------------------------------------------------- 470 # Coverage and Dataset Series Interfaces 471 #----------------------------------------------------------------------- 472
473 -class CoverageInterface(ResourceInterface):
474 """ 475 The parent class of all coverage interfaces. It defines methods for 476 access to coverage data. It inherits from 477 :class:`~.ResourceInterface`. 478 479 :Interface ID: resources.coverages.interfaces.Coverage 480 481 .. method:: getCoverageId 482 483 This method shall return the coverage id of the coverage resource 484 wrapped by the implementation 485 486 .. method:: getCoverageSubtype 487 488 This method shall return the GML coverage subtype of the coverage 489 resource wrapped by the implementation 490 491 .. method:: getType 492 493 This method shall return the EOxServer coverage type of the 494 coverage wrapped by the implementation. Current choices are: 495 496 * ``file`` 497 * ``eo.rect_dataset`` 498 * ``eo.ref_dataset`` 499 * ``eo.rect_stitched_mosaic`` 500 501 .. method:: getSize 502 503 This method shall return the size of the coverage wrapped by the 504 implementation. The return value is expected to be a 2-tuple 505 of integers ``(xsize, ysize)``. 506 507 .. method:: getRangeType 508 509 This method shall return a :class:`~.RangeType` instance 510 containing the data type and band structure of the coverage 511 wrapped by the implementation 512 513 .. method:: getDataStructureType 514 515 This method shall return the type of the data structure that contains the 516 coverage's data. See :meth:`CoverageDataInterface.getDataStructureType`. 517 Note that this does not define the implementation of the coverage data 518 object returned with :meth:`getData`. 519 520 .. method:: getData 521 522 This method shall return an object that provides access to the coverage 523 data, i.e. an implementation of :class:`CoverageDataInterface`. 524 525 .. method:: getLayerMetadata 526 527 This method shall return a list containing 2-tuples of MapServer 528 metadata key-value-pairs that will be tagged on the MapServer 529 layer representing this coverage. 530 """ 531 532 REGISTRY_CONF = { 533 "name": "Coverage Interface", 534 "intf_id": "resources.coverages.interfaces.Coverage" 535 } 536 537 538 getCoverageId = Method( 539 returns=StringArg("@return") 540 ) 541 542 getCoverageSubtype = Method( 543 returns=StringArg("@return") 544 ) 545 546 getType = Method( 547 returns=StringArg("@return") 548 ) 549 550 getSize = Method( 551 returns=ObjectArg("@return", arg_class=tuple) 552 ) 553 554 getRangeType = Method( 555 returns=ObjectArg("@return", arg_class=RangeType) 556 ) 557 558 getDataStructureType = Method( 559 returns=StringArg("@return") 560 ) 561 562 getData = Method( 563 returns=ObjectArg("@return") 564 ) 565 566 getLayerMetadata = Method( 567 returns=ListArg("@return", arg_class=tuple) 568 ) 569 570 matches = Method( 571 ListArg("filter_exprs"), 572 returns=BoolArg("@return") 573 )
574
575 -class RectifiedGridInterface(RegisteredInterface):
576 """ 577 This interface defines methods to access rectified grid information, 578 namely the coordinate reference system ID and the geographical 579 extent of the coverage. It is intended to be used as mix-in for 580 coverage interfaces. 581 582 :Interface ID: resources.coverages.interfaces.RectifiedGrid 583 584 .. method:: getSRID 585 586 This method shall return the EPSG SRID of the coverage's 587 coordinate reference system (CRS) 588 589 .. method:: getExtent 590 591 This method shall return the extent of the coverage wrapped by 592 the implementation. The return value is expected to be a 4-tuple 593 of floating point coordinates (minx, miny, maxx, maxy) expressed 594 in the CRS described by the SRID returned with :meth:`getSRID`. 595 """ 596 597 REGISTRY_CONF = { 598 "name": "Rectified Grid Interface (mix-in for coverages)", 599 "intf_id": "resources.coverages.interfaces.RectifiedGrid" 600 } 601 602 getSRID = Method( 603 returns=IntArg("@return") 604 ) 605 606 getExtent = Method( 607 returns=ObjectArg("@return", arg_class=tuple) 608 ) 609 610 getResolution = Method( 611 returns=ObjectArg("@return", arg_class=tuple) 612 )
613
614 -class ReferenceableGridInterface(RegisteredInterface):
615 """ 616 This interface defines methods for access to referenceable grid 617 information. 618 619 :Interface ID: resources.coverages.interfaces.ReferenceableGrid 620 621 .. method:: getSRID 622 623 This method shall return the EPSG SRID of the coordinate reference 624 system (CRS) of the coverages tie-points. 625 626 .. method:: getExtent 627 628 This method shall return the extent of the coverage wrapped by 629 the implementation. The return value is expected to be a 4-tuple 630 of floating point coordinates (minx, miny, maxx, maxy) expressed 631 in the CRS described by the SRID returned with :meth:`getSRID`. 632 """ 633 634 REGISTRY_CONF = { 635 "name": "Referenceable Grid Interface (mix-in for coverages)", 636 "intf_id": "resources.coverages.interfaces.ReferenceableGrid" 637 } 638 639 getSRID = Method( 640 returns=IntArg("@return") 641 ) 642 643 getExtent = Method( 644 returns=ObjectArg("@return", arg_class=tuple) 645 )
646 647
648 -class EOWCSObjectInterface(EOMetadataInterface):
649 """ 650 This is the interface for EO Coverage subtypes as defined by the 651 Earth Observation Application Profile for WCS 2.0. It inherits from 652 :class:`EOMetadataInterface`. It should not be implemented directly; you'd 653 rather use its descendants. 654 655 .. method:: getWGS84Extent 656 657 This method shall return the WGS 84 extent of the EO coverage 658 wrapped by the implementation. The return value shall be a 4-tuple 659 of floating point coordinates (minlon, minlat, maxlon, maxlat) 660 given in the WGS 84 coordinate system (EPSG:4326). 661 662 .. method:: getEOGML 663 664 This method shall return the EO GML (EO O&M) conformant metadata 665 stored with the EO coverage. If no EO O&M metadata is available, 666 the empty string will be returned 667 668 """ 669 670 REGISTRY_CONF = { 671 "name": "Interface for EO-WCS Objects", 672 "intf_id": "resources.coverages.interfaces.EOWCSObject" 673 } 674 675 getWGS84Extent = Method( 676 returns=ObjectArg("@return", arg_class=tuple) 677 ) 678 679 getEOGML = Method( 680 returns=StringArg("@return") 681 )
682
683 -class EOCoverageInterface(CoverageInterface, EOWCSObjectInterface):
684 """ 685 This interface is the base interface for implementations of EO 686 Coverages according to the WCS 2.0 EO-AP (EO-WCS). It inherits from 687 :class:`CoverageInterface` and class:`EOWCSObjectInterface`. It is not 688 intended to be implemented directly; rather one of its descendants shall 689 be used. 690 691 :Interface ID: resources.coverages.interfaces.EOCoverage 692 693 .. method:: getEOCoverageSubtype 694 695 This method shall return the EO coverage subtype of the coverage 696 wrapped by the implementation 697 698 .. method:: getDatasets(filter_exprs=None) 699 700 This method shall return a list of dataset wrappers for the 701 datasets contained in the coverage wrapped by the implemention. 702 The optional ``filter_exprs`` argument is expected to be a list 703 of filter expressions to be applied to the datasets or ``None``. 704 In case no contained dataset matches the filter expressions an 705 empty list shall be returned. 706 707 In case of atomic coverages which do not contain any datasets 708 (e.g. RectifiedDatasets themselves) a list containing the 709 coverage wrapper itself shall be returned. In case filter 710 expressions are provided with the call these shall be applied; 711 if the coverage does not match them an empty list shall be 712 returned. 713 714 .. method:: getLineage 715 716 This method shall return the content of the lineage object stored 717 with the EO coverage wrapped by the implementation. Note that this 718 element is not yet specified in detail in the specification at 719 the moment (2011-05-26). If no lineage is available, None shall 720 be returned. 721 722 .. method:: getContainers 723 724 This method shall return a list of container wrappers (Stitched 725 Mosaic or Dataset Series wrappers) the coverage is contained in. 726 The empty list shall be returned if the coverage is not related 727 to any container object. 728 729 .. method:: getContainerCount 730 731 This method shall return the number of container objects the 732 EO Coverage is contained in. 733 734 .. method:: containedIn(res_id) 735 736 This method shall return ``True`` if the EO coverage is 737 contained in the container object (Stitched Mosaic or Dataset 738 Series) specified by the ``wrapper``, ``False`` otherwise. 739 740 .. method:: contains(res_id) 741 742 This method shall return ``True`` if the EO coverage is a 743 container object and contains the coverage with resource 744 specified by the ``wrapper``, ``False`` otherwise. 745 """ 746 REGISTRY_CONF = { 747 "name": "EO Coverage Interface", 748 "intf_id": "resources.coverages.interfaces.EOCoverage" 749 } 750 751 752 getEOCoverageSubtype = Method( 753 returns=StringArg("@return") 754 ) 755 756 getDatasets = Method( 757 ListArg("filter_exprs", default=None), 758 returns=ListArg("@return") 759 ) 760 761 getLineage = Method( 762 returns=ObjectArg("@return") 763 ) 764 765 getContainers = Method( 766 returns=ListArg("@return") 767 ) 768 769 getContainerCount = Method( 770 returns=IntArg("@return") 771 ) 772 773 containedIn = Method( 774 ObjectArg("wrapper"), 775 returns=BoolArg("@return") 776 ) 777 778 contains = Method( 779 ObjectArg("wrapper"), 780 returns=BoolArg("@return") 781 )
782
783 -class RectifiedDatasetInterface(EOCoverageInterface, RectifiedGridInterface):
784 """ 785 This class is intended for implementations of RectifiedDataset 786 objects according to the WCS 2.0 EO-AP (EO-WCS). It inherits from 787 :class:`~.EODatasetInterface` and :class:`~.RectifiedGridInterface`. 788 789 :Interface ID: resources.coverages.interfaces.RectifiedDataset 790 """ 791 REGISTRY_CONF = { 792 "name": "Rectified Dataset Interface", 793 "intf_id": "resources.coverages.interfaces.RectifiedDataset" 794 }
795
796 -class ReferenceableDatasetInterface(EOCoverageInterface, ReferenceableGridInterface):
797 """ 798 This class is intended for implementations of RectifiedDataset 799 objects according to the WCS 2.0 EO-AP (EO-WCS). It inherits from 800 :class:`~.EODatasetInterface` and 801 :class:`ReferenceableGridInterface`. 802 803 .. note:: the design of this interface is still TBD 804 805 :Interface ID: resources.coverages.interfaces.ReferenceableDataset 806 807 """ 808 REGISTRY_CONF = { 809 "name": "Referenceable Dataset Interface", 810 "intf_id": "resources.coverages.interfaces.ReferenceableDataset" 811 }
812
813 -class ContainerInterface(RegisteredInterface):
814 """ 815 This is the common interface for coverages and series containing 816 EO Coverages. 817 818 .. method:: contains(wrapper) 819 820 Returns a boolean value describing if the container contains the resource 821 specified by the given ``wrapper``. 822 823 .. method:: addCoverage(wrapper) 824 825 Add resource specified by the given ``wrapper``. 826 827 .. method:: removeCoverage(wrapper) 828 829 Remove resource specified by the given ``wrapper``. 830 831 .. method:: getDataSources 832 833 This method shall return a list of data sources, i.e. objects 834 implementing :class:`DataSourceInterface` for the given container. 835 It is intended for use in 836 :mod:`eoxserver.resources.coverages.synchronize`. 837 """ 838 839 REGISTRY_CONF = { 840 "name": "Container Interface", 841 "intf_id": "resources.coverages.interfaces.Container" 842 } 843 844 contains = Method( 845 ObjectArg("wrapper"), 846 returns=BoolArg("@return") 847 ) 848 849 addCoverage = Method( 850 ObjectArg("wrapper") 851 ) 852 853 removeCoverage = Method( 854 ObjectArg("wrapper") 855 ) 856 857 getDataSources = Method( 858 returns=ListArg("@return") 859 )
860
861 -class RectifiedStitchedMosaicInterface(EOCoverageInterface, RectifiedGridInterface, ContainerInterface):
862 """ 863 This class is intended for implementations of Rectified Stitched 864 Mosaic objects according to WCS 2.0 EO-AP (EO-WCS). It inherits from 865 :class:`~.EOCoverageInterface`, :class:`~.RectifiedGridInterface` 866 and :class:`~.TileIndexInterface`. 867 868 :Interface ID: resources.coverages.interfaces.RectifiedStitchedMosaic 869 870 .. method:: getDataDirs: 871 872 This method shall return a list of directories which hold the 873 stitched mosaic data. 874 875 .. method:: getImagePattern 876 877 This method shall return the filename pattern for image files 878 to be included in the stitched mosaic. 879 """ 880 REGISTRY_CONF = { 881 "name": "Rectified Stitched Mosaic Interface", 882 "intf_id": "resources.coverages.interfaces.RectifiedStitchedMosaic" 883 }
884
885 -class DatasetSeriesInterface(ResourceInterface, EOWCSObjectInterface):
886 """ 887 This interface is intended for implementations of Dataset Series 888 according to the WCS 2.0 EO-AP (EO-WCS). It inherits from 889 :class:`~.ResourceInterface` and :class:`~.EOWCSObjectInterface`. 890 891 :Interface ID: resources.coverages.interfaces.DatasetSeries 892 893 .. method:: getType 894 895 Shall return ``"eo.dataset_series"``. 896 897 .. method:: getEOCoverages(filter_exprs=None) 898 899 This method shall return a list of EOCoverage wrappers for the 900 datasets and stitched mosaics contained in the dataset series 901 wrapped by the implementation. The optional ``filter_exprs`` 902 argument is expected to be a list of filter expressions to be 903 applied to the datasets or ``None``. In case no contained dataset 904 matches the filter expressions an empty list shall be returned. 905 906 .. method:: getDatasets(filter_exprs=None) 907 908 This method shall return a list of RectifiedDataset and 909 ReferenceableDataset wrappers contained in the dataset series. The 910 optional ``filter_exprs`` argument is expected to be a list of filter 911 expressions to be applied to the datasets or ``None``. In case no 912 contained dataset matches the filter expressions an empty list shall be 913 returned. 914 915 .. method:: contains(wrapper) 916 917 This method shall return ``True`` if the EO Coverage specified by 918 ``wrapper`` is contained in the Dataset Series, ``False`` otherwise. 919 920 """ 921 REGISTRY_CONF = { 922 "name": "Dataset Series Interface", 923 "intf_id": "resources.coverages.interfaces.DatasetSeries" 924 } 925 926 getType = Method( 927 returns=StringArg("@return") 928 ) 929 930 getEOCoverages = Method( 931 ListArg("filter_exprs", default=None), 932 returns=ListArg("@return") 933 ) 934 935 getDatasets = Method( 936 ListArg("filter_exprs", default=None), 937 returns=ListArg("@return") 938 ) 939 940 contains = Method( 941 ObjectArg("wrapper"), 942 returns=BoolArg("@return") 943 )
944
945 -class ManagerInterface(RegisteredInterface):
946 """ 947 This is an interface for coverage and dataset series managers. These 948 managers shall facilitate registration of data in the database providing an 949 easy-to-use interface for application programmers. 950 951 Managers are bound to a certain resource type, e.g. a DatasetSeries or a 952 RectifiedStitchedMosaic. It suffices to have one manager per resource type 953 as it can be invoked for many objects of this type. 954 955 .. method:: acquireID(obj_id=None, fail=False) 956 957 This method shall acquire a valid and unique object ID and return it. 958 The caller can provide a suggestion ``obj_id``. In this case, the 959 method shall try to acquire this object ID. The optional ``fail`` 960 argument determines what the method shall do in case it cannot acquire 961 the given ``obj_id``. If it is set to ``True``, the method shall raise 962 an exception, otherwise it shall degrade gracefully returning a newly 963 generated object ID. 964 965 The implementation should be able to guarantee that the acquired ID 966 cannot be used by other threads of execution unless it is released 967 and left unused. If it cannot assure this, the deviation shall be 968 documented with a warning. 969 970 .. method:: releaseID(obj_id) 971 972 This method shall release an object ID ``obj_id`` that has been 973 acquired with :meth:`acquireID` beforehand. In case the object ID has 974 been left unused, it shall be free to be acquired again. 975 976 .. method:: create(obj_id=None, **kwargs) 977 978 This method shall create and return a coverage or dataset series wrapper 979 from the attributes given in ``kwargs``. The actual range of keyword 980 arguments accepted may depend on the resource type and the 981 implementation. 982 983 If the ``obj_id`` argument is omitted a new object ID shall be generated 984 using the same mechanism as :meth:`acquireID`. If the provided object ID 985 is invalid or already in use, appropriate exceptions shall be raised. 986 987 .. method:: update(obj_id, **kwargs) 988 989 This method shall update the coverage or dataset series with ID 990 ``obj_id`` with new parameters provided as keyword arguments. The actual 991 range of keyword arguments accepted may depend on the resource type and 992 the implementation and should correlate with the arguments accepted by 993 :meth:`create` as far as possible. 994 995 The method shall return the updated coverage or dataset series wrapper. 996 997 It shall raise :exc:`~.NoSuchCoverage` if there is no coverage or 998 dataset series with ID ``obj_id``. 999 1000 .. method:: delete(obj_id) 1001 1002 This method shall delete the coverage or dataset with ID ``obj_id``. 1003 1004 It shall raise :exc:`~.NoSuchCoverage` if there is no coverage or 1005 dataset series with ID ``obj_id``. 1006 """ 1007 REGISTRY_CONF = { 1008 "name": "Manager Interface for EO Objects", 1009 "intf_id": "resources.coverages.interfaces.Manager", 1010 "binding_method": "kvp", 1011 "registry_keys": ( 1012 "resources.coverages.interfaces.res_type", 1013 ) 1014 } 1015 1016 create = Method( 1017 StringArg("obj_id", default=None), 1018 StringArg("request_id", default=None), 1019 KwArgs("kwargs"), 1020 returns = ObjectArg("@return") 1021 ) 1022 1023 update = Method( 1024 StringArg("obj_id"), 1025 DictArg("link"), 1026 DictArg("unlink"), 1027 DictArg("set"), 1028 returns = ObjectArg("@return") 1029 ) 1030 1031 delete = Method( 1032 StringArg("obj_id") 1033 ) 1034 1035 synchronize = Method( 1036 StringArg("obj_id") 1037 )
1038