Code Monkey home page Code Monkey logo

php-libkml's Introduction

PHP KML parser

Donate Latest Version on Packagist GitHub Tests Action Status Total Downloads License

A php library to parse KML/KMZ files.

php-libKML maps KML/KMZ data into PHP objects that follow the KML specification. The purpose of the library is to create KML file from code, parse KML files and convert to another format maintaining the complete KML information.

Features

  • KML schema version 2.2
  • PHP 7.4+
  • Composer integration
  • Object oriented design
  • Comprehensive KML model
  • Import
    • KML

Future features:

  • Google extensions support
  • Import
    • KMZ
    • GeoJson
  • Export
    • KML/KMZ
    • GeoJson
    • WKT

Installation

You can install the package via composer:

composer require simonschaufi/php-libkml

Usage

$kmlReader = new KmlReader();
$kmlDocument = $kmlReader->fromString($kml);
// or
$kmlDocument = $kmlReader->fromKmlFile($kmlFilePath);

Contributing

Pull Requests are gladly welcome!

Please remember to add an issue and connect it to your pull requests. It is very helpful to understand what kind of issue the PR is going to solve.

Bugfixes:

Please describe what kind of bug your fix solves and give us feedback on how to reproduce the issue. We're going to accept only bugfixes if we can reproduce the issue.

Execute unit tests:

composer local:tests:unit

Execute acceptance tests:

composer local:tests:acceptance

Credits

License

The MIT License (MIT). Please see License File for more information.

php-libkml's People

Contributors

actions-user avatar dependabot[bot] avatar earelin avatar simonschaufi avatar yariksheptykin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

php-libkml's Issues

Partial conversion of KML files with MultiGeometry to GeoJSON + missing conversion of ExtendedData

Dear @earelin,

Thank you for this library which is really useful for KML conversion to GeoJSON.

I'd like to inform you that the conversion of KML files with MultiGeometry to GeoJSON doesn't work.

For instance, if you convert the following KML files with MultiGeometry
points_shapes.kml.txt using the method toExtGeoJSON you'll get a file without the polygons of the MultiGeometry points_shapes_converted_phplibkml.geojson.txt.

Meanwhile GeoJSON.io converts it correctly points_shapes_converted_geojsonio.geojson.txt

If you send the file points_shapes.kml.txt to the test/parse.php you'll get the following fatal error:

Fatal error: Cannot call abstract method libKML\KMLObject::__toString() in /path/to/php-libkml_v0.1/libKML/geometries/MultiGeometry.php on line 51
Call Stack
#	Time	Memory	Function	Location
1	0.0007	320280	{main}( )	.../parse.php:0
2	0.0518	2672032	KML->__toString( )	.../parse.php:106
3	0.0518	2673152	libKML\Document->__toString( )	.../libkml.php:127
4	0.0518	2673224	libKML\Container->__toString( )	.../Document.php:13
5	0.0530	2684880	libKML\Placemark->__toString( )	.../Container.php:71
6	0.0530	2685800	libKML\MultiGeometry->__toString( )	.../Placemark.php:22

Also, Name and Description tags are correctly converted, but I have the felling that ExtendedData are not (for instance they are missing when converted to GeoJSON).

Thanks a lot for your help,

Kind regards,

Alexandre 8)

How to generate KMZ?

Hello,

How do you convert a document to KMZ format, including referenced files like images?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.