2017 © Pedro Peláez
 

library sql-geo

Easily store GeoJSON in a SQL database

image

m1ke/sql-geo

Easily store GeoJSON in a SQL database

  • Tuesday, January 20, 2015
  • by m1ke
  • Repository
  • 1 Watchers
  • 0 Stars
  • 68 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

SQL Geo I/O

A PHP library for moving data between database and standard output formats (e.g. GeoJSON and KML)., (*1)

Initially created just as a wrapper to take GeoJSON data and input into a database., (*2)

Installation

php composer.phar require m1ke/geojson-sql, (*3)

Authors

Written by Mike Lehan and StuRents.com., (*4)

Usage

  • For GeoJsonSql
    • process_and_save() Returns the $polygon array formatted for inclusion in a query. Also accepts a PDO statement if you want to save in a database.
    • process_with_query(PDO $db,$table,$name) Creates a PDO query with a single value which is replaced with the polygon
  • For SqlGeo
    • search_json(Array $where) Returns a JSON string based on the submitted query e.g. ['item_id' => 25]

Example

For GeoJsonSql:, (*5)

require __DIR__.'/vendor/autoload.php';

$db=new PDO('mysql:host=localhost;dbname=database','user','pass');

$file_name='geojson.json';

$geojson = new GeoJsonSql($file_name);
$geojson->process_with_query($db,'table','polygon_field');

For SqlGeo:, (*6)

require __DIR__.'/vendor/autoload.php';

$db=new PDO('mysql:host=localhost;dbname=geospatial','root','');

$sqljson=new SqlGeo($db,'table','polygon_field');
echo $sqljson->search_json(['title'=>'Polygon Title']);

The Versions

20/01 2015

dev-master

9999999-dev

Easily store GeoJSON in a SQL database

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

20/01 2015

dev-x1.0

dev-x1.0

Easily store GeoJSON in a SQL database

  Sources   Download

MIT

The Requires

  • php >=5.4.0