<s> import bisect <EOL> from gtfsobjectbase import GtfsObjectBase <EOL> import problems as problems_module <EOL> import util <EOL> import sys <EOL> class ShapePoint ( GtfsObjectBase ) : <EOL> """<STR_LIT>""" <EOL> _REQUIRED_FIELD_NAMES = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> _FIELD_NAMES = _REQUIRED_FIELD_NAMES + [ '<STR_LIT>' ] <EOL> def __init__ ( self , shape_id = None , lat = None , lon = None , seq = None , dist = None , <EOL> field_dict = None ) : <EOL> """<STR_LIT>""" <EOL> self . _schedule = None <EOL> if field_dict : <EOL> if isinstance ( field_dict , self . __class__ ) : <EOL> for k , v in field_dict . iteritems ( ) : <EOL> self . __dict__ [ k ] = v <EOL> else : <EOL> self . __dict__ . update ( field_dict ) <EOL> else : <EOL> self . shape_id = shape_id <EOL> self . shape_pt_lat = lat <EOL> self . shape_pt_lon = lon <EOL> self . shape_pt_sequence = seq <EOL> self . shape_dist_traveled = dist <EOL> def ParseAttributes ( self , problems ) : <EOL> """<STR_LIT>""" <EOL> if util . IsEmpty ( self . shape_id ) : <EOL> problems . MissingValue ( '<STR_LIT>' ) <EOL> return <EOL> try : <EOL> if not isinstance ( self . shape_pt_sequence , int ) : <EOL> self . shape_pt_sequence = util . NonNegIntStringToInt ( self . shape_pt_sequence , problems ) <EOL> elif self . shape_pt_sequence < <NUM_LIT:0> : <EOL> problems . InvalidValue ( '<STR_LIT>' , self . shape_pt_sequence , <EOL> '<STR_LIT>' ) <EOL> except ( TypeError , ValueError ) : <EOL> problems . InvalidValue ( '<STR_LIT>' , self . shape_pt_sequence , <EOL> '<STR_LIT>' ) <EOL> return <EOL> try : <EOL> if not isinstance ( self . shape_pt_lat , ( int , float ) ) : <EOL> self . shape_pt_lat = util . FloatStringToFloat ( self . shape_pt_lat , problems ) <EOL> if abs ( self . shape_pt_lat ) > <NUM_LIT> : <EOL> problems . InvalidValue ( '<STR_LIT>' , self . shape_pt_lat ) <EOL> return <EOL> except ( TypeError , ValueError ) : <EOL> problems . InvalidValue ( '<STR_LIT>' , self . shape_pt_lat ) <EOL> return <EOL> try : <EOL> if not isinstance ( self . shape_pt_lon , ( int , float ) ) : <EOL> self . shape_pt_lon = util . FloatStringToFloat ( self . shape_pt_lon , problems ) <EOL> if abs ( self . shape_pt_lon ) > <NUM_LIT> : <EOL> problems . InvalidValue ( '<STR_LIT>' , self . shape_pt_lon ) <EOL> return <EOL> except ( TypeError , ValueError ) : <EOL> problems . InvalidValue ( '<STR_LIT>' , self . shape_pt_lon ) <EOL> return <EOL> if abs ( self . shape_pt_lat ) < <NUM_LIT:1.0> and abs ( self . shape_pt_lon ) < <NUM_LIT:1.0> : <EOL> problems . InvalidValue ( '<STR_LIT>' , self . shape_pt_lat , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> type = problems_module . TYPE_WARNING ) <EOL> return <EOL> if self . shape_dist_traveled == '<STR_LIT>' : <EOL> self . shape_dist_traveled = None <EOL> if ( self . shape_dist_traveled is not None and <EOL> not isinstance ( self . shape_dist_traveled , ( int , float ) ) ) : <EOL> try : <EOL> self . shape_dist_traveled = util . FloatStringToFloat ( self . shape_dist_traveled , problems ) <EOL> except ( TypeError , ValueError ) : <EOL> problems . InvalidValue ( '<STR_LIT>' , self . shape_dist_traveled , <EOL> '<STR_LIT>' ) <EOL> return <EOL> if self . shape_dist_traveled is not None and self . shape_dist_traveled < <NUM_LIT:0> : <EOL> problems . InvalidValue ( '<STR_LIT>' , self . shape_dist_traveled , <EOL> '<STR_LIT>' ) <EOL> return <EOL> return True </s>
