Skip to content

Use Pygeoif 1.0Β #132

Closed
Closed

Description

@cleder

Pygeoif has breaking changes from version 0.7 to 1.0.

Activity

  1. MrNaif2018 commented on Oct 2, 2021

    @MrNaif2018
    Contributor

    Hello! I would like to work on this. Should it use the beta version of pygeoif? Like migrate to using 1.0 interface with pygeoif>=1.0 constraint, and pip (as far as I remember) will pick beta versions for now, and when stable version is released it will pick it up?
    EDIT: actually installing pygeoif only worked with --pre flag

  2. MrNaif2018 commented on Oct 2, 2021

    @MrNaif2018
    Contributor

    I am having many test failures related to geometry objects not being iterable. Is it a bug in pygeoif or is it intended to be so? Not sure yet how to proceed because currently pygeoif objects' properties are used to guess their type for serialization

    _________________________________________________________________________ KmlFromStringTestCase.test_multilinestrings _________________________________________________________________________
    
    self = <fastkml.test_main.KmlFromStringTestCase testMethod=test_multilinestrings>
    
        def test_multilinestrings(self):
            doc = """<kml xmlns="http://www.opengis.net/kml/2.2">
            <Placemark>
              <name>Dnipro (Dnieper)</name>
              <MultiGeometry>
              <LineString><coordinates>33.54,46.831,0 33.606,46.869,0 33.662,46.957,0 33.739,47.05,0 33.859,47.149,0 33.976,47.307,0 33.998,47.411,0 34.155,47.49,0 34.448,47.542,0 34.712,47.553,0 34.946,47.521,0 35.088,47.528,0 35.138,47.573,0 35.149,47.657,0 35.106,47.842,0 </coordinates></LineString>
              <LineString><coordinates>33.194,49.094,0 32.884,49.225,0 32.603,49.302,0 31.886,49.555,0 </coordinates></LineString>
              <LineString><coordinates>31.44,50,0 31.48,49.933,0 31.486,49.871,0 31.467,49.754,0 </coordinates></LineString>
              <LineString><coordinates>30.508,51.217,0 30.478,50.904,0 30.479,50.749,0 30.515,50.597,0 </coordinates></LineString>
              </MultiGeometry>
            </Placemark> </kml>"""
        
            k = kml.KML()
    >       k.from_string(doc)
    
    fastkml/test_main.py:734: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    fastkml/kml.py:112: in from_string
        feature.from_element(placemark)
    fastkml/kml.py:1081: in from_element
        geom.from_element(multigeometry)
    fastkml/geometry.py:416: in from_element
        mgeom = self._get_multigeometry(element)
    fastkml/geometry.py:405: in _get_multigeometry
        return MultiLineString(geoms)
    /home/alex/envs/github/fastkml/lib/python3.8/site-packages/pygeoif/geometry.py:733: in __init__
        self._geoms = tuple(LineString(line) for line in lines)
    /home/alex/envs/github/fastkml/lib/python3.8/site-packages/pygeoif/geometry.py:733: in <genexpr>
        self._geoms = tuple(LineString(line) for line in lines)
    /home/alex/envs/github/fastkml/lib/python3.8/site-packages/pygeoif/geometry.py:282: in __init__
        self._geoms = self._set_geoms(coordinates)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    
    coordinates = LineString(((33.54, 46.831, 0.0), (33.606, 46.869, 0.0), (33.662, 46.957, 0.0), (33.739, 47.05, 0.0), (33.859, 47.149,...0), (34.946, 47.521, 0.0), (35.088, 47.528, 0.0), (35.138, 47.573, 0.0), (35.149, 47.657, 0.0), (35.106, 47.842, 0.0)))
    
        @staticmethod
        def _set_geoms(coordinates: LineType) -> Tuple[Point, ...]:
            geoms = []
            last_len = None
    >       for coord in coordinates:
    E       TypeError: 'LineString' object is not iterable
    
    /home/alex/envs/github/fastkml/lib/python3.8/site-packages/pygeoif/geometry.py:352: TypeError
    
  3. cleder commented on Oct 2, 2021

    @cleder
    OwnerAuthor

    This is intended to be so.
    pygeoif has stricter requirements for the inputs, and there are @classmethods available to emulate the old behaviour.

  4. MrNaif2018 commented on Oct 2, 2021

    @MrNaif2018
    Contributor

    So do you think I should use the class factories for that? Because the code heavily relies on geometry types to serialize/serialize correctly

  5. cleder commented on Oct 2, 2021

    @cleder
    OwnerAuthor

    Instead of return MultiLineString(geoms) it would be return MultiLineString.from_linestrings(geoms)

  6. added this to the Version 1.0 milestone on Oct 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions