Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Geophp | 709 | 129 | 23 | 3 years ago | 1 | December 02, 2014 | 75 | other | PHP | |
Advanced geometry operations in PHP | ||||||||||
Laravel Postgis | 347 | 36 | 2 | a day ago | 47 | August 11, 2022 | 21 | mit | PHP | |
Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models. | ||||||||||
Doctrine Postgis | 193 | 19 | 1 | 2 months ago | 14 | April 21, 2022 | 2 | mit | PHP | |
Spatial and Geographic Data with PostGIS and Doctrine. | ||||||||||
Pg2b3dm | 191 | 2 days ago | 19 | February 16, 2023 | 2 | mit | JavaScript | |||
Tool for converting from PostGIS to b3dm tiles | ||||||||||
Go.geojson | 160 | 21 | 98 | 2 years ago | 3 | May 22, 2019 | mit | Go | ||
Encoding and decoding GeoJSON <-> Go | ||||||||||
Geospatial | 144 | 3 | 7 | 16 days ago | 18 | December 07, 2021 | 81 | agpl-3.0 | JavaScript | |
Odoo and GIS | ||||||||||
Postgis_adapter | 87 | 11 | 1 | 3 years ago | 17 | March 18, 2011 | 1 | other | Ruby | |
RIP : Fork of spatial_adapter to give postgis more love | ||||||||||
Simplefeatures | 78 | 5 days ago | 65 | June 10, 2022 | 48 | mit | Go | |||
Simple Features is a pure Go Implementation of the OpenGIS Simple Feature Access Specification | ||||||||||
Pgh3 | 76 | a year ago | 1 | apache-2.0 | C | |||||
PostgreSQL extension for the H3 hierarchical geospatial indexing system | ||||||||||
Python Postgis | 63 | a year ago | 4 | Python | ||||||
PostGIS helpers for psycopg2 and asyncpg |
Extension for working with Postgis. As intermediate format used Geo Json.
The preferred way to install this extension is through Composer.
{
"require": {
"nanson/yii2-postgis": "*"
}
}
Converts coordinates array to SQL expression for saving in postgis binary format before insert/update and from postgis binary to array after find.
<?php
use yii\db\ActiveRecord;
use nanson\postgis\behaviors\GeometryBehavior;
class MyModel extends ActiveRecord
{
// ...
public function behaviors()
{
return [
[
'class' => GeometryBehavior::className(),
'type' => GeometryBehavior::GEOMETRY_POINT,
'attribute' => 'point',
// explicitly set custom db connection if you do not want to use
// static::getDb() or Yii::$app->getDb() connections
'db' => 'db_custom'
],
[
'class' => GeometryBehavior::className(),
'type' => GeometryBehavior::GEOMETRY_LINESTRING,
'attribute' => 'line',
// skip attribute if it was not selected as Geo Json (by PostgisQueryTrait), because it requires a separate query.
'skipAfterFindPostgis' => true,
],
];
}
// ...
}
// ...
$model = new MyModel;
$model->point = [39.234, 54.456];
$model->line = [[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]];
$model->save();
?>
Option | Type | Default | Description |
---|---|---|---|
attribute | string | attribute that will be automatically handled | |
type | string | geometry type: Point , LineString , Polygon , MultiPoint , MultiLineString , MultiPolygon
|
|
skipAfterFindPostgis | boolean | false | skip convertion after find, if data in postgis binary (it requires a separate query, look PostgisQueryTrait ) |
Generate SQL expression before insert/update based on geometry and radius
<?php
use yii\db\ActiveRecord;
use nanson\postgis\behaviors\GeometryBehavior;
use nanson\postgis\behaviors\StBufferBehavior;
class MyModel extends ActiveRecord
{
// ...
public function behaviors()
{
return [
[
'class' => GeometryBehavior::className(),
'attribute' => 'point',
'type' => GeometryBehavior::GEOMETRY_POINT,
],
[
'class' => StBufferBehavior::className(),
'attribute' => 'buffer',
'attributeGeometry' => 'point',
'attributeRadius' => 'radius',
],
];
}
// ...
}
// ...
$model = new MyModel;
$model->point = [39.234, 54.456];
$model->radius = 5;
// It will be save St_Buffer for `$model->point` with `$model->radius` in `$model->buffer`
$model->save();
?>
Option | Type | Default | Description |
---|---|---|---|
attribute | string | attribute for saving buffer | |
attributeGeometry | string | attribute with geometry | |
attributeRadius | string | attribute with radius | |
geography | boolean | false | build buffer as geography |
radiusUnit | string |
deg for geomtery or m for geography |
units of buffer radius: deg , m , km
|
options | array | [] | additional options for St_Buffer function |
Extends ActiveQuery for working with Postgis data.
<?php
class MyQuery extends \yii\db\ActiveQuery
{
use \nanson\postgis\db\PostgisQueryTrait;
// ...
}
// ...
class MyModel extends \yii\db\ActiveRecord
{
public static function find(){
return \Yii::createObject([
'class' => MyQuery::className(),
], [get_called_class()]);
}
}
?>
Option | Type | Default | Description |
---|---|---|---|
autoGeoJson | boolean | true | select all geo columns as GeoJson automatically |
geoFields | array | all table columns with data type geometry or geography
|
table columns, that must be selected as Geo Json |
exceptGeoFields | boolean | false | exclude all geo columns from select statement |
exceptFields | array | [] | columns, which must be excluded from select statement |
Method | Description |
---|---|
withGeoFields($fields=null) | Add columns, that must be selected as Geo Json. Accepts null , string , array . If fields is null - all geoFileds will be added. |
excludeFields($fields=null) | Exclude columns from select statement. Accepts null , string , array . If fields is null - all exceptFields will be excluded from select statement. |
Helper for working with Geo Json
Method | Returns | Description |
---|---|---|
toArray($geoJson) | array | returns coordinates array by Geo Json |
toGeoJson($type, $coordinates, $srid=4326) | string (geo json) | returns Geo Json by geometry type, coordinates array and SRID |
toGeometry($type, $coordinates, $srid=4326) | string (sql expression) | the same, that toGeoJson , but wraps result by "ST_GeomFromGeoJSON('$geoJson')"
|