Skip to content
/ sql-geo Public

A PHP library for moving data in and out of GeoSQL databases

License

Notifications You must be signed in to change notification settings

M1ke/sql-geo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQL Geo I/O

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

Initially created just as a wrapper to take GeoJSON data and input into a database.

Installation

php composer.phar require m1ke/geojson-sql

Authors

Written by Mike Lehan and StuRents.com.

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:

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:

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']);

About

A PHP library for moving data in and out of GeoSQL databases

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published