Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor geometry.Polygon #301

Closed
cleder opened this issue Jan 19, 2024 · 1 comment
Closed

Refactor geometry.Polygon #301

cleder opened this issue Jan 19, 2024 · 1 comment

Comments

@cleder
Copy link
Owner

cleder commented Jan 19, 2024

A Polygon is expressed in KML as:

<Polygon id="ID">
  <!-- specific to Polygon -->
  <extrude>0</extrude>                       <!-- boolean -->
  <tessellate>0</tessellate>                 <!-- boolean -->
  <altitudeMode>clampToGround</altitudeMode>
        <!-- kml:altitudeModeEnum: clampToGround, relativeToGround, or absolute -->
        <!-- or, substitute gx:altitudeMode: clampToSeaFloor, relativeToSeaFloor -->
  <outerBoundaryIs>
    <LinearRing>
      <coordinates>...</coordinates>         <!-- lon,lat[,alt] -->
    </LinearRing>
  </outerBoundaryIs>
  <innerBoundaryIs>
    <LinearRing>
      <coordinates>...</coordinates>         <!-- lon,lat[,alt] -->
    </LinearRing>
  </innerBoundaryIs>
</Polygon>

Normalize fastkml.geometry.Polygon to take parameters shell and holes:

class Polygon(_Geometry):
    def __init__(
        self,
        *,
        ns: Optional[str] = None,
        name_spaces: Optional[Dict[str, str]] = None,
        id: Optional[str] = None,
        target_id: Optional[str] = None,
        extrude: Optional[bool] = None,
        tessellate: Optional[bool] = None,
        altitude_mode: Optional[AltitudeMode] = None,
        shell: Optional[Shell] = None,
        holes: Iterable[Holes] = None,
        geometry: geo.Polygon,
    ) -> None:

Shell should be a BaseObject, or XMLObject which takes a fastkml.geometry.LinearRing as kml_geometry parameter
Holes should be a BaseObject, or XMLObject which takes an Iterable[fastkml.geometry.LinearRing] as kml_geometry parameter

Tag name to be overwritten for Shell as

    @classmethod
    def get_tag_name(cls) -> str:
         return 'outerBoundaryIs'

and similar for Holes

Then it should be possible to use the registry and remove the custom etree_element and _get_geometry methods.

@cleder
Copy link
Owner Author

cleder commented Apr 21, 2024

see also: #316

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

1 participant