| 137 | | if ((*itr)->name=="trk") |
| | 137 | if ((*itr)->name=="rte") |
| | 138 | { |
| | 139 | osg::ref_ptr<Track> track = new Track; |
| | 140 | track->setName(filename); |
| | 141 | |
| | 142 | osg::ref_ptr<TrackSegment> trackSegment = new TrackSegment; |
| | 143 | for(osgDB::XmlNode::Children::iterator sitr = (*itr)->children.begin(); |
| | 144 | sitr != (*itr)->children.end(); |
| | 145 | ++sitr) |
| | 146 | { |
| | 147 | if ((*sitr)->name=="rtept" ) |
| | 148 | { |
| | 149 | osgDB::XmlNode* trkpt = sitr->get(); |
| | 150 | TrackSegment::TrackPoint point; |
| | 151 | bool valid = false; |
| | 152 | if (trkpt->properties.count(latitude)!=0) |
| | 153 | { |
| | 154 | valid = true; |
| | 155 | point.latitude = osg::asciiToDouble(trkpt->properties[latitude].c_str()); |
| | 156 | } |
| | 157 | if (trkpt->properties.count(longitude)!=0) |
| | 158 | { |
| | 159 | valid = true; |
| | 160 | point.longitude = osg::asciiToDouble(trkpt->properties[longitude].c_str()); |
| | 161 | } |
| | 162 | |
| | 163 | for(osgDB::XmlNode::Children::iterator pitr = trkpt->children.begin(); |
| | 164 | pitr != trkpt->children.end(); |
| | 165 | ++pitr) |
| | 166 | { |
| | 167 | if ((*pitr)->name=="ele") point.elevation = osg::asciiToDouble((*pitr)->contents.c_str()); |
| | 168 | else if ((*pitr)->name=="time") point.time = convertTime((*pitr)->contents); |
| | 169 | } |
| | 170 | |
| | 171 | if (valid) |
| | 172 | { |
| | 173 | osg::notify(osg::NOTICE)<<" point.latitude="<<point.latitude<<", longitude="<<point.longitude<<", elev="<<point.elevation<<", time="<<point.time<<std::endl; |
| | 174 | trackSegment->addTrackPoint(point); |
| | 175 | } |
| | 176 | } |
| | 177 | |
| | 178 | } |
| | 179 | |
| | 180 | if (!trackSegment->getTrackPoints().empty()) |
| | 181 | { |
| | 182 | track->addTrackSegment(trackSegment.get()); |
| | 183 | } |
| | 184 | |
| | 185 | return track.release(); |
| | 186 | } |
| | 187 | else if ((*itr)->name=="trk") |