PHPackages                             yermo/geophpwithfeatures - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. yermo/geophpwithfeatures

ActiveLibrary

yermo/geophpwithfeatures
========================

GeoPHPwithFeatures is an extended version of the original GeoPHP library which is an open-source native PHP library for doing geometry operations. It is written entirely in PHP and can therefore run on shared hosts. It can read and write a wide variety of formats: WKT (including EWKT), WKB (including EWKB), GeoJSON, KML, GPX, GeoRSS). It works with all Simple-Feature geometries (Point, LineString, Polygon, GeometryCollection etc.) and can be used to get centroids, bounding-boxes, area, and a wide variety of other useful information.

1.2(11y ago)5134[2 issues](https://github.com/Yermo/geoPHPwithFeatures/issues)GPL-2 or New-BSDPHP

Since Dec 2Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Yermo/geoPHPwithFeatures)[ Packagist](https://packagist.org/packages/yermo/geophpwithfeatures)[ Docs](https://github.com/phayes/geoPHP)[ RSS](/packages/yermo-geophpwithfeatures/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

[geophp.net](https://geophp.net "GeoPHP homepage")

The GeoPHP project has stated that it intends to restrict their project to pure geometry data. In other words, no features data such as what you might find in a GPX file.

GeoPHPwithFeatures is a fork of the popular GeoPHP project that adds features metadata to geometries.

The primary purpose of this fork is to add support for GPX file features data and convert that to and from GeoJSON making it easier to handle the kinds of features data you might find in a GPS generated GPX file and render that on a LeafLet map. I needed this capability for the next version of the maps on my site: [miles-by-motorcycle.com](https://miles-by-motorcycle.com "Miles-By-Motorcycle")

The other adaptors (KML, etc) simply ignore the metadata as of this writing.

GPX files with extension metadata can be read and written. They can also be converted to the GeoJSON format where geometries with metadata are converted to GeoJSON Features objects with a properties property that includes a verbatim copy of the GPX meta data extensions. The GeoJSON spec has no opinions on how the properties property is formatted so I've chosen to simply mimic the metadata structure found in GPX files keeping all the extension names the same (e.g. Garmin's gpxx:RouteExtension, gpxx:WaypointExtension, et al.)

Please note:

- A properties property is included at the top level FeaturesCollection, in violation of the standard.
- A metadata object is included in the LineString point type to represent elevation, time, and other metadata (from the GPX file) also in violation of the standard.
- GPX trkseg's in a given trk are coalesced into a single trkseg.

For an example of a Garmin Zumo 550 generated GPX file converted to GeoJSON see the tests/input/gpx and tests/input/json directories.

A simple command line tool, bin/geo\_convert.php, is included to convert files manually. You may find the xmllint and json\_pp useful for formatting the output so that it is human readable. For an example try:

$ cd geoPHPwithFeatures/bin $ php geo\_convert.php --input-path=../test/input/gpx/2\_test.gpx --input-format=gpx --output-path=test.json --output-format=geojson

For documentation please refer to the GeoPHP project.

The only public changes are the addition of an additional "metadata" parameter to all geometry constructors in addition to setMetaData() and getMetaData(). In all cases, they simply take an arbitrary associative array. Everything else should be backwards compatible with the main GeoPHP project.

Packages:

libxerces-c-samples - needed to validate GPX files. See [http://www.topografix.com/gpx\_validation.asp](http://www.topografix.com/gpx_validation.asp) (SAXCount)

Original GeoPHP README
----------------------

[](#original-geophp-readme)

GeoPHP is a open-source native PHP library for doing geometry operations. It is written entirely in PHP and can therefore run on shared hosts. It can read and write a wide variety of formats: WKT (including EWKT), WKB (including EWKB), GeoJSON, KML, GPX, and GeoRSS. It works with all Simple-Feature geometries (Point, LineString, Polygon, GeometryCollection etc.) and can be used to get centroids, bounding-boxes, area, and a wide variety of other useful information.

geoPHP also helpfully wraps the GEOS php extension so that applications can get a transparent performance increase when GEOS is installed on the server. When GEOS is installed, geoPHP also becomes fully compliant with the OpenGIS® Implementation Standard for Geographic information. With GEOS you get the full-set of openGIS functions in PHP like Union, IsWithin, Touches etc. This means that applications get a useful "core-set" of geometry operations that work in all environments, and an "extended-set"of operations for environments that have GEOS installed.

See the 'getting started' section below for references and examples of everything that geoPHP can do.

This project is currently looking for co-maintainers. If you think you can help out, please send me a message. Forks are also welcome, please issue pull requests and I will merge them into the main branch.

Getting Started
---------------

[](#getting-started)

- The lastest stable version can always be downloaded at:
- Read the API Reference at:
- Examples
    - Using geoPHP as a GIS format converter:
- Other Interesting Links:
    - Learn about GEOS integration at:

Example usage
-------------

[](#example-usage)

```
