当前位置: 首页>>代码示例>>PHP>>正文


PHP c2cTools::simplexmlLoadFile方法代码示例

本文整理汇总了PHP中c2cTools::simplexmlLoadFile方法的典型用法代码示例。如果您正苦于以下问题:PHP c2cTools::simplexmlLoadFile方法的具体用法?PHP c2cTools::simplexmlLoadFile怎么用?PHP c2cTools::simplexmlLoadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在c2cTools的用法示例。


在下文中一共展示了c2cTools::simplexmlLoadFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: kml2wkt

 /**
  * kml2wkt does what its name implies : 
  * it takes a kml file, parses it for linestrings and returns an equivalent WKT LINESTRING
  *
  * The returned WKT can be 2, 3 or 4D. 
  * If does not really handle 4D parsing (beyond scope IMO) => KML import is restricted to routes (outings will only support GPX input)
  * If $dim = 4, then time field will be zero-padded.
  */
 public static function kml2wkt($path, $dim = 3)
 {
     // FIXME: document structure is very user customizable, and thus this function is not very robust ...
     // a solution would be to extract points linked to a linestring (if these points are present), and to sort them by date to build the linestring.
     $xml = c2cTools::simplexmlLoadFile($path);
     // TODO: handle files with Document>NetworkLink>Url>href : wget content... (mymaps generates these ones)
     // TODO: handle files with one waypoint for point update ?
     // TODO : handle multilines geometries ?
     $i = 0;
     $wkta = array();
     if ($pm = $xml->Document->Placemark) {
         // this is a simple kml
         // (for instance, one made with google "my maps")
         // in which these is no folder.
         c2cTools::log("ParseGeo::kml2wkt({$path}, {$dim}) with xml->Document->Placemark");
         return 'LINESTRING(' . self::getKmlCoordinates($pm->LineString->coordinates, $dim) . ')';
     } elseif ($geom_folders = $xml->Document->Folder) {
         // this is a "complex" KML with several folders (typical output of gpsbabel from gpx)
         $trk_coords = array();
         // kml file may contain three geom folders : Waypoints, Tracks and Routes
         foreach ($geom_folders as $folder) {
             // we're just looking for tracks :
             if ($folder->name == 'Tracks') {
                 // there might be subfolders if gps signal has been interrupted
                 // we merge these folders together to build a single track.
                 foreach ($folder->Folder as $track) {
                     $trk_coords[] = self::getKmlCoordinates($track->Placemark->LineString->coordinates, $dim);
                 }
             }
         }
         c2cTools::log("ParseGeo::kml2wkt({$path}, {$dim}) with xml->Document->Folder");
         return 'LINESTRING(' . implode(', ', $trk_coords) . ')';
     } else {
         c2cTools::log("kml2wkt : no track found");
         return false;
     }
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:45,代码来源:ParseGeo.class.php


注:本文中的c2cTools::simplexmlLoadFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。