Coder Social home page Coder Social logo

geojson's People

Contributors

aewalker avatar eymengunay avatar gabplch avatar gnutix avatar jeromegamez avatar jmikola avatar minicodemonkey avatar munkie avatar pborreli avatar sasezaki avatar simonschaufi avatar toooni avatar tsuguya 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geojson's Issues

Improved documentation

Hello!

I try to use this package, but the examples in the USAGE.md file is not clear for me...

In my case I need to extract points from database and then serve as API to the client, that's show a map with a mapbox gl implementation.

Can you please let me an real example? If you can... In the meantime I'll try to deal with this. If I can reach my goal I'll a PR with my usage example.

Thanks in advance. Regards.

Adjusting constructor for multiple arguments

The code in Point seems more complicated than necessary. It may be good to modify the constructor so that it's more clear how to structure data going into the class. For instance:

    public function __construct(
        $latitude,
        $longitude,
        CoordinateReferenceSystem $crs = null,
        BoundingBox $box = null
    ) {
        $this->coordinates = [
            $latitude,
            $longitude
        ];

FeatureCollection and Feature should be top-level object classes

Point,MultiPoint,LineString, etc. are all \GeoJson\Geometry objects, e.g. \GeoJson\Geometry\Point. This follows spec.

Feature and FeatureCollection are both in the \GeoJson\Feature hierarchy -- \GeoJson\Feature\FeatureCollection and \GeoJson\Feature\Feature. I think this is out of spec. The Feature and FeatureCollection classes do not extend a common Feature class -- FeatureCollection has no properties in common with Feature.

PHP 8.1: Return type of GeoJson\GeoJson::jsonSerialize()

When using PHP 8.1, i get the following log message :

Deprecated: Return type of GeoJson\GeoJson::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

I appears all the class extending \JsonSerializable and implementing the "jsonSerializer" method needs their return to be explicitly typed to "mixed" for this deprecation to disappear.

Example setting point doesn't work in PHP 5.3

<?php
require 'vendor/autoload.php';
$point = new \GeoJson\Geometry\Point([1, 1]);

result:

PHP Parse error: syntax error, unexpected '[', expecting ')' in /file/path/test.php on line 3

This does work:

$point = new \GeoJson\Geometry\Point(array(1, 1));

MultiPolygon not parsing although appearing to be valid

Hello

I am having an issue parsing the following GeoJSON ...

https://gist.github.com/sptdigital/f0b7102bae5e9d72c3845b406c323951

It returns the error message LinearRing requires at least four positions, even though my LinearRings are compliant with the latest version of the GeoJson standard as far as I can see.

I have no issues using this GeoJson anywhere outside of this package.

Could you possibly point me in the right direction please?

Thanks,
Ally

Errors trying to jsonSerialize in PHP 5.3

The readme says "jsonSerialize() will need to be manually called and its return value passed to json_encode()."

<?php
require 'vendor/autoload.php';
$point = new \GeoJson\Geometry\Point(array(1, 1));
$json = json_encode(\GeoJson\GeoJson::jsonSerialize($point));
print($json);

Produces two errors
PHP Strict Standards: Non-static method GeoJson\GeoJson::jsonSerialize() should not be called statically in /path/file.php on line 4
PHP Fatal error: Using $this when not in object context in /path/vendor/jmikola/geojson/src/GeoJson/GeoJson.php on line 66

Please advise.

Adding members not specified by GeoJSON

I would like to suggest that a nice feature would be possibility do add any members to the GeoJSON object. I mean objects that are not specified in GeoJSON standard.

E.g. I am working now on a project, where PHP script will be outputting GeoJSON data. The data will be loaded via AJAX to a JavaScript and then load a Google Map based on the data.

I want to pass via GeoJSON some settings to set up a map e.g. an initial zoom value.

So let's say I have a GeoJSON FeatureColletion object. The collection is made of 1 feature (Point). I am specifying an initial zoom value as 2-nd member. I want my GeoJSON look this:


{
    "type":"FeatureCollection",
    "zoom": 12,
    "bbox":[
        19.967651,
        53.537043,
        19.967651,
        53.537043
    ],
    "features":[
        {
            "type":"Feature",
            "geometry":{
                "type":"Point",
                "coordinates":[
                    19.967651,
                    53.537043
                ]
            },
            "properties": null
        }
    ]
}

As I understand the specification of GeoJSON standard, it is allowed to add such members.

What do you think about it? I mean, what do you think about extending your lib so that you can add other members (not specified in a GeoJSON spec).

PHP warning when Polygon is created from invalid data

When not correct data is used to create Polygon following php warning is shown

new \GeoJson\Geometry\Polygon([[2,4]]);

PHP Warning:  array_map(): An error occurred while invoking the map callback in ...

I suggest removing array_map in Polygon constructor in favor of using foreach to create coordinates array for polygon.

See php bug related to throwing Exception in array_map callback - https://bugs.php.net/bug.php?id=55416

Patch release

Would be nice to have a patch release. I just ran into 844e43a which was fixed 4 years ago.

Documentation is missing

Is the README the only documentation for this library? I don't think I should have to leaf through the test code to find out that a Feature is instantiated with new \GeoJson\Feature\Feature($geometry, $properties, $id); but how would I know the ordering of the arguments otherwise?

Remove CoordinateReferenceSystem classes

As discussed in #33 (comment), RFC7946 states:

B.1. Normative Changes

Specification of coordinate reference systems has been removed, i.e., the "crs" member of [GJ2008] is no longer used.

If CRS is no longer part of the GeoJSON spec, we can consider removing these classes altogether.

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.