Error while processing json data
Hi I test your great code with some json data and for some it's work perfectly and for other it doesn't while my json is correct (i test it with a validator). Could you just have a look at this code please :
$json = '{ "type": "Feature", "properties": { "IIDTN_FRT": "test"}, "geometry": { "type": "Polygon", "coordinates":[ [[[1.6051958566706,50.785936202881],[1.6035577181033,50.786331165949],[1.6036272417271,50.786490972741],[1.6037969382322,50.786624987962],[1.6041839477005,50.786792164244],[1.6046934098152,50.78714709222],[1.6048584090552,50.787422397645],[1.6049731931262,50.787888965505],[1.6052573913483,50.788336485091],[1.6057083401075,50.788384091537],[1.6061482799832,50.788513039937],[1.6063639672226,50.788647351108],[1.6065610139567,50.788828930519],[1.6068650256711,50.789270813966],[1.607075797545,50.789828450257],[1.6070115346163,50.790671111528],[1.6069376464062,50.790999874813],[1.6066874254713,50.791643247549],[1.6064843317236,50.792351365233],[1.6064166446318,50.792845616202],[1.606223766391,50.793101929623],[1.6061364550305,50.793299215329],[1.6061411880416,50.793466435912],[1.6062409008458,50.793712665294],[1.6067011089333,50.794019979963],[1.6067487097456,50.794187068363],[1.6064929082631,50.794837103446],[1.6062037185237,50.795914911599],[1.6056571797231,50.79736187957],[1.6052387215233,50.798177982637],[1.6047862416646,50.799311791108],[1.6045125617485,50.799781835828],[1.6043323755464,50.800011466138],[1.6040304871711,50.801024110774],[1.6061178156331,50.801071056569],[1.6071163760902,50.801055994173],[1.6086430038263,50.8009390864],[1.6090752979237,50.801216164707],[1.6091018993069,50.801713634896],[1.6091556157668,50.801817438129],[1.6093368753415,50.801883926923],[1.6110921379731,50.801819002747],[1.6122515683712,50.801719775368],[1.6132479797856,50.80161245365],[1.6151480279832,50.801344726775],[1.6157166439056,50.800750318725],[1.6158133574053,50.800562131826],[1.6158254225854,50.800431766068],[1.6157173173456,50.800192635204],[1.6139127165632,50.798025713941],[1.6138062237643,50.797927576773],[1.612991809047,50.797410860171],[1.6127552586171,50.797207230138],[1.6126360762814,50.797030687965],[1.6125378593967,50.796652538209],[1.6122645865852,50.793378973862],[1.6121795334486,50.793106498798],[1.6119522644812,50.792942627496],[1.6110340373853,50.792622464612],[1.61074245503,50.792462612884],[1.6104691025385,50.792220287038],[1.6103225879518,50.791981423199],[1.6100866778656,50.790669846697],[1.6099278309427,50.790212720735],[1.6074551972525,50.787507024282],[1.6070660559365,50.78732826646],[1.6059453262665,50.787117423065],[1.6055502328683,50.786935365941],[1.6053786097774,50.786775852918],[1.6053159781859,50.786649546594],[1.6051958566706,50.785936202881]]] ]}}';
$polygon1 = geoPHP::load($json);
$area = round(($polygon1->getArea())/1000000,3);
$centroid = $polygon1->getCentroid();
$centX = $centroid->getX();
$centY = $centroid->getY();
print "This polygon2 has an area of ".$area." and a centroid with X=".$centX." and Y=".$centY;
I posted your feature in http://geojsonlint.com/ and it does not validate.
at first glace you seem to have nested 1 too many arrays, eg
{ "type": "Feature", "properties": { "IIDTN_FRT": "test"}, "geometry": { "type": "Polygon", "coordinates":[ [[1.6051958566706,50.785936202881],[1.6035577181033,50.786331165949],[1.6036272417271,50.786490972741],[1.6037969382322,50.786624987962],[1.6041839477005,50.786792164244],[1.6046934098152,50.78714709222],[1.6048584090552,50.787422397645],[1.6049731931262,50.787888965505],[1.6052573913483,50.788336485091],[1.6057083401075,50.788384091537],[1.6061482799832,50.788513039937],[1.6063639672226,50.788647351108],[1.6065610139567,50.788828930519],[1.6068650256711,50.789270813966],[1.607075797545,50.789828450257],[1.6070115346163,50.790671111528],[1.6069376464062,50.790999874813],[1.6066874254713,50.791643247549],[1.6064843317236,50.792351365233],[1.6064166446318,50.792845616202],[1.606223766391,50.793101929623],[1.6061364550305,50.793299215329],[1.6061411880416,50.793466435912],[1.6062409008458,50.793712665294],[1.6067011089333,50.794019979963],[1.6067487097456,50.794187068363],[1.6064929082631,50.794837103446],[1.6062037185237,50.795914911599],[1.6056571797231,50.79736187957],[1.6052387215233,50.798177982637],[1.6047862416646,50.799311791108],[1.6045125617485,50.799781835828],[1.6043323755464,50.800011466138],[1.6040304871711,50.801024110774],[1.6061178156331,50.801071056569],[1.6071163760902,50.801055994173],[1.6086430038263,50.8009390864],[1.6090752979237,50.801216164707],[1.6091018993069,50.801713634896],[1.6091556157668,50.801817438129],[1.6093368753415,50.801883926923],[1.6110921379731,50.801819002747],[1.6122515683712,50.801719775368],[1.6132479797856,50.80161245365],[1.6151480279832,50.801344726775],[1.6157166439056,50.800750318725],[1.6158133574053,50.800562131826],[1.6158254225854,50.800431766068],[1.6157173173456,50.800192635204],[1.6139127165632,50.798025713941],[1.6138062237643,50.797927576773],[1.612991809047,50.797410860171],[1.6127552586171,50.797207230138],[1.6126360762814,50.797030687965],[1.6125378593967,50.796652538209],[1.6122645865852,50.793378973862],[1.6121795334486,50.793106498798],[1.6119522644812,50.792942627496],[1.6110340373853,50.792622464612],[1.61074245503,50.792462612884],[1.6104691025385,50.792220287038],[1.6103225879518,50.791981423199],[1.6100866778656,50.790669846697],[1.6099278309427,50.790212720735],[1.6074551972525,50.787507024282],[1.6070660559365,50.78732826646],[1.6059453262665,50.787117423065],[1.6055502328683,50.786935365941],[1.6053786097774,50.786775852918],[1.6053159781859,50.786649546594],[1.6051958566706,50.785936202881]] ]}}
does validate
Thanks for your return my online validator validate it a a json http://www.freeformatter.com/json-validator.html I will use yours in the futur! Thanks again for your great code!