Example #1
0
     if (count($associated_routes) == 1) {
         $single_route = Document::find('Route', $route['id'], array('global_rating', 'facing', 'engagement_rating', 'equipment_rating', 'toponeige_technical_rating', 'toponeige_exposition_rating', 'labande_ski_rating', 'labande_global_rating', 'ice_rating', 'mixed_rating', 'rock_free_rating', 'rock_required_rating', 'aid_rating', 'hiking_rating', 'snowshoeing_rating'));
         if ($rating = trim(field_route_ratings_data($single_route, false, false, true))) {
             $item->addChild('rating', $rating);
         }
         if ($facing = $single_route['facing']) {
             $item->addChild('facing', $facing);
         }
     }
     if ($max_ele > 0) {
         $item->addChild('geom', "{$lon},{$lat}");
         $item->addChild('elevation', $max_ele);
     } else {
         // could not find any geolocalized route to link
         // => we go to the next step : find highest associated summits to these routes
         $coords = Route::findHighestAssociatedSummitCoords($associated_routes);
         if ($coords['ele'] > 0) {
             if (strlen($coords['lon']) && strlen($coords['lat'])) {
                 $item->addChild('geom', $coords['lon'] . ',' . $coords['lat']);
             }
             $item->addChild('elevation', $coords['ele']);
         }
     }
 } elseif ($associated_sites = Association::findAllAssociatedDocs($id, $fields = array('id', 'lon', 'lat', 'elevation'), 'to')) {
     // find highest site
     $max_ele = 0;
     foreach ($associated_sites as $site) {
         if (($ele = $site['elevation']) && $ele > $max_ele && ($lon = $site['lon']) && ($lat = $site['lat'])) {
             $highest_site = $site;
             $max_ele = $site['elevation'];
         }