Code Monkey home page Code Monkey logo

Comments (2)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 12, 2024
[deleted comment]

from pynmea.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 12, 2024
Ok, nevermind that above, it doesn't work. I wrote better code to be inserted 
at the same spot. Now it checks in the parse_map to see if there are the 
longitude and latitude attributes that were parsed. If so, it will dynamically 
grab the name of the attribute, get the value and create a corresponding 
'_decimal' attribute with the calculated value.

        #Calculate the decimal value of the longitude and latitude if the attribute is present in the sentence
        for attribute in self.parse_map:
            if attribute[0].lower() == 'longitude':
                #Get the longitude attribute dynamically using the attribute name from parse_map
                longitude = getattr(self,attribute[1])
                #Add failsafe for empty values from invalid sentences
                if longitude != '':
                    self.longitude_decimal = float(longitude[3:])/60+float(longitude[:3])
                #To be consistent, create empty attribute, prevent AttributeError in downstream code
                else:
                    self.longitude_decimal = ''

            if attribute[0].lower() == 'latitude':
                #Get the latitude attribute dynamically using the attribute name from parse_map
                latitude = getattr(self,attribute[1])
                #Add failsafe for empty values from invalid sentences
                if latitude != '':
                    self.latitude_decimal = float(latitude[2:])/60+float(latitude[:2])
                #To be consistent, create empty attribute, prevent AttributeError in downstream code
                else:
                    self.latitude_decimal = ''

Sorry for the stupid first post.
Charles.

Original comment by [email protected] on 30 Apr 2013 at 7:56

from pynmea.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.