Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

rogeriolino/doctrine-geojson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

doctrine-geojson

GeoJson Doctrine Models

Requirements

  • PHP 5.4+
  • Doctrine 2.4+

Usage

Saving

  <?php
  
  $feature = new Feature();
  $feature->add(new Property('name', 'Rogerio Lino'));
  $feature->setGeometry(
    (new Geometry('Point'))
      ->add(new Coordinate(-40, -20, 0))
  );
  
  $entityManager->persist($feature);
  $entityManager->flush();

Retrieving

  <?php

  $features = $entityManager
                    ->getRepository('RogerioLino\Doctrine\GeoJson\Feature')
                    ->findAll();
  echo json_encode(new FeatureCollection($features));

JSON Output

  {
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    -40,
                    -20,
                    0
                ]
            },
            "properties": {
                "name": "Rogerio Lino"
            }
        }
    ]
  }

About

GeoJson Doctrine Models

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages