====== Spatial database :: CartoDB ====== * Créer un compte chez www.cartodb.com et s'y loguer ===== Première "CartoTable" ===== * Créer une //Empty table// * Renommer la table (Edit Metadata) //my4capitals// * Exécuter dans le panneau SQL les insertions ci-dessous INSERT INTO my4capitals (cartodb_id, name, the_geom) VALUES ( 0, 'Paris', ST_GeometryFromText( 'POINT(2.333 48.867)', 4326)); INSERT INTO my4capitals (cartodb_id, name, the_geom) VALUES ( 1, 'Bern', ST_GeometryFromText( 'POINT(7.433 46.95)', 4326)); INSERT INTO my4capitals (cartodb_id, name, the_geom) VALUES ( 2, 'Rome', ST_GeometryFromText( 'POINT(12.5 41.883)', 4326)); INSERT INTO my4capitals (cartodb_id, name, the_geom) VALUES ( 3, 'Madrid', ST_GeometryFromText( 'POINT(-3.71 40.41)', 4326)); * Executer dans le panneau SQL la sélection ci-dessous et comparer la colonne //the_geom// avec //the_geom_webmercator// SELECT * from my4capitals * Basculer en mode MAP VIEW * Editer la CartoCSS à votre goût (onglet CSS) ==== Utilisation de la SQL API de CartoDB ==== 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 : __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 qui permet d'encoder un flux GeoJSON peut toujours être utile). * Ce qui donne : 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); ?>