Skip to content

Commit

Permalink
merge main into cma
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmuelle committed Jul 8, 2024
2 parents efb6b9b + 1b66dfa commit e70e659
Show file tree
Hide file tree
Showing 8 changed files with 810 additions and 568 deletions.
880 changes: 424 additions & 456 deletions README.md

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions cdr_schemas/cdr_responses/area_extractions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from typing import List, Optional, Union

from pydantic import BaseModel, Field

from cdr_schemas.area_extraction import AreaType
from cdr_schemas.cdr_responses.features import ProjectedFeature
from cdr_schemas.features.polygon_features import Polygon


class AreaExtractionResponse(BaseModel):
area_extraction_id: str = Field(default="", description="Area extraction id")
cog_id: str = Field(default="", description="Cog id")
reference_id: Union[str, None] = Field(
default=None, description="Legend id of older version of this legend item."
)
px_bbox: List[Union[float, int]] = Field(
default_factory=list,
description="""The rough 2 point bounding box of the item.
Format is expected to be [x1,y1,x2,y2].""",
)
px_geojson: Optional[Polygon]
system: str = Field(default="", description="System that published this item")
system_version: str = Field(
default="", description="System version that published this item"
)
model_id: str = Field(
default="", description="Model id for the model used to generate this item"
)
validated: bool = Field(default=False, description="Validated by human")
confidence: Optional[float] = None
category: AreaType = Field(
...,
description="""
The type of area extraction.
""",
)
text: str = Field(
default="",
description="""
The text within the extraction area.
""",
)
projected_feature: List[ProjectedFeature] = Field(
default_factory=list,
description="""
List of projected versions of this feature. Probably will only be one result.
""",
)
133 changes: 133 additions & 0 deletions cdr_schemas/cdr_responses/features.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
from typing import Any, List, Optional, Union

from pydantic import BaseModel, Field

from cdr_schemas.features.line_features import Line
from cdr_schemas.features.point_features import Point
from cdr_schemas.features.polygon_features import Polygon


class ProjectedFeature(BaseModel):
cdr_projection_id: str = Field(
description="CDR projection id used for creating transform"
)
feature_type: str = Field(description="Feature type. E.g. polygon, point, line")
projected_geojson: Optional[Union[Polygon, Point, Line]] = Field(
description="Projected geojson in EPSG 4326"
)
projected_bbox: List[Union[float, int]] = Field(
default_factory=list, description="Projected bbox in EPSG 4326"
)


class PolygonExtractionResponse(BaseModel):
polygon_id: str = Field(default="", description="CDR polygon id")
cog_id: str = Field(default="", description="Cog id")
px_bbox: List[Union[float, int]] = Field(
default_factory=list,
description="""The rough 2 point bounding box of the item.
Format is expected to be [x1,y1,x2,y2].""",
)
px_geojson: Polygon
reference_id: Union[str, None] = Field(
default=None, description="Polygon id of older version of this polygon."
)
confidence: Optional[float] = None
model_id: str = Field(
default="", description="CDR model id for the model used to generate this item"
)
system: str = Field(default="", description="System that published this item")
system_version: str = Field(
default="", description="System version that published this item"
)
validated: bool = Field(default=False, description="Validated by human")
legend_id: str = Field(default="", description="Associated CDR legend id")
projected_feature: List[ProjectedFeature] = Field(
default_factory=list,
description="""
List of projected versions of this feature. Probably will only be one result.
""",
)
legend_item: Optional[Any] = Field(
default=None,
description="Some CDR endpoints can allow legend item data attached to each feature.",
)


class PointExtractionResponse(BaseModel):
point_id: str = Field(default="", description="CDR point id")
cog_id: str = Field(default="", description="Cog id")
px_bbox: List[Union[float, int]] = Field(
default_factory=list,
description="""The rough 2 point bounding box of the item.
Format is expected to be [x1,y1,x2,y2].""",
)
px_geojson: Point
dip: Optional[Union[int, None]] = Field(
default=None, description="Point dip value."
)
dip_direction: Optional[Union[int, None]] = Field(
default=None, description="Point dip direction value."
)
reference_id: Union[str, None] = Field(
default=None, description="Point id of older version of this point."
)
confidence: Optional[float] = None
model_id: str = Field(
default="",
description="""
Model id associated with the model and version used to generate this item
""",
)
system: str = Field(default="", description="System that published this item")
system_version: str = Field(
default="", description="System Version that published this item"
)
validated: bool = Field(default=False, description="Validated by human")
legend_id: str = Field(default="", description="Associated legend id")
projected_feature: List[ProjectedFeature] = Field(
default_factory=list,
description="""
List of projected versions of this feature. Probably will only be one result.
""",
)
legend_item: Optional[Any] = Field(
default=None,
description="Some CDR endpoints can allow legend item data attached to each feature",
)


