From f71cc14bd1b807bbc1599df3930171e375fab62c Mon Sep 17 00:00:00 2001 From: abodeuis <54557445+abodeuis@users.noreply.github.com> Date: Mon, 15 Apr 2024 14:40:06 -0500 Subject: [PATCH] Added the easily fixed stuff that shouldn't need discussion (#23) * Added the easily fixed stuff that shouldn't need discussion * Updated docs and fixed lint * Change legend bbox to 2 point bounding box and added legend_contour which is the polygon bounding box * Fixed lint * Updated descriptions of coordinates for polygon, line and point features * Added model provence and formatted line and point features * added s back to features. * updated readme --------- Co-authored-by: marshHawk4 --- .gitignore | 5 +- README.md | 760 ++++++++++++----------- cdr_schemas/area_extraction.py | 24 +- cdr_schemas/common.py | 19 + cdr_schemas/feature_results.py | 58 +- cdr_schemas/features/line_features.py | 81 ++- cdr_schemas/features/point_features.py | 94 ++- cdr_schemas/features/polygon_features.py | 107 +++- 8 files changed, 667 insertions(+), 481 deletions(-) diff --git a/.gitignore b/.gitignore index 07ae849..bf5c19a 100644 --- a/.gitignore +++ b/.gitignore @@ -158,4 +158,7 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ -.ruff_cache \ No newline at end of file +.ruff_cache + +# Vscode +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index 61d5f73..ae4f127 100644 --- a/README.md +++ b/README.md @@ -66,28 +66,15 @@ poetry run docs ```mermaid classDiagram - class AreaType { - <> - Map_Area: str = 'Map_Area' - Legend_Area: str = 'Legend_Area' - CrossSection: str = 'CrossSection' - OCR: str = 'OCR' - Polygon_Legend_Area: str = 'Polygon_Legend_Area' - Line_Point_Legend_Area: str = 'Line_Point_Legend_Area' - Line_Legend_Area: str = 'Line_Legend_Area' - Point_Legend_Area: str = 'Point_Legend_Area' - Correlation_Diagram: str = 'Correlation_Diagram' - } - class Area_Extraction { type: GeomType = GeomType.Polygon coordinates: list[list[list[Union[float, int]]]] bbox: Optional[list[Union[float, int]]] category: AreaType text: Optional[str] - confidence: Optional[float] - model: Optional[str] - model_version: Optional[str] + model: Optional[str] = None + model_version: Optional[str] = None + confidence: Optional[float] = None } class GeomType { @@ -97,8 +84,21 @@ classDiagram Polygon: str = 'Polygon' } - Area_Extraction ..> AreaType + class AreaType { + <> + Map_Area: str = 'Map_Area' + Legend_Area: str = 'Legend_Area' + CrossSection: str = 'CrossSection' + OCR: str = 'OCR' + Polygon_Legend_Area: str = 'Polygon_Legend_Area' + Line_Point_Legend_Area: str = 'Line_Point_Legend_Area' + Line_Legend_Area: str = 'Line_Legend_Area' + Point_Legend_Area: str = 'Point_Legend_Area' + Correlation_Diagram: str = 'Correlation_Diagram' + } + Area_Extraction ..> GeomType + Area_Extraction ..> AreaType ``` @@ -113,10 +113,16 @@ classDiagram ```mermaid classDiagram - class GeoreferenceResult { - likely_CRSs: Optional[list[str]] - map_area: Optional[Area_Extraction] - projections: Optional[list[ProjectionResult]] + class Geom_Point { + latitude: Union[float, int, NoneType] + longitude: Union[float, int, NoneType] + type: GeomType = GeomType.Point + } + + class Pixel_Point { + rows_from_top: Union[float, int] + columns_from_left: Union[float, int] + type: GeomType = GeomType.Point } class Area_Extraction { @@ -125,22 +131,17 @@ classDiagram bbox: Optional[list[Union[float, int]]] category: AreaType text: Optional[str] - confidence: Optional[float] - model: Optional[str] - model_version: Optional[str] - } - - class GeomType { - <> - Point: str = 'Point' - LineString: str = 'LineString' - Polygon: str = 'Polygon' + model: Optional[str] = None + model_version: Optional[str] = None + confidence: Optional[float] = None } - class Pixel_Point { - rows_from_top: Union[float, int] - columns_from_left: Union[float, int] - type: GeomType = GeomType.Point + class GeoreferenceResults { + cog_id: str + georeference_results: Optional[list[GeoreferenceResult]] + gcps: Optional[list[GroundControlPoint]] + system: str + system_version: str } class ProjectionResult { @@ -149,6 +150,19 @@ classDiagram file_name: str } + class GeoreferenceResult { + likely_CRSs: Optional[list[str]] + map_area: Optional[Area_Extraction] + projections: Optional[list[ProjectionResult]] + } + + class GeomType { + <> + Point: str = 'Point' + LineString: str = 'LineString' + Polygon: str = 'Polygon' + } + class GroundControlPoint { gcp_id: str map_geom: Geom_Point @@ -159,30 +173,16 @@ classDiagram crs: Optional[str] } - class GeoreferenceResults { - cog_id: str - georeference_results: Optional[list[GeoreferenceResult]] - gcps: Optional[list[GroundControlPoint]] - system: str - system_version: str - } - - class Geom_Point { - latitude: Union[float, int, NoneType] - longitude: Union[float, int, NoneType] - type: GeomType = GeomType.Point - } - - Area_Extraction ..> AreaType Area_Extraction ..> GeomType + Area_Extraction ..> AreaType Geom_Point ..> GeomType Pixel_Point ..> GeomType GroundControlPoint ..> Geom_Point GroundControlPoint ..> Pixel_Point - GeoreferenceResult ..> Area_Extraction GeoreferenceResult ..> ProjectionResult - GeoreferenceResults ..> GeoreferenceResult + GeoreferenceResult ..> Area_Extraction GeoreferenceResults ..> GroundControlPoint + GeoreferenceResults ..> GeoreferenceResult ``` @@ -203,6 +203,21 @@ classDiagram non_rectangular: str = 'non_rectangular' } + class CogMetaData { + cog_id: str + system: str + system_version: str + multiple_maps: Optional[bool] + map_metadata: Optional[list[MapMetaData]] + } + + class MapColorSchemeTypes { + <> + full_color: str = 'full_color' + monochrome: str = 'monochrome' + grayscale: str = 'grayscale' + } + class MapMetaData { title: Optional[str] year: Optional[int] @@ -219,21 +234,6 @@ classDiagram model_version: str } - class CogMetaData { - cog_id: str - system: str - system_version: str - multiple_maps: Optional[bool] - map_metadata: Optional[list[MapMetaData]] - } - - class MapColorSchemeTypes { - <> - full_color: str = 'full_color' - monochrome: str = 'monochrome' - grayscale: str = 'grayscale' - } - MapMetaData ..> MapShapeTypes MapMetaData ..> MapColorSchemeTypes CogMetaData ..> MapMetaData @@ -251,82 +251,94 @@ classDiagram ```mermaid classDiagram - class Area_Extraction { - type: GeomType = GeomType.Polygon - coordinates: list[list[list[Union[float, int]]]] - bbox: Optional[list[Union[float, int]]] - category: AreaType - text: Optional[str] - confidence: Optional[float] - model: Optional[str] - model_version: Optional[str] - } - - class PointLegendAndFeaturesResult { - id: str - crs: str - cdr_projection_id: Optional[str] - name: Optional[str] - description: Optional[str] - legend_bbox: Optional[list[Union[float, int]]] - point_features: Optional[list[PointFeatureCollection]] - } - - class PolygonLegendAndFeauturesResult { + class PolygonLegendAndFeaturesResult { id: str - crs: str - cdr_projection_id: Optional[str] - map_unit: Optional[MapUnit] - abbreviation: Optional[str] - legend_bbox: Optional[list[Union[float, int]]] - category: Optional[str] - color: Optional[str] - description: Optional[str] - pattern: Optional[str] - polygon_features: Optional[PolygonFeatureCollection] + legend_provenance: Optional[ModelProvenance] = None + label: Optional[str] = None + abbreviation: Optional[str] = None + description: Optional[str] = None + legend_bbox: Optional[list[Union[float, int]]] = None + legend_contour: Optional[list[list[Union[float, int]]]] = None + color: Optional[str] = None + pattern: Optional[str] = None + category: Optional[str] = None + map_unit: Optional[MapUnit] = None + crs: Optional[str] = 'pixel' + cdr_projection_id: Optional[str] = None + polygon_features: Optional[PolygonFeatureCollection] = None } - class LineLegendAndFeaturesResult { + class PointLegendAndFeaturesResult { id: str - crs: str - cdr_projection_id: Optional[str] - name: Optional[str] - description: Optional[str] - legend_bbox: Optional[list[Union[float, int]]] - line_features: Optional[LineFeatureCollection] + legend_provenance: Optional[ModelProvenance] = None + name: Optional[str] = None + abbreviation: Optional[str] = None + description: Optional[str] = None + legend_bbox: Optional[list[Union[float, int]]] = None + legend_contour: Optional[list[list[Union[float, int]]]] = None + crs: Optional[str] = 'pixel' + cdr_projection_id: Optional[str] = None + point_features: Optional[list[PointFeatureCollection]] = None } - class FeatureResults { + class CogMetaData { cog_id: str - line_feature_results: Optional[list[LineLegendAndFeaturesResult]] - point_feature_results: Optional[list[PointLegendAndFeaturesResult]] - polygon_feature_results: Optional[list[PolygonLegendAndFeauturesResult]] - cog_area_extractions: Optional[list[Area_Extraction]] - cog_metadata_extractions: Optional[list[CogMetaData]] system: str system_version: str + multiple_maps: Optional[bool] + map_metadata: Optional[list[MapMetaData]] } - class CogMetaData { - cog_id: str + class FeatureResults { system: str system_version: str - multiple_maps: Optional[bool] - map_metadata: Optional[list[MapMetaData]] + cog_id: str + line_feature_results: Optional[list[LineLegendAndFeaturesResult]] = None + point_feature_results: Optional[list[PointLegendAndFeaturesResult]] = None + polygon_feature_results: Optional[list[PolygonLegendAndFeaturesResult]] = None + cog_area_extractions: Optional[list[Area_Extraction]] = None + cog_metadata_extractions: Optional[list[CogMetaData]] = None + } + + class Area_Extraction { + type: GeomType = GeomType.Polygon + coordinates: list[list[list[Union[float, int]]]] + bbox: Optional[list[Union[float, int]]] + category: AreaType + text: Optional[str] + model: Optional[str] = None + model_version: Optional[str] = None + confidence: Optional[float] = None + } + + class LineLegendAndFeaturesResult { + id: str + legend_provenance: Optional[ModelProvenance] = None + name: Optional[str] = None + abbreviation: Optional[str] = None + description: Optional[str] = None + legend_bbox: Optional[list[Union[float, int]]] = None + legend_contour: Optional[list[list[Union[float, int]]]] = None + crs: Optional[str] = 'pixel' + cdr_projection_id: Optional[str] = None + line_features: Optional[LineFeatureCollection] } - Area_Extraction ..> AreaType Area_Extraction ..> GeomType + Area_Extraction ..> AreaType + LineLegendAndFeaturesResult ..> ModelProvenance LineLegendAndFeaturesResult ..> LineFeatureCollection + PointLegendAndFeaturesResult ..> ModelProvenance PointLegendAndFeaturesResult ..> PointFeatureCollection - PolygonLegendAndFeauturesResult ..> PolygonFeatureCollection - PolygonLegendAndFeauturesResult ..> MapUnit + PolygonLegendAndFeaturesResult ..> ModelProvenance + PolygonLegendAndFeaturesResult ..> PolygonFeatureCollection + PolygonLegendAndFeaturesResult ..> MapUnit CogMetaData ..> MapMetaData - FeatureResults ..> Area_Extraction + FeatureResults ..> PolygonLegendAndFeaturesResult FeatureResults ..> PointLegendAndFeaturesResult - FeatureResults ..> PolygonLegendAndFeauturesResult - FeatureResults ..> LineLegendAndFeaturesResult FeatureResults ..> CogMetaData + FeatureResults ..> Area_Extraction + FeatureResults ..> LineLegendAndFeaturesResult ``` @@ -341,30 +353,20 @@ classDiagram ```mermaid classDiagram - class PointProperties { - model: Optional[str] - model_version: Optional[str] - confidence: Optional[float] - bbox: Optional[list[Union[float, int]]] - dip: Optional[int] - dip_direction: Optional[int] + class ModelProvenance { + model: Optional[str] = None + model_version: Optional[str] = None + confidence: Optional[float] = None } - class PointLegendAndFeaturesResult { - id: str - crs: str - cdr_projection_id: Optional[str] - name: Optional[str] - description: Optional[str] - legend_bbox: Optional[list[Union[float, int]]] - point_features: Optional[list[PointFeatureCollection]] + class PointFeatureCollection { + type: GeoJsonType = GeoJsonType.FeatureCollection + features: list[PointFeature] } - class GeomType { - <> - Point: str = 'Point' - LineString: str = 'LineString' - Polygon: str = 'Polygon' + class Point { + coordinates: list[Union[float, int]] + type: GeomType = GeomType.Point } class PointFeature { @@ -374,28 +376,48 @@ classDiagram properties: PointProperties } - class GeoJsonType { - <> - Feature: str = 'Feature' - FeatureCollection: str = 'FeatureCollection' + class PointLegendAndFeaturesResult { + id: str + legend_provenance: Optional[ModelProvenance] = None + name: Optional[str] = None + abbreviation: Optional[str] = None + description: Optional[str] = None + legend_bbox: Optional[list[Union[float, int]]] = None + legend_contour: Optional[list[list[Union[float, int]]]] = None + crs: Optional[str] = 'pixel' + cdr_projection_id: Optional[str] = None + point_features: Optional[list[PointFeatureCollection]] = None } - class Point { - coordinates: list[Union[float, int]] - type: GeomType = GeomType.Point + class PointProperties { + model: Optional[str] = None + model_version: Optional[str] = None + confidence: Optional[float] = None + bbox: Optional[list[Union[float, int]]] = None + dip: Optional[int] = None + dip_direction: Optional[int] = None } - class PointFeatureCollection { - type: GeoJsonType = GeoJsonType.FeatureCollection - features: list[PointFeature] + class GeomType { + <> + Point: str = 'Point' + LineString: str = 'LineString' + Polygon: str = 'Polygon' + } + + class GeoJsonType { + <> + Feature: str = 'Feature' + FeatureCollection: str = 'FeatureCollection' } Point ..> GeomType - PointFeature ..> GeoJsonType - PointFeature ..> PointProperties PointFeature ..> Point - PointFeatureCollection ..> GeoJsonType + PointFeature ..> PointProperties + PointFeature ..> GeoJsonType PointFeatureCollection ..> PointFeature + PointFeatureCollection ..> GeoJsonType + PointLegendAndFeaturesResult ..> ModelProvenance PointLegendAndFeaturesResult ..> PointFeatureCollection @@ -411,34 +433,30 @@ classDiagram ```mermaid classDiagram + class ModelProvenance { + model: Optional[str] = None + model_version: Optional[str] = None + confidence: Optional[float] = None + } + class Line { coordinates: list[list[Union[float, int]]] type: GeomType = GeomType.LineString } - class GeomType { - <> - Point: str = 'Point' - LineString: str = 'LineString' - Polygon: str = 'Polygon' - } - class LineLegendAndFeaturesResult { id: str - crs: str - cdr_projection_id: Optional[str] - name: Optional[str] - description: Optional[str] - legend_bbox: Optional[list[Union[float, int]]] + legend_provenance: Optional[ModelProvenance] = None + name: Optional[str] = None + abbreviation: Optional[str] = None + description: Optional[str] = None + legend_bbox: Optional[list[Union[float, int]]] = None + legend_contour: Optional[list[list[Union[float, int]]]] = None + crs: Optional[str] = 'pixel' + cdr_projection_id: Optional[str] = None line_features: Optional[LineFeatureCollection] } - class GeoJsonType { - <> - Feature: str = 'Feature' - FeatureCollection: str = 'FeatureCollection' - } - class DashType { <> solid: str = 'solid' @@ -446,6 +464,26 @@ classDiagram dotted: str = 'dotted' } + class LineProperty { + model: Optional[str] = None + model_version: Optional[str] = None + confidence: Optional[float] = None + dash_pattern: Optional[DashType] = None + symbol: Optional[str] = None + } + + class LineFeatureCollection { + type: GeoJsonType = GeoJsonType.FeatureCollection + features: Optional[list[LineFeature]] = None + } + + class GeomType { + <> + Point: str = 'Point' + LineString: str = 'LineString' + Polygon: str = 'Polygon' + } + class LineFeature { type: GeoJsonType = GeoJsonType.Feature id: str @@ -453,26 +491,20 @@ classDiagram properties: LineProperty } - class LineFeatureCollection { - type: GeoJsonType = GeoJsonType.FeatureCollection - features: Optional[list[LineFeature]] - } - - class LineProperty { - model: Optional[str] - model_version: Optional[str] - confidence: Optional[float] - dash_pattern: Optional[DashType] = None - symbol: Optional[str] + class GeoJsonType { + <> + Feature: str = 'Feature' + FeatureCollection: str = 'FeatureCollection' } Line ..> GeomType LineProperty ..> DashType + LineFeature ..> Line LineFeature ..> LineProperty LineFeature ..> GeoJsonType - LineFeature ..> Line - LineFeatureCollection ..> GeoJsonType LineFeatureCollection ..> LineFeature + LineFeatureCollection ..> GeoJsonType + LineLegendAndFeaturesResult ..> ModelProvenance LineLegendAndFeaturesResult ..> LineFeatureCollection @@ -488,75 +520,85 @@ classDiagram ```mermaid classDiagram - class GeomType { - <> - Point: str = 'Point' - LineString: str = 'LineString' - Polygon: str = 'Polygon' + class ModelProvenance { + model: Optional[str] = None + model_version: Optional[str] = None + confidence: Optional[float] = None } - class PolygonFeature { - type: GeoJsonType = GeoJsonType.Feature - id: str - geometry: Polygon - properties: PolygonProperty + class MapUnit { + age_text: Optional[str] = None + b_age: Optional[float] = None + b_interval: Optional[str] = None + lithology: Optional[str] = None + name: Optional[str] = None + t_age: Optional[float] = None + t_interval: Optional[str] = None + comments: Optional[str] = None } - class PolygonLegendAndFeauturesResult { - id: str - crs: str - cdr_projection_id: Optional[str] - map_unit: Optional[MapUnit] - abbreviation: Optional[str] - legend_bbox: Optional[list[Union[float, int]]] - category: Optional[str] - color: Optional[str] - description: Optional[str] - pattern: Optional[str] - polygon_features: Optional[PolygonFeatureCollection] + class Polygon { + coordinates: list[list[list[Union[float, int]]]] + type: GeomType = GeomType.Polygon } - class GeoJsonType { - <> - Feature: str = 'Feature' - FeatureCollection: str = 'FeatureCollection' + class PolygonLegendAndFeaturesResult { + id: str + legend_provenance: Optional[ModelProvenance] = None + label: Optional[str] = None + abbreviation: Optional[str] = None + description: Optional[str] = None + legend_bbox: Optional[list[Union[float, int]]] = None + legend_contour: Optional[list[list[Union[float, int]]]] = None + color: Optional[str] = None + pattern: Optional[str] = None + category: Optional[str] = None + map_unit: Optional[MapUnit] = None + crs: Optional[str] = 'pixel' + cdr_projection_id: Optional[str] = None + polygon_features: Optional[PolygonFeatureCollection] = None } class PolygonFeatureCollection { type: GeoJsonType = GeoJsonType.FeatureCollection - features: Optional[list[PolygonFeature]] + features: Optional[list[PolygonFeature]] = None + } + + class PolygonFeature { + type: GeoJsonType = GeoJsonType.Feature + id: str + geometry: Polygon + properties: PolygonProperty } class PolygonProperty { - model: Optional[str] - model_version: Optional[str] - confidence: Optional[float] + model: Optional[str] = None + model_version: Optional[str] = None + confidence: Optional[float] = None } - class Polygon { - coordinates: list[list[list[Union[float, int]]]] - type: GeomType = GeomType.Polygon + class GeomType { + <> + Point: str = 'Point' + LineString: str = 'LineString' + Polygon: str = 'Polygon' } - class MapUnit { - age_text: Optional[str] - b_age: Optional[float] - b_interval: Optional[str] - lithology: Optional[str] - name: Optional[str] - t_age: Optional[float] - t_interval: Optional[str] - comments: Optional[str] + class GeoJsonType { + <> + Feature: str = 'Feature' + FeatureCollection: str = 'FeatureCollection' } Polygon ..> GeomType PolygonFeature ..> PolygonProperty - PolygonFeature ..> GeoJsonType PolygonFeature ..> Polygon - PolygonFeatureCollection ..> GeoJsonType + PolygonFeature ..> GeoJsonType PolygonFeatureCollection ..> PolygonFeature - PolygonLegendAndFeauturesResult ..> PolygonFeatureCollection - PolygonLegendAndFeauturesResult ..> MapUnit + PolygonFeatureCollection ..> GeoJsonType + PolygonLegendAndFeaturesResult ..> ModelProvenance + PolygonLegendAndFeaturesResult ..> PolygonFeatureCollection + PolygonLegendAndFeaturesResult ..> MapUnit ``` @@ -577,6 +619,21 @@ classDiagram non_rectangular: str = 'non_rectangular' } + class CogMetaData { + cog_id: str + system: str + system_version: str + multiple_maps: Optional[bool] + map_metadata: Optional[list[MapMetaData]] + } + + class MapColorSchemeTypes { + <> + full_color: str = 'full_color' + monochrome: str = 'monochrome' + grayscale: str = 'grayscale' + } + class MapMetaData { title: Optional[str] year: Optional[int] @@ -593,21 +650,6 @@ classDiagram model_version: str } - class CogMetaData { - cog_id: str - system: str - system_version: str - multiple_maps: Optional[bool] - map_metadata: Optional[list[MapMetaData]] - } - - class MapColorSchemeTypes { - <> - full_color: str = 'full_color' - monochrome: str = 'monochrome' - grayscale: str = 'grayscale' - } - MapMetaData ..> MapShapeTypes MapMetaData ..> MapColorSchemeTypes CogMetaData ..> MapMetaData @@ -634,6 +676,12 @@ classDiagram system_version: str } + class DocumentProvenance { + external_system_name: str + external_system_id: Optional[str] = '' + external_system_url: Optional[str] = '' + } + class DocumentExtraction { id: UnionType[str, NoneType] = None document_id: str = None @@ -648,18 +696,6 @@ classDiagram system_version: str } - class Document { - id: str - title: str - is_open: bool - pages: int - size: int - provenance: list[DocumentProvenance] = list - metadata: Optional[DocumentMetaData] = None - system: str - system_version: str - } - class DocumentMetaData { doi: str = '' authors: list[str] = list @@ -671,10 +707,16 @@ classDiagram description: str = '' } - class DocumentProvenance { - external_system_name: str - external_system_id: Optional[str] = '' - external_system_url: Optional[str] = '' + class Document { + id: str + title: str + is_open: bool + pages: int + size: int + provenance: list[DocumentProvenance] = list + metadata: Optional[DocumentMetaData] = None + system: str + system_version: str } UploadDocument ..> DocumentMetaData @@ -695,9 +737,15 @@ classDiagram ```mermaid classDiagram - class PageInfo { - page: int - bounding_box: Optional[BoundingBox] + class BoundingBox { + x_min: float + x_max: float + y_min: float + y_max: float + } + + class Commodity { + name: str } class EvidenceLayer { @@ -705,28 +753,31 @@ classDiagram relevance_score: float } - class Reference { - document: Document - page_info: list[PageInfo] + class GeologyInfo { + age: Optional[str] + unit_name: Optional[str] + description: Optional[str] + lithology: Optional[list[str]] + process: Optional[list[str]] + environment: Optional[list[str]] + comments: Optional[str] } - class MineralSystem { - deposit_type: list[DepositType] - source: list[MappableCriteria] - pathway: list[MappableCriteria] - trap: Optional[list[MappableCriteria]] - preservation: Optional[list[MappableCriteria]] - energy: Optional[list[MappableCriteria]] - outflow: Optional[list[MappableCriteria]] + class Grade { + grade_unit: str + grade_value: float } - class ResourceReserveCategory { - <> - INFERRED: str = 'Inferred Mineral Resource' - INDICATED: str = 'Indicated Mineral Resource' - MEASURED: str = 'Measured Mineral Resource' - PROBABLE: str = 'Probable Mineral Reserve' - PROVEN: str = 'Proven Mineral Reserve' + class LocationInfo { + location: Geometry + crs: str + country: Optional[str] + state_or_province: Optional[str] + } + + class PageInfo { + page: int + bounding_box: Optional[BoundingBox] } class DepositTypeCandidate { @@ -736,31 +787,13 @@ classDiagram source: str } - class MappableCriteria { - criteria: str - theoretical: Optional[str] - potential_dataset: Optional[list[EvidenceLayer]] - supporting_references: list[Reference] - } - - class Ore { - ore_unit: str - ore_value: float - } - - class MineralSite { - source_id: str - record_id: str - name: Optional[str] - mineral_inventory: list[MineralInventory] - location_info: LocationInfo - geology_info: Optional[GeologyInfo] - deposit_type_candidate: list[DepositTypeCandidate] - } - - class Grade { - grade_unit: str - grade_value: float + class ResourceReserveCategory { + <> + INFERRED: str = 'Inferred Mineral Resource' + INDICATED: str = 'Indicated Mineral Resource' + MEASURED: str = 'Measured Mineral Resource' + PROBABLE: str = 'Probable Mineral Reserve' + PROVEN: str = 'Proven Mineral Reserve' } class Document { @@ -775,14 +808,25 @@ classDiagram system_version: str } - class GeologyInfo { - age: Optional[str] - unit_name: Optional[str] - description: Optional[str] - lithology: Optional[list[str]] - process: Optional[list[str]] - environment: Optional[list[str]] - comments: Optional[str] + class DepositType { + name: str + environment: str + group: str + } + + class MineralSite { + source_id: str + record_id: str + name: Optional[str] + mineral_inventory: list[MineralInventory] + location_info: LocationInfo + geology_info: Optional[GeologyInfo] + deposit_type_candidate: list[DepositTypeCandidate] + } + + class Ore { + ore_unit: str + ore_value: float } class MineralInventory { @@ -798,28 +842,9 @@ classDiagram zone: Optional[str] } - class DepositType { - name: str - environment: str - group: str - } - - class LocationInfo { - location: Geometry - crs: str - country: Optional[str] - state_or_province: Optional[str] - } - - class Commodity { - name: str - } - - class BoundingBox { - x_min: float - x_max: float - y_min: float - y_max: float + class Reference { + document: Document + page_info: list[PageInfo] } class Geometry { @@ -828,6 +853,23 @@ classDiagram Polygon: str = 'Polygon' } + class MineralSystem { + deposit_type: list[DepositType] + source: list[MappableCriteria] + pathway: list[MappableCriteria] + trap: Optional[list[MappableCriteria]] + preservation: Optional[list[MappableCriteria]] + energy: Optional[list[MappableCriteria]] + outflow: Optional[list[MappableCriteria]] + } + + class MappableCriteria { + criteria: str + theoretical: Optional[str] + potential_dataset: Optional[list[EvidenceLayer]] + supporting_references: list[Reference] + } + Document ..> DocumentMetaData Document ..> DocumentProvenance DepositTypeCandidate ..> DepositType @@ -836,19 +878,19 @@ classDiagram Reference ..> Document MappableCriteria ..> EvidenceLayer MappableCriteria ..> Reference - MineralSystem ..> MappableCriteria MineralSystem ..> DepositType + MineralSystem ..> MappableCriteria MineralInventory ..> datetime - MineralInventory ..> ResourceReserveCategory MineralInventory ..> Reference - MineralInventory ..> Ore + MineralInventory ..> ResourceReserveCategory MineralInventory ..> Commodity + MineralInventory ..> Ore MineralInventory ..> Grade LocationInfo ..> Geometry - MineralSite ..> LocationInfo MineralSite ..> MineralInventory - MineralSite ..> GeologyInfo MineralSite ..> DepositTypeCandidate + MineralSite ..> GeologyInfo + MineralSite ..> LocationInfo ``` @@ -863,6 +905,12 @@ classDiagram ```mermaid classDiagram + class MapResults { + cog_id: str + georef_results: Optional[list[GeoreferenceResults]] + extraction_results: Optional[list[FeatureResults]] + } + class GeoreferenceResults { cog_id: str georeference_results: Optional[list[GeoreferenceResult]] @@ -872,29 +920,23 @@ classDiagram } class FeatureResults { - cog_id: str - line_feature_results: Optional[list[LineLegendAndFeaturesResult]] - point_feature_results: Optional[list[PointLegendAndFeaturesResult]] - polygon_feature_results: Optional[list[PolygonLegendAndFeauturesResult]] - cog_area_extractions: Optional[list[Area_Extraction]] - cog_metadata_extractions: Optional[list[CogMetaData]] system: str system_version: str - } - - class MapResults { cog_id: str - georef_results: Optional[list[GeoreferenceResults]] - extraction_results: Optional[list[FeatureResults]] + line_feature_results: Optional[list[LineLegendAndFeaturesResult]] = None + point_feature_results: Optional[list[PointLegendAndFeaturesResult]] = None + polygon_feature_results: Optional[list[PolygonLegendAndFeaturesResult]] = None + cog_area_extractions: Optional[list[Area_Extraction]] = None + cog_metadata_extractions: Optional[list[CogMetaData]] = None } - FeatureResults ..> Area_Extraction + FeatureResults ..> PolygonLegendAndFeaturesResult FeatureResults ..> PointLegendAndFeaturesResult - FeatureResults ..> PolygonLegendAndFeauturesResult - FeatureResults ..> LineLegendAndFeaturesResult FeatureResults ..> CogMetaData - GeoreferenceResults ..> GeoreferenceResult + FeatureResults ..> Area_Extraction + FeatureResults ..> LineLegendAndFeaturesResult GeoreferenceResults ..> GroundControlPoint + GeoreferenceResults ..> GeoreferenceResult MapResults ..> GeoreferenceResults MapResults ..> FeatureResults diff --git a/cdr_schemas/area_extraction.py b/cdr_schemas/area_extraction.py index 7bc4bd5..038a1c4 100644 --- a/cdr_schemas/area_extraction.py +++ b/cdr_schemas/area_extraction.py @@ -24,10 +24,15 @@ class Area_Extraction(BaseModel): """ type: GeomType = GeomType.Polygon - coordinates: List[List[List[Union[float, int]]]] + coordinates: List[List[List[Union[float, int]]]] = Field( + description="""The coordinates of the areas boundry. Format is expected + to be [x,y] coordinate pairs where the top left is the + origin (0,0).""" + ) bbox: Optional[List[Union[float, int]]] = Field( - description="""The extacted bounding box of the area. - Column value from left, row value from bottom.""" + description="""The extracted bounding box of the area. + Format is expected to be [x1,y1,x2,y2] where the top left + is the origin (0,0).""", ) category: AreaType = Field( ..., @@ -41,12 +46,15 @@ class Area_Extraction(BaseModel): The text within the extraction area. """, ) - confidence: Optional[float] = Field( - description="The prediction probability from the ML model" + + # Model Provenance + model: Optional[str] = Field( + default=None, description="Name of the model used to generate this data" ) - model: Optional[str] = Field(description="model name used for extraction") model_version: Optional[str] = Field( - description="model version used for extraction" + default=None, description="Version of the model used to generate this data" ) - model_config = ConfigDict(protected_namespaces=()) + confidence: Optional[float] = Field( + default=None, description="The prediction confidence of the model" + ) diff --git a/cdr_schemas/common.py b/cdr_schemas/common.py index b06a1c0..81b6ad1 100644 --- a/cdr_schemas/common.py +++ b/cdr_schemas/common.py @@ -1,4 +1,10 @@ from enum import Enum +from typing import Optional + +from pydantic import BaseModel, ConfigDict, Field + +# Constant for defining that a projection is in pixel coordinates +CRITICALMAAS_PIXEL = "pixel" class GeomType(str, Enum): @@ -10,3 +16,16 @@ class GeomType(str, Enum): class GeoJsonType(str, Enum): Feature = "Feature" FeatureCollection = "FeatureCollection" + + +class ModelProvenance(BaseModel): + model: Optional[str] = Field( + default=None, description="Name of the model used to generate this data" + ) + model_version: Optional[str] = Field( + default=None, description="Version of the model used to generate this data" + ) + model_config = ConfigDict(protected_namespaces=()) + confidence: Optional[float] = Field( + default=None, description="The prediction confidence of the model" + ) diff --git a/cdr_schemas/feature_results.py b/cdr_schemas/feature_results.py index dcd8c3a..baec9ab 100644 --- a/cdr_schemas/feature_results.py +++ b/cdr_schemas/feature_results.py @@ -5,7 +5,7 @@ from cdr_schemas.area_extraction import Area_Extraction from cdr_schemas.features.line_features import LineLegendAndFeaturesResult from cdr_schemas.features.point_features import PointLegendAndFeaturesResult -from cdr_schemas.features.polygon_features import PolygonLegendAndFeauturesResult +from cdr_schemas.features.polygon_features import PolygonLegendAndFeaturesResult from cdr_schemas.metadata import CogMetaData @@ -14,51 +14,31 @@ class FeatureResults(BaseModel): Feature Extraction Results. """ - cog_id: str = Field( - ..., - description=""" - Cog id. - """, + system: str = Field(description="The name of the system used to generate results.") + system_version: str = Field( + description="The version of the system used to generate results." ) + cog_id: str = Field(description="Cog id.") line_feature_results: Optional[List[LineLegendAndFeaturesResult]] = Field( - ..., - description=""" - A list of legend extractions with associated line feature results. - """, + default=None, + description="""A list of legend extractions with associated line + feature results.""", ) point_feature_results: Optional[List[PointLegendAndFeaturesResult]] = Field( - ..., - description=""" - A list of legend extractions with associated point feature results. - """, + default=None, + description="""A list of legend extractions with associated point + feature results.""", ) - polygon_feature_results: Optional[List[PolygonLegendAndFeauturesResult]] = Field( - ..., - description=""" - A list of legend extractions with associated polygon feature results. - """, + polygon_feature_results: Optional[List[PolygonLegendAndFeaturesResult]] = Field( + default=None, + description="""A list of legend extractions with associated polygon + feature results.""", ) cog_area_extractions: Optional[List[Area_Extraction]] = Field( - ..., - description=""" - Higher level extraction pulled off a cog - legend area, map area, ocr text area, etc. - """, + default=None, + description="""Higher level extraction pulled off a cog - legend area, + map area, ocr text area, etc.""", ) cog_metadata_extractions: Optional[List[CogMetaData]] = Field( - ..., - description=""" - Metadata extractions pulled off a cog. - """, - ) - system: str = Field( - ..., - description=""" - The name of the system used. - """, - ) - system_version: str = Field( - ..., - description=""" - The version of the system used. - """, + default=None, description="Metadata extractions pulled off a cog." ) diff --git a/cdr_schemas/features/line_features.py b/cdr_schemas/features/line_features.py index 75bbffd..dab6934 100644 --- a/cdr_schemas/features/line_features.py +++ b/cdr_schemas/features/line_features.py @@ -3,7 +3,12 @@ from pydantic import BaseModel, ConfigDict, Field -from cdr_schemas.common import GeoJsonType, GeomType +from cdr_schemas.common import ( + CRITICALMAAS_PIXEL, + GeoJsonType, + GeomType, + ModelProvenance, +) class DashType(str, Enum): @@ -14,10 +19,14 @@ class DashType(str, Enum): class Line(BaseModel): """ - coordinates in line are (column from left, row from bottom). + Individual line segmentation of a line feature. """ - coordinates: List[List[Union[float, int]]] + coordinates: List[List[Union[float, int]]] = Field( + description="""The coordinates of the line. Format is expected to + be [x,y] coordinate pairs where the top left is the origin + (0,0).""" + ) type: GeomType = GeomType.LineString @@ -26,19 +35,25 @@ class LineProperty(BaseModel): Properties of the line. """ - model: Optional[str] = Field(description="model name used for extraction") + # Model Provenance + model: Optional[str] = Field( + default=None, description="Name of the model used to generate this data" + ) model_version: Optional[str] = Field( - description="model version used for extraction" + default=None, description="Version of the model used to generate this data" ) + model_config = ConfigDict(protected_namespaces=()) confidence: Optional[float] = Field( - description="The prediction probability from the ML model" + default=None, description="The prediction confidence of the model" ) + + # Line Properties dash_pattern: Optional[DashType] = Field( default=None, description="values = {solid, dash, dotted}" ) - symbol: Optional[str] - - model_config = ConfigDict(protected_namespaces=()) + symbol: Optional[str] = Field( # TODO add description + default=None, description="TODO : Add description" + ) class LineFeature(BaseModel): @@ -61,7 +76,7 @@ class LineFeatureCollection(BaseModel): """ type: GeoJsonType = GeoJsonType.FeatureCollection - features: Optional[List[LineFeature]] + features: Optional[List[LineFeature]] = None class LineLegendAndFeaturesResult(BaseModel): @@ -70,16 +85,44 @@ class LineLegendAndFeaturesResult(BaseModel): """ id: str = Field(description="your internal id") - crs: str = Field(description="values={CRITICALMAAS:pixel, EPSG:*}") - cdr_projection_id: Optional[str] = Field( - description=""" - A cdr projection id used to georeference the features - """ + + # Legend Fields + # TODO move to a more sensible location + legend_provenance: Optional[ModelProvenance] = Field( + default=None, description="Where the data originated from." + ) + name: Optional[str] = Field( + default=None, description="Label of the map unit in the legend" + ) + abbreviation: Optional[str] = Field( + default=None, description="Abbreviation of the map unit label." + ) + description: Optional[str] = Field( + default=None, description="Description of the map unit in the legend" ) - name: Optional[str] - description: Optional[str] legend_bbox: Optional[List[Union[float, int]]] = Field( - description="""The extacted bounding box of the legend item. - Column value from left, row value from bottom.""" + default=None, + description="""The rough 2 point bounding box of the map units label. + Format is expected to be [x1,y1,x2,y2] where the top left + is the origin (0,0).""", + ) + legend_contour: Optional[List[List[Union[float, int]]]] = Field( + default=None, + description="""The more precise polygon bounding box of the map units + label. Format is expected to be [x,y] coordinate pairs + where the top left is the origin (0,0).""", + ) + + # Segmentation Fields + crs: Optional[str] = Field( + default=CRITICALMAAS_PIXEL, + description="""What projection the geometry of the segmentation are in, + Default is CRITICALMAAS_PIXEL which specifies pixel coordinates. + Possible values are {CRITICALMAAS_PIXEL, EPSG:*}""", + ) + cdr_projection_id: Optional[str] = Field( + default=None, + description="""If non-pixel coordinates are used the cdr projection id of the + georeference that was used to create them is required.""", ) line_features: Optional[LineFeatureCollection] diff --git a/cdr_schemas/features/point_features.py b/cdr_schemas/features/point_features.py index b5c9ff6..4e7ad4d 100644 --- a/cdr_schemas/features/point_features.py +++ b/cdr_schemas/features/point_features.py @@ -2,15 +2,23 @@ from pydantic import BaseModel, ConfigDict, Field -from cdr_schemas.common import GeoJsonType, GeomType +from cdr_schemas.common import ( + CRITICALMAAS_PIXEL, + GeoJsonType, + GeomType, + ModelProvenance, +) class Point(BaseModel): """ - coordinates in line are (column from left, row from bottom). + Individual occurance of a point feature. """ - coordinates: List[Union[float, int]] + coordinates: List[Union[float, int]] = Field( + description="""The coordinates of the point. Format is expected to be an + [x,y] coordinate where the top left is the origin (0,0).""" + ) type: GeomType = GeomType.Point @@ -19,21 +27,31 @@ class PointProperties(BaseModel): Properties of the Point. """ - model: Optional[str] = Field(description="model name used for extraction") + # Model Provenance + model: Optional[str] = Field( + default=None, description="Name of the model used to generate this data" + ) model_version: Optional[str] = Field( - description="model version used for extraction" + default=None, description="Version of the model used to generate this data" ) + model_config = ConfigDict(protected_namespaces=()) confidence: Optional[float] = Field( - description="The prediction probability from the ML model" + default=None, description="The prediction confidence of the model" ) + + # Point Properties bbox: Optional[List[Union[float, int]]] = Field( - description="""The extacted bounding box of the point item. - Column value from left, row value from bottom.""" + default=None, + description="""The extacted 2 point bounding box of the point item. + Format is expected to be [x1,y1,x2,y2] where the top left + is the origin (0,0).""", + ) + dip: Optional[int] = Field( # TODO add description + default=None, description="TODO : Add description" + ) + dip_direction: Optional[int] = Field( # TODO add description + default=None, description="TODO : Add description" ) - dip: Optional[int] - dip_direction: Optional[int] - - model_config = ConfigDict(protected_namespaces=()) class PointFeature(BaseModel): @@ -65,18 +83,46 @@ class PointLegendAndFeaturesResult(BaseModel): """ id: str = Field(description="your internal id") - crs: str = Field(description="values={CRITICALMAAS:pixel, EPSG:*}") - cdr_projection_id: Optional[str] = Field( - description=""" - A cdr projection id used to georeference the features - """ + + # Legend Fields + # TODO move to a more sensible location + legend_provenance: Optional[ModelProvenance] = Field( + default=None, description="Where the data originated from." + ) + name: Optional[str] = Field( + default=None, description="Label of the map unit in the legend" + ) + abbreviation: Optional[str] = Field( + default=None, description="Abbreviation of the map unit label." + ) + description: Optional[str] = Field( + default=None, description="Description of the map unit in the legend" ) - name: Optional[str] = Field(description="name of legend item") - description: Optional[str] legend_bbox: Optional[List[Union[float, int]]] = Field( - description=""" - The extacted bounding box of the legend item. - Column value from left, row value from bottom. - """ + default=None, + description="""The rough 2 point bounding box of the map units label. + Format is expected to be [x1,y1,x2,y2] where the top left + is the origin (0,0).""", + ) + legend_contour: Optional[List[List[Union[float, int]]]] = Field( + default=None, + description="""The more precise polygon bounding box of the map units + label. Format is expected to be [x,y] coordinate pairs + where the top left is the origin (0,0).""", + ) + + # Segmentation Fields + crs: Optional[str] = Field( + default=CRITICALMAAS_PIXEL, + description="""What projection the geometry of the segmentation are in, + Default is CRITICALMAAS_PIXEL which specifies pixel coordinates. + Possible values are {CRITICALMAAS_PIXEL, EPSG:*}""", + ) + cdr_projection_id: Optional[str] = Field( + default=None, + description="""If non-pixel coordinates are used the cdr projection id of the + georeference that was used to create them is required.""", + ) + point_features: Optional[List[PointFeatureCollection]] = Field( + default=None, description="All point features for legend item." ) - point_features: Optional[List[PointFeatureCollection]] diff --git a/cdr_schemas/features/polygon_features.py b/cdr_schemas/features/polygon_features.py index 1572504..cacaff4 100644 --- a/cdr_schemas/features/polygon_features.py +++ b/cdr_schemas/features/polygon_features.py @@ -2,15 +2,24 @@ from pydantic import BaseModel, ConfigDict, Field -from cdr_schemas.common import GeoJsonType, GeomType +from cdr_schemas.common import ( + CRITICALMAAS_PIXEL, + GeoJsonType, + GeomType, + ModelProvenance, +) class Polygon(BaseModel): """ - coordinates in line are (column from left, row from bottom). + Individual polygon segmentation of a polygon feature. """ - coordinates: List[List[List[Union[float, int]]]] + coordinates: List[List[List[Union[float, int]]]] = Field( + description="""The coordinates of the polygon. Format is expected to + be [x,y] coordinate pairs where the top left is the origin + (0,0).""" + ) type: GeomType = GeomType.Polygon @@ -19,12 +28,14 @@ class PolygonProperty(BaseModel): Properties of the polygon. """ - model: Optional[str] = Field(description="model name used for extraction") + model: Optional[str] = Field( + default=None, description="Name of the model used for extraction" + ) model_version: Optional[str] = Field( - description="model version used for extraction" + default=None, description="Version of the model used for extraction" ) confidence: Optional[float] = Field( - description="The prediction probability from the ML model" + default=None, description="The prediction confidence of the model" ) model_config = ConfigDict(protected_namespaces=()) @@ -50,7 +61,7 @@ class PolygonFeatureCollection(BaseModel): """ type: GeoJsonType = GeoJsonType.FeatureCollection - features: Optional[List[PolygonFeature]] + features: Optional[List[PolygonFeature]] = None class MapUnit(BaseModel): @@ -58,36 +69,70 @@ class MapUnit(BaseModel): Map unit information for legend item. """ - age_text: Optional[str] - b_age: Optional[float] - b_interval: Optional[str] - lithology: Optional[str] - name: Optional[str] - t_age: Optional[float] - t_interval: Optional[str] - comments: Optional[str] + # TODO Someone needs to add full descriptions to these fields + age_text: Optional[str] = None + b_age: Optional[float] = None + b_interval: Optional[str] = None + lithology: Optional[str] = None + name: Optional[str] = None + t_age: Optional[float] = None + t_interval: Optional[str] = None + comments: Optional[str] = None -class PolygonLegendAndFeauturesResult(BaseModel): +class PolygonLegendAndFeaturesResult(BaseModel): """ - Polygon legend item metadata along with associated polygon features found. + Polygon map unit metadata along with associated polygon segmentation found. """ id: str = Field(description="your internal id") - crs: str = Field(description="values={CRITICALMAAS:pixel, EPSG:*}") - cdr_projection_id: Optional[str] = Field( - description=""" - A cdr projection id used to georeference the features - """ + + # Legend Fields + # TODO move to a more sensible location + legend_provenance: Optional[ModelProvenance] = Field( + default=None, description="Where the data originated from." + ) + label: Optional[str] = Field(default=None, description="Label of the map unit") + abbreviation: Optional[str] = Field( + default=None, description="Abbreviation of the map unit label." + ) + description: Optional[str] = Field( + default=None, description="Description of the map unit" ) - map_unit: Optional[MapUnit] - abbreviation: Optional[str] legend_bbox: Optional[List[Union[float, int]]] = Field( - description="""The extacted bounding box of the legend item. - Column value from left, row value from bottom.""" + default=None, + description="""The rough 2 point bounding box of the map units label. + Format is expected to be [x1,y1,x2,y2] where the top left + is the origin (0,0).""", + ) + legend_contour: Optional[List[List[Union[float, int]]]] = Field( + default=None, + description="""The more precise polygon bounding box of the map units + label. Format is expected to be [x,y] coordinate pairs + where the top left is the origin (0,0).""", + ) + color: Optional[str] = Field(default=None, description="The color of the map unit") + pattern: Optional[str] = Field( + default=None, description="The pattern of the map unit" + ) + ### TODO Agreed on Apr 15th call that category can be removed + category: Optional[str] = Field(default=None, description="TODO - what is this?") + map_unit: Optional[MapUnit] = Field( + default=None, description="Human annotated information on the map unit" + ) + + # Segmentation Fields + crs: Optional[str] = Field( + default=CRITICALMAAS_PIXEL, + description="""What projection the geometry of the segmentation are in, + Default is CRITICALMAAS_PIXEL which specifies pixel coordinates. + Possible values are {CRITICALMAAS_PIXEL, EPSG:*}""", + ) + cdr_projection_id: Optional[str] = Field( + default=None, + description="""If non-pixel coordinates are used the cdr projection id of the + georeference that was used to create them is required.""", + ) + polygon_features: Optional[PolygonFeatureCollection] = Field( + default=None, description="All polygon features for legend item." ) - category: Optional[str] - color: Optional[str] - description: Optional[str] - pattern: Optional[str] - polygon_features: Optional[PolygonFeatureCollection]