Example #1
0
/*
 * Mandatory script !
 */
include_once 'config.php';
include_once 'functions/general.php';
/*
 * Avoid unwanted requests...
 */
if (!abcCheck($_REQUEST)) {
    exit(0);
}
/*
 * Force HTTP Header
 */
if (isset($_REQUEST["returntype"])) {
    /*
     * Force XML
     */
    if ($_REQUEST["returntype"] == "XML") {
        header("Pragma: no-cache");
        header("Expires: 0");
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
        header("Cache-Control: no-cache, must-revalidate");
        header("Content-type: text/xml");
    }
}
/*
 * Send either a POST request or a GET request
 */
echo $_SERVER['REQUEST_METHOD'] == 'POST' ? postRemoteData($_REQUEST["url"], $HTTP_RAW_POST_DATA, true) : getRemoteData($_REQUEST["url"], null, false);
Example #2
0
/*
 * Satellites
 */
if (isset($_REQUEST["q"])) {
    $req .= '&sn=' . $_REQUEST["q"];
}
/*
 * SPOT Dali Rest Server information
 *
 * Server : engine.mapshup.info
 * IP     : 213.251.187.141
 * API KEY: 2KYfZcCsisLrlToDWn5_uQ::
 *
 * Example of a search link:
 * http://daliis.spotimage.fr/wstools/data20/features.svc/search?
 * of=json
 * &sd=2009-01-01T00:00:00
 * &ed=2009-01-07T00:00:00
 * &mc=100
 * &mi=30
 * &minr=2.5
 * &maxr=20
 * &zt=rectangle
 * &nwlat=52&selat=48&nwlon=9&selon=13
 * &sk={key}
 *
 */
$req .= '&mc=30&of=geojson&zt=rectangle&sk=2KYfZcCsisLrlToDWn5_uQ::';
$url = 'http://daliis.spotimage.fr/wstools/data20/features.svc/search?' . $req;
echo str_replace("featureCollection", "features", getRemoteData($url, null, false));
Example #3
0
 * Geonames rssToGeoRSS service
 */
$rssToGeoRSS = 'http://ws.geonames.net/rssToGeoRSS?username=jrom&feedUrl=';
/*
 * Process only valid requests
 */
if (abcCheck($_REQUEST)) {
    $fileName = MSP_UPLOAD_DIR . createPassword(8) . '.rss';
    /*
     * First get RSS stream
     */
    if (saveFile(getRemoteData($_REQUEST["url"], null, false), $fileName)) {
        /*
         * If input RSS is true GeoRSS, then it should contain
         * a xmlns:georss attribute with value = "http://www.georss.org/georss"
         *
         */
        $doc = new DOMDocument();
        $doc->load($fileName);
        if ($doc->documentElement->getAttribute("xmlns:georss") != "http://www.georss.org/georss") {
            unlink($fileName);
            saveFile(getRemoteData($rssToGeoRSS . rawurlencode($_REQUEST["url"]), null, false), $fileName);
        }
        header("Pragma: no-cache");
        header("Expires: 0");
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
        header("Cache-Control: no-cache, must-revalidate");
        header("Content-type: text/xml");
        echo file_get_contents($fileName);
    }
}
Example #4
0
/**
 * This script returns GeoJSON
 */
header("Pragma: no-cache");
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Content-type: application/json; charset=utf-8");
/**
 * TODO : allow only ws.geonames.net to idenfied user ?
 * $url = 'http://ws.geonames.org/wikipediaSearch?';
 */
$url = 'http://ws.geonames.net/wikipediaSearch?username=jrom&';
/*
 * Search terms
 */
$q = isset($_REQUEST["q"]) ? $_REQUEST["q"] : "";
/*
 * Lang
 */
$lang = isset($_REQUEST["lang"]) ? $_REQUEST["lang"] : "en";
/*
 * Number of results
 */
$maxRows = isset($_REQUEST["maxRows"]) ? $_REQUEST["maxRows"] : MSP_RESULTS_PER_PAGE;
/**
 * NB: tags are comma separated
 */
$url = $url . "q=" . $q . "&maxRows=" . $maxRows . "&lang=" . $lang;
echo toGeoJSON(saveFile(getRemoteData($url, null, false), MSP_UPLOAD_DIR . "wikipedia_" . createPassword(10) . ".xml"));
Example #5
0
         }
     }
 }
 /**
  * Send a GET request $url
  *
  * The trick : if url do not have a "?", we add
  * a "?request=GetCapabilities" at the end of
  * the url. This will do nothing in the majority
  * of case, but if the url is an OGC url it will
  * automatically get the capabilities document :-)
  */
 if (!strrpos($url, '?')) {
     $arr = getRemoteData($url . "?request=GetCapabilities", null, true);
 } else {
     $arr = getRemoteData($url . "&request=GetCapabilities", null, true);
 }
 /*
  * Magic part : we try to detect a mapshup valid
  * layerType from the url content_type
  */
 if ($arr["info"] != "") {
     /*
      * A typical content_type is on the form
      *
      *  "type/yyy; charset..."
      *
      * For a easier detection we only need the first
      * part (don't care of charset).
      *
      */
Example #6
0
  *          top:
  *          left:
  *          right:
  *      }
  *  }
  */
 foreach ($json->tiles as $row) {
     foreach ($row as $tile) {
         $arr = explode('/', $tile->url);
         $arr = explode('\\.', $arr[count($arr) - 1]);
         $name = $arr[0];
         /*
          * If file exists, no need to upload it again !
          */
         if (!file_exists(MSP_UPLOAD_DIR . $name . ".tif")) {
             saveFile(getRemoteData($tile->url, null, false), MSP_UPLOAD_DIR . $name . ".jpeg");
             exec(MSP_GDAL_TRANSLATE_PATH . ' -of GTiff -a_srs ' . $tile->srs . ' -a_ullr ' . $tile->bounds->left . ' ' . $tile->bounds->top . ' ' . $tile->bounds->right . ' ' . $tile->bounds->bottom . ' ' . MSP_UPLOAD_DIR . $name . '.jpeg ' . MSP_UPLOAD_DIR . $name . '.tif');
         }
         $unique .= $name;
         $inputs .= " " . MSP_UPLOAD_DIR . $name . ".tif";
     }
 }
 /*
  * Generate the mosaic if it not already exists
  */
 $unique = md5($unique) . ".tif";
 if (!file_exists(MSP_UPLOAD_DIR . $unique)) {
     exec(MSP_GDAL_MERGE_PATH . ' -o ' . MSP_UPLOAD_DIR . $unique . $inputs);
 }
 $json = array('success' => true, 'url' => MSP_GETFILE_URL . $unique . "&stream=true");
 echo json_encode($json);
Example #7
0
                                    break;
                                }*/
            }
        }
        /*
         * Add feature array to feature collection array
         */
        array_push($geojson['features'], array('type' => 'Feature', 'geometry' => pointToGeoJSONGeometry(floatval($lonlat[1]), floatval($lonlat[0])), 'properties' => array('title' => $title, 'date' => $disaster->getElementsByTagname('date')->item(0)->nodeValue, 'call-id' => $disaster->getElementsByTagname('call-id')->item(0)->nodeValue, 'type' => $type, 'description' => $disaster->getElementsByTagname('description')->item(0)->nodeValue, 'link' => $disaster->getElementsByTagname('link')->item(0)->nodeValue)));
        $count++;
    }
    // Update totalResults
    $geojson["totalResults"] = $count;
    return json_encode($geojson);
}
/**
 * This script returns JSON
 */
header("Pragma: no-cache");
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Content-type: application/json; charset=utf-8");
/*
 *  
 */
$url = 'http://www.disasterscharter.org/DisasterCharter/CnesXml?articleType=activation&locale=en_US&companyId=1&communityId=10729';
/*
 * Get flickr result in json format
 */
echo xmlToGeoJSON(getRemoteData($url, null, false));
Example #8
0
$start = isset($_REQUEST["start"]) ? str_replace("T00:00:00", "", $_REQUEST["start"]) : "";
$end = isset($_REQUEST["end"]) ? str_replace("T00:00:00", "", $_REQUEST["end"]) : "";
/*
 * url_s is equivalent to thumbnail
 * url_l is equivalent to quicklook
 * url_sq is a small square image use for layer symbology
 */
$extras = "description,tags,geo,url_s,url_l,url_sq";
/*
 * Construct url with input parameters
 */
$url = $url . "tags=" . str_replace(" ", ",", $q) . "&machine_tags=" . $machine_tags . "&user_id=" . $user_id . "&tag_mode=" . $tag_mode . "&extras=" . $extras . "&per_page=" . $per_page . "&bbox=" . $bbox . "&relevance=" . $relevance . "&min_taken_date=" . $start . "&max_taken_date=" . $end;
/*
 * Get flickr result in json format
 */
$json = getRemoteData($url, null, false);
/*
 * The flickr result is not valid json string
 * It is surrounded by a jsonFlickApi() function
 * Thus, first we need to get rid of this function
 * before decode the json string
 */
$json = str_replace('jsonFlickrApi(', '', $json);
$json = json_decode(substr($json, 0, strlen($json) - 1));
/*
 * Initiate an empty GeoJSON object
 */
$geojson = array('type' => 'FeatureCollection', 'features' => array());
/*
 * Problem reading json => return an empty GeoJSON
 */
            continue;
        }
        /**
         * Add feature
         */
        $feature = array('type' => 'Feature', 'geometry' => bboxToGeoJSONGeometry($lonmin, $latmin, $lonmax, $latmax), 'properties' => array('identifier' => $dataObject->getElementsByTagName('identifier')->length > 0 ? $dataObject->getElementsByTagName('identifier')->item(0)->nodeValue : "", 'modified' => $dataObject->getElementsByTagName('modified')->length > 0 ? $dataObject->getElementsByTagName('modified')->item(0)->nodeValue : "", 'title' => $dataObject->getElementsByTagName('title')->length > 0 ? $dataObject->getElementsByTagName('title')->item(0)->nodeValue : "", 'type' => $dataObject->getElementsByTagName('type')->length > 0 ? $dataObject->getElementsByTagName('type')->item(0)->nodeValue : "", 'subject' => $dataObject->getElementsByTagName('subject')->length > 0 ? $dataObject->getElementsByTagName('subject')->item(0)->nodeValue : "", 'format' => $dataObject->getElementsByTagName('format')->length > 0 ? $dataObject->getElementsByTagName('format')->item(0)->nodeValue : "", 'creator' => $dataObject->getElementsByTagName('creator')->length > 0 ? $dataObject->getElementsByTagName('creator')->item(0)->nodeValue : "", 'publisher' => $dataObject->getElementsByTagName('publisher')->length > 0 ? $dataObject->getElementsByTagName('publisher')->item(0)->nodeValue : "", 'abstract' => str_replace($array, "", $dataObject->getElementsByTagName('abstract')->length > 0 ? $dataObject->getElementsByTagName('abstract')->item(0)->nodeValue : ""), 'language' => $dataObject->getElementsByTagName('language')->length > 0 ? $dataObject->getElementsByTagName('language')->item(0)->nodeValue : "", 'thumbnail' => "", 'quicklook' => ""));
        // Add feature array to feature collection array
        array_push($geojson['features'], $feature);
    }
    return json_encode($geojson);
}
/* =============================== END FUNCTIONS ======================

/**
 *  This script returns a GeoJSON result
 */
header("Pragma: no-cache");
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Content-type: application/json; charset=utf-8");
$theData = getRemoteData('/Users/jrom/Sites/jeob/bidon.inspire.xml', null, false);
/**
 *  Check if a SOAP Fault occured
 */
$error = OWSExceptionToJSON($theData);
if ($error) {
    echo $error;
} else {
    echo outputToGeoJSON($theData);
}
 * economic rights,  and the successive licensors  have only  limited
 * liability.
 *
 * In this respect, the user's attention is drawn to the risks associated
 * with loading,  using,  modifying and/or developing or reproducing the
 * software by the user in light of its specific status of free software,
 * that may mean  that it is complicated to manipulate,  and  that  also
 * therefore means  that it is reserved for developers  and  experienced
 * professionals having in-depth computer knowledge. Users are therefore
 * encouraged to load and test the software's suitability as regards their
 * requirements in conditions enabling the security of their systems and/or
 * data to be ensured and,  more generally, to use and operate it in the
 * same conditions as regards security.
 *
 * The fact that you are presently reading this means that you have had
 * knowledge of the CeCILL-B license and that you accept its terms.
 */
include_once '../../../config.php';
include_once '../../../functions/general.php';
/**
 * This script returns JSON data
 */
header("Pragma: no-cache");
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Content-type: application/json; charset=utf-8");
$action = $_REQUEST['action'];
$url = "http://www.disasterschartercatalog.org/cecec/scripts/connectors/cecec/DisastersCharter_SlotComboProxy.php?action=" . $action;
echo getRemoteData($url, null, false);
Example #11
0
$du = isset($_POST['duField']) ? $_POST['duField'] : "";
$dp = isset($_POST['dpField']) ? $_POST['dpField'] : "";
$ddb = isset($_POST['ddbField']) ? $_POST['ddbField'] : "";
######################################################################
if ($catFilterID != 0) {
    $compFilterArr = array(0 => "All Components") + getTwoColumnsMap("select componentID, component " . "from components where component != 'VOID' and " . "component != 'UNKNOWN' and " . "categoryID =" . $catFilterID . " " . "order by component");
    $noneDisplay = "";
} else {
    $noneDisplay = "none";
}
if ($_POST['Save'] == "Merge") {
    $dbArr = array("source" => array($sip, $sdb, $su, $sp), "target" => array($dip, $ddb, $du, $dp));
    $catFilterID = $_POST['catField'];
    $compFilterID = $_POST['compField'];
    $userQuery = "35,30";
    $remoteArr = getRemoteData($build, $userQuery, $dbArr);
    $log = storeRemoteData($build, $remoteArr, $catFilterID, $compFilterID, $dbArr);
}
#######################################################################
$smarty = new TLSmarty();
$smarty->assign("catFilterArr", $catFilterArr);
$smarty->assign("catFilterID", $catFilterID);
$smarty->assign("compFilterArr", $compFilterArr);
$smarty->assign("compFilterID", $compFilterID);
$smarty->assign("noneDisplay", $noneDisplay);
$smarty->assign("log", "<p align=left>" . $log . "</p>");
$smarty->assign("sip", $sip);
$smarty->assign("su", $su);
$smarty->assign("sp", $sp);
$smarty->assign("sdb", $sdb);
$smarty->assign("dip", $dip);
Example #12
0
/*
 * Get XML result
 * Structure :
 *
 *  <result>
 *      <target>m31</target>
 *      <service>NED(nedwww.ipac.caltech.edu)</service>
 *      <coordsys>ICRS</coordsys>
 *      <ra>10.68469</ra>
 *      <dec>41.26904</dec>
 *      <time>524</time>
 *  </result>
 * 
 */
$doc = new DOMDocument();
if ($doc->loadXML(getRemoteData($url, null, false))) {
    /*
     * Initialiaze GeoJSON
     */
    $geojson = array('type' => 'FeatureCollection', 'features' => array());
    /*
     * Parse result and populate geojson result
     */
    $result = $doc->getElementsByTagname('result')->item(0);
    if ($result != null) {
        $ra = $result->getElementsByTagname('ra')->item(0)->nodeValue;
        $dec = $result->getElementsByTagname('dec')->item(0)->nodeValue;
        /*
         * Only exploitable results are processed
         */
        if ($ra && $dec) {
Example #13
0
 * http://api.spotimage.com/catalog/spot/data/Dali.svc/search?
 * of=json
 * &sd=2009-01-01T00:00:00
 * &ed=2009-01-07T00:00:00
 * &mc=100
 * &mi=30
 * &minr=2.5
 * &maxr=20
 * &zt=rectangle
 * &nwlat=52&selat=48&nwlon=9&selon=13
 * &sk={key}
 *
 */
$req .= '&of=json&zt=rectangle&sk=2KYfZcCsisLrlToDWn5_uQ::';
$url = 'http://api.spotimage.com/catalog/spot/data/Dali.svc/search?' . $req;
$json = json_decode(getRemoteData($url, null, false));
$geojson = array('type' => 'FeatureCollection', 'features' => array());
/*
 * Error ?
 */
if ($json->Message != null) {
    $error = array('code' => $json->Code, 'message' => $json->Message);
    $geojson['error'] = $error;
} else {
    foreach ($json->Scenes as $row) {
        /*
         * Compute poslist from scene coordinates
         */
        $poslist = $row->LowerLeft->Longitude . " " . $row->LowerLeft->Latitude . " " . $row->LowerRight->Longitude . " " . $row->LowerRight->Latitude . " " . $row->UpperRight->Longitude . " " . $row->UpperRight->Latitude . " " . $row->UpperLeft->Longitude . " " . $row->UpperLeft->Latitude . " " . $row->LowerLeft->Longitude . " " . $row->LowerLeft->Latitude;
        /*
         * Add feature