class LineExtractionResponse(BaseModel):
line_id: str = Field(default="", description="CDR line id")
cog_id: str = Field(default="", description="Cog id")
px_bbox: List[Union[float, int]] = Field(
default_factory=list,
description="""The rough 2 point bounding box of the item.
Format is expected to be [x1,y1,x2,y2].""",
)
px_geojson: Line
dash_pattern: str = Field(default="", description="Dash pattern of line")
symbol: str = Field(default="", description="Symbol on line")
reference_id: Union[str, None] = Field(
default=None, description="Line id of older version of this line."
)
confidence: Optional[float] = None
model_id: str = Field(
default="", description="model id for the model used to generate this item"
)
system: str = Field(default="", description="System that published this item")
system_version: str = Field(
default="", description="System version that published this item"
)
validated: bool = Field(default=False, description="Validated by human")
legend_id: str = Field(default="", description="Associated legend id")
projected_feature: List[ProjectedFeature] = Field(
default_factory=list,
description="""
List of projected versions of this feature. Probably will only be one result.
""",
)
legend_item: Optional[Any] = Field(
default=None,
description="Some CDR endpoints can allow a legend item data attached to each feature.",
)
61 changes: 61 additions & 0 deletions cdr_schemas/cdr_responses/legend_items.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from typing import List, Optional, Union

from pydantic import BaseModel, Field

from cdr_schemas.cdr_responses.features import (
LineExtractionResponse,
PointExtractionResponse,
PolygonExtractionResponse,
)
from cdr_schemas.features.polygon_features import Polygon


class LegendItemResponse(BaseModel):
legend_id: str = Field(default="", description="CDR legend id")
abbreviation: str = Field(default="", description="Abbreviation of legend item")
description: str = Field(default="", description="Legend item description")
color: str = Field(default="", description="Color")
reference_id: Union[str, None] = Field(
default=None, description="Legend id of older version of this legend item."
)
label: str = Field(default="", description="Label of legend item")
pattern: str = Field(
default="",
description="If category of type polygon this can be filled in with pattern type",
)
px_bbox: List[Union[float, int]] = Field(
default_factory=list,
description="""The rough 2 point bounding box of the item.
Format is expected to be [x1,y1,x2,y2].""",
)
px_geojson: Optional[Polygon]
cog_id: str = Field(default="", description="Cog id")
category: str = Field(
default="", description="Category of legend item. Polygon, point, or line."
)
system: str = Field(default="", description="System that published this item")
system_version: str = Field(
default="", description="System version that published this item"
)
model_id: str = Field(
default="", description="Model id for the model used to generate this item"
)
validated: bool = Field(default=False, description="Validated by human")
confidence: Optional[float] = None
map_unit_age_text: str = Field(default="", description="Age of map unit")
map_unit_lithology: str = Field(default="", description="Map unit lithology")
map_unit_b_age: Optional[float] = None
map_unit_t_age: Optional[float] = None

point_extractions: List[PointExtractionResponse] = Field(
default_factory=list,
description="Optionally added point extractions associated with this legend item",
)
polygon_extractions: List[PolygonExtractionResponse] = Field(
default_factory=list,
description="Optionally added polygon extractions associated with this legend item",
)
line_extractions: List[LineExtractionResponse] = Field(
default_factory=list,
description="Optionally added line extractions associated with this legend item",
)
2 changes: 1 addition & 1 deletion cdr_schemas/features/point_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class PointProperties(BaseModel):
)

# Point Properties
bbox: Optional[List[Union[float, int]]] = Field(
bbox: List[Union[float, int]] = Field(
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
Expand Down
Loading

0 comments on commit e70e659

Please sign in to comment.