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

Handle case where Feature booleans are 'true' or 'false' during parsing #15

Merged
merged 1 commit into from Aug 1, 2014
Merged

Conversation

jwhelland
Copy link
Contributor

I've come across a few kml documents that use string 'true' or 'false' for the visibility and open boolean values instead of 1 or 0. The current way of casting to int doesn't work for these. The changes I made check for the string values and force to integer 1 or 0.

I'm not sure this is the best solution as it doesn't preserve the original string values when using to_string, but it works for my needs. I thought this might be useful for others as well.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) when pulling 0f882d7 on jwhelland:master into 272c6d2 on cleder:master.

@@ -493,10 +493,16 @@ def from_element(self, element):
self.description = description.text
visibility = element.find('%svisibility' % self.ns)
if visibility is not None:
self.visibility = int(visibility.text)
if visibility.text in ['1', 'true']:
Copy link
Owner

Choose a reason for hiding this comment

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

Not sure what the standard defines as default here, can you read it up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to kml reference the default values here are:
visibility=1
open=0

And according to xsd definition for boolean:
Legal values for boolean are true, false, 1 (which indicates true), and 0 (which indicates false).

Refs:
https://developers.google.com/kml/documentation/kmlreference#feature
http://www.w3schools.com/schema/schema_dtypes_misc.asp

cleder added a commit that referenced this pull request Aug 1, 2014
Handle case where Feature booleans are 'true' or 'false' during parsing, No need to preserve the original values if they are in violation of the specification, we may need to adjust isOpen and visibility so it defaults to the specifications default values
@cleder cleder merged commit 905d659 into cleder:master Aug 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants