GIS and Media fusion

"The explosive growth of the GeoWeb and geographic information has made GIS powerful media for the general public to communicate, but perhaps more importantly, GIS have also become media for constructive dialogs and interactions about social issues." - Sui & Goodchild

User Tools

Site Tools


geoinf14:cartodb0

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
geoinf14:cartodb0 [2014/12/01 15:22]
oertz created
geoinf14:cartodb0 [2018/05/16 10:05] (current)
Line 12: Line 12:
 INSERT INTO my4capitals (cartodb_id,​ name, the_geom) VALUES ( 3, '​Madrid',​ ST_GeometryFromText( '​POINT(-3.71 40.41)',​ 4326)); INSERT INTO my4capitals (cartodb_id,​ name, the_geom) VALUES ( 3, '​Madrid',​ ST_GeometryFromText( '​POINT(-3.71 40.41)',​ 4326));
 </​code>​ </​code>​
-  * Executer dans le panneau SQL et comparer la colonne //​the_geom// ​et //​the_geom_webmercator//​+  * Executer dans le panneau SQL la sélection ci-dessous ​et comparer la colonne //​the_geom// ​avec //​the_geom_webmercator//​
 <​code>​ <​code>​
 SELECT * from my4capitals SELECT * from my4capitals
Line 20: Line 20:
  
 ==== Utilisation de la SQL API de CartoDB ==== ==== Utilisation de la SQL API de CartoDB ====
-La classe Connection du GeoManager précédent est maintenant remplacée par une API Web. On peut y lancer des requêtes ​GQL. Par exemple :+La classe Connection du GeoManager précédent est maintenant remplacée par un appel à une API Web. On peut y lancer des requêtes ​SQL spatiales. Par exemple :
 <​code>​ <​code>​
 <?php <?php
Line 39: Line 39:
 </​code>​ </​code>​
 __TODO__ __TODO__
-  - Adapter le géoservice Get4Capitals.php en utilisant l'API SQL de CartoDB pour afficher les 4 villes dans votre application OpenLayers (la classe FeatureCollection du GeoManager peut être utile).+  - Adapter le géoservice Get4Capitals.php en utilisant l'API SQL de CartoDB pour afficher les 4 villes dans votre application OpenLayers (la classe FeatureCollection du GeoManager ​qui permet d'​encoder un flux GeoJSON ​peut toujours ​être utile). 
 + 
 +  * Ce qui donne : 
 +<​code>​ 
 +<?php 
 +require_once '​GeoManager.php';​ 
 + 
 +$ch = curl_init();​ 
 +curl_setopt($ch,​ CURLOPT_RETURNTRANSFER,​ 1); 
 + 
 +$api_key = "​2e957be5f1e9c0793ca1725aab08274a795f2c3f";​ 
 +$q = "​select name, ST_AsGeoJSON(the_geom) as geom from my4capitals";​ 
 + 
 +$url = "​http://​oertz.cartodb.com/​api/​v2/​sql?​api_key="​ . $api_key. "&​q="​ . urlencode($q);​ 
 +curl_setopt($ch,​ CURLOPT_URL,​ $url); 
 + 
 +$result = curl_exec($ch);​ 
 +$rows = json_decode($result)->​rows;​ 
 + 
 +header("​Content-type:​ application/​json"​);​ 
 + 
 +$i = 0; 
 +$fc = new FeatureCollection();​ 
 +foreach ($rows as $row) { 
 +    $fc->​addFeature(new Feature($i++,​ json_decode($row->​geom),​ array("​name"​ => $row->​name)));​ 
 +
 + 
 +echo json_encode($fc);​ 
 + 
 +?> 
 +</​code>​
  
geoinf14/cartodb0.1417443754.txt.gz · Last modified: 2018/05/16 10:05 (external edit)