Example #1
0
/**
 * Get mapshup layerType from file extension
 */
function getLayerInfosFromFile($fileName)
{
    // Set default values
    $type = MSP_UNKNOWN;
    /*
     * get extension
     */
    $ext = strtolower(getExtension($fileName));
    /*
     * KML
     */
    if ($ext === "kml") {
        $type = "KML";
    } else {
        if ($ext === "gpx") {
            $type = "GPX";
        } else {
            if ($ext === "jpeg" || $ext === "gif" || $ext === "jpg" || $ext === "png") {
                $type = "Image";
            } else {
                if ($ext === "xml" || $ext === "gml") {
                    /*
                     * Load XML document
                     */
                    $doc = new DOMDocument();
                    $doc->load($fileName);
                    return getLayerInfosFromXML($doc);
                }
            }
        }
    }
    // Set default values
    $infos = array('type' => $type, 'title' => null, 'description' => null);
    return $infos;
}
Example #2
0
         $infos["type"] = "KML";
     } else {
         if ($contentType == "image/png" || $contentType == "image/jpeg" || $contentType == "image/gif") {
             $infos["type"] = "Image";
             /*
              * TODO : compute bbox when possible (gdal ?)
              * $extras = array(
              *   'bbox' => '',
              *   'srs' => 'EPSG:4326
              * );
              */
         } else {
             if (strrpos($contentType, "xml") !== -1) {
                 $doc = new DOMDocument();
                 $doc->loadXML($arr["data"]);
                 $infos = getLayerInfosFromXML($doc);
             } else {
                 $infos = array('type' => MSP_UNKNOWN, 'title' => null, 'description' => null);
             }
         }
     }
 }
 /*
  * Push items
  */
 $item = array('url' => $url, 'id' => $id, 'content_type' => $contentType);
 /*
  * Infos keys/values
  */
 foreach (array_keys($infos) as $key) {
     if ($infos[$key] != null) {