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

Add LandXML support #80

Merged
merged 24 commits into from
Nov 17, 2020
Merged

Add LandXML support #80

merged 24 commits into from
Nov 17, 2020

Conversation

psolyca
Copy link
Collaborator

@psolyca psolyca commented Dec 7, 2017

Add support of LandXML as input and output.

@psolyca psolyca requested a review from steko December 7, 2017 14:25
Copy link
Collaborator

@steko steko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot of work! It's fantastic!!!

It was not clear from the description that you were adding both input and output support for the format 👍

The biggest issue I can find - and that's not very big! - is the lack of documentation, both in general and for specific details, e.g. the different values for processing points "PO", "PT" etc. is super efficient but it must be explained somewhere in the user documentation.

There's also some confusion with the tests, since only the output is covered. The existing tests for other formats use this simplistic procedure of "sampling" some points but I think it's better to use a complete sample file (or more than one). Sample files should go to sample_data and can be used for tests (in this case, both for input and output).

I have added more comments on small details in some files.

Thank you! 😁

data/template.xml Outdated Show resolved Hide resolved
totalopenstation/formats/landxml.py Outdated Show resolved Hide resolved
totalopenstation/formats/landxml.py Outdated Show resolved Hide resolved
totalopenstation/formats/landxml.py Show resolved Hide resolved
totalopenstation/tests/test_geojson.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@steko steko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I'm just asking for a few small changes that I didn't see yesterday (file names, missing test coverage).

And the documentation: if you want I can start writing it?

@psolyca
Copy link
Collaborator Author

psolyca commented Aug 28, 2019

I will do it.

@psolyca
Copy link
Collaborator Author

psolyca commented Aug 28, 2019

After rereading the code, PO, PT and ST are values used internally and not provided to end users, thus I will had a page (or multiple) on explanation around Tops development.
As these values have been introduced long time ago, I will not add them on this PR but will create another one.

@psolyca psolyca added the waiting changes Waiting for other changes in the code label Aug 30, 2019
@psolyca
Copy link
Collaborator Author

psolyca commented Aug 30, 2019

I need some changes in the code before releasing this parser.

@psolyca psolyca changed the title Add LandXML support [WIP] Add LandXML support Aug 30, 2019
This commit add basic support for LandXML output as only setup
method processing InstrumentSetupX tag is added.
The Survey class in landxml.py populate the survey tag of LandXML.
Each sub tag has his own function and tags should be in order
(convention):
    - SurveyHeader
    - Equipment
    - CgPoints
    - InstrumentSetup0
    - InstrumentSetupX
    - ObservationGroup0
    - ObservationGroupX
The OutputFormat class in tops_xml.py exports points data in LandXML
format.
This commit complete support for LandXML output as only cg_point
method processing CgPoints tag is added.
This commit complete support for LandXML output as only raw_observation
method processing ObservationGroupX tags is added.
This commit complete support for LandXML output as only equipment
method processing Equipment tags is added.
This commit finalize the support for LandXML output and add a template to the output file.
This commit add a simple unittest to LandXML output.
TEMPLATE is a constant string and not a file anymore due to potential error
when the program is called from outside the source tree.
The XML format is specific to LandXML, thus change all xml word
to landxml.
@psolyca psolyca force-pushed the feature/LandXML branch 2 times, most recently from 9e44c94 to c7c12eb Compare December 2, 2019 13:49
@steko
Copy link
Collaborator

steko commented Dec 9, 2019

Do you need any help to update this pull request?

Tests are failing because some of our input formats have no Z coordinate and the LandXML output module doesn't handle the case of missing Z coordinate:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
totalopenstation/output/tops_landxml.py:53: in process
    kwargs = self._get_feature(feature)
totalopenstation/output/tops_landxml.py:41: in _get_feature
    kwargs["z"] = feature.geometry.z
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = Point(0.0, 0.0)
    @property
    def z(self):
        """Return z coordinate."""
        if len(self._coordinates) != 3:
>           raise ValueError("This point has no z coordinate.")
E           ValueError: This point has no z coordinate.

@psolyca
Copy link
Collaborator Author

psolyca commented Dec 9, 2019

I will look at this after merging master.
I will have lots of work this end of year. I hope to be able to finish this for end of December but I can not guarantee.

@steko
Copy link
Collaborator

steko commented Dec 9, 2019

Take your time, there is no deadline.

@psolyca
Copy link
Collaborator Author

psolyca commented Nov 16, 2020

Weird results of test cases https://github.com/totalopenstation/totalopenstation/runs/1407259466 ^^;
Values are correct but not in the right order for 3.6, 3.7 and pypy3.
It could be a "problem" of order in dict but it has been introduced in 3.7 and 3.7 is not correct.
So should we pass through this ?

@steko
Copy link
Collaborator

steko commented Nov 16, 2020

Oh, that's LandXML support coming! 😄

About those weird test results, I'm not sure it depends on ordered dictionary since you're testing the output of tostring(). Since I don't like having test failures around too much, I propose the following workaround.

Replace these two lines

        self.assertEqual(self.output.splitlines()[12], b'\t\t<InstrumentSetup id="setup0" stationName="STATION" instrumentHeight="1.5">')
        self.assertEqual(self.output.splitlines()[16], b'\t\t\t<RawObservation targetHeight="1.5" horizAngle="0" zenithAngle="90.585" slopeDistance="1718.28">')

with

        self.assertIn(b'<InstrumentSetup', self.output.splitlines()[12])
        self.assertIn(b'id="setup0"', self.output.splitlines()[12])
        self.assertIn(b'instrumentHeight="1.5"', self.output.splitlines()[12])
        self.assertIn(b'stationName="STATION"', self.output.splitlines()[12])
        self.assertIn(b'<RawObservation', self.output.splitlines()[16])
        self.assertIn(b'targetHeight="1.5"', self.output.splitlines()[16])
        self.assertIn(b'horizAngle="0"', self.output.splitlines()[16])
        self.assertIn(b'zenithAngle="90.585"', self.output.splitlines()[16])
        self.assertIn(b'slopeDistance="1718.28"', self.output.splitlines()[16])

so the order doesn't matter. After all we're not testing that XML is well formed (we trust the standard library to do that).

I think that settles the problem and makes LandXML a first class format 🚀

@psolyca
Copy link
Collaborator Author

psolyca commented Nov 17, 2020

Thanks !
You were faster than me ^^

@psolyca psolyca added feature and removed waiting changes Waiting for other changes in the code labels Nov 17, 2020
@psolyca psolyca changed the title [WIP] Add LandXML support Add LandXML support Nov 17, 2020
@steko
Copy link
Collaborator

steko commented Nov 17, 2020

Huge work!
I think one of the Travis checks will hang forever since it's not a branch in this repo (we may remove the check altogether).
I'll just merge this. There's still some documentation missing but it can be done in a smaller PR.

@psolyca
Copy link
Collaborator Author

psolyca commented Nov 17, 2020

I was looking why the check did not pass but ok to merge.
I will do a PR for the documentation later.

@steko steko merged commit 7f3c6ac into totalopenstation:master Nov 17, 2020
@psolyca psolyca deleted the feature/LandXML branch November 30, 2020 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants