I run a query and I get a GeoJSON file, but when I try to load the file into the map, I get the error that it's an Unsuported GeoJSON type. this is the PHP file that generate GeoJSON :
$element = $_POST['element'];
$query = "SELECT one, two, three, ST_AsGeoJSON(geom, 7) AS geojson FROM TABLE WHERE parcel = '$parcel'";
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
$geojson = array(
'type' => 'FeatureCollection',
'features' => array()
);
$i = 0;
while ($line = pg_fetch_assoc($result)) {
$feature = array(
'geometry' => json_decode($line['geojson'], true),
'properties' => $data[]=$line,
'id' => $i++
);
array_push($geojson['features'], $feature);
}
$localData = json_encode($geojson);
//$contData = "data/fileData_".session_id().".json";
$contData = "data/fileData.json";
$file = fopen($contData, "w");
fwrite($file, $localData);
fclose($file);
and the file is like this:
{
"type": "FeatureCollection",
"features": [
{
"geometry": {
"type": "MultiPolygon",
"crs": {
"type": "name",
"properties": {
"name": "EPSG:25830"
}
},
"coordinates": [
[
[
[
628354.2325,
4630884.3655
],
[
628340.7125,
4630906.3255
],
[
628344.293,
4630942.2755
],
[
628344.673,
4630946.0955
],
[
628352.403,
4630943.3355
],
[
628378.293,
4630938.4055
],
[
628427.4635,
4630932.5155
],
[
628453.3535,
4630928.2655
],
[
628536.7735,
4630913.475
],
[
628555.6835,
4630910.325
],
[
628556.4135,
4630908.665
],
[
628557.2335,
4630906.775
],
[
628559.8935,
4630900.655
],
[
628562.8335,
4630893.935
],
[
628565.553,
4630884.025
],
[
628568.773,
4630867.435
],
[
628571.8625,
4630851.215
],
[
628578.6825,
4630828.435
],
[
628586.3525,
4630810.605
],
[
628580.442,
4630804.225
],
[
628579.812,
4630798.165
],
[
628575.472,
4630792.465
],
[
628569.952,
4630788.665
],
[
628555.922,
4630778.625
],
[
628546.3315,
4630771.655
],
[
628530.4115,
4630760.435
],
[
628508.971,
4630744.875
],
[
628505.081,
4630743.235
],
[
628498.651,
4630743.425
],
[
628492.501,
4630743.695
],
[
628447.621,
4630754.185
],
[
628434.221,
4630756.635
],
[
628415.461,
4630756.675
],
[
628398.861,
4630751.805
],
[
628369.832,
4630833.995
],
[
628369.122,
4630836.275
],
[
628354.4225,
4630883.7955
],
[
628354.2325,
4630884.3655
]
]
]
]
},
"properties": {
"id": "25",
"cadastralcode": "50010A00700271",
"parcel": "271",
"zone": "300-400",
"longitude": "41.819076014660794",
"latitude": "-1.4532398649376337",
"altitude": "364",
"geojson": "{\"type\":\"MultiPolygon\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:25830\"}},\"coordinates\":[[[[628354.2325,4630884.3655],[628340.7125,4630906.3255],[628344.293,4630942.2755],[628344.673,4630946.0955],[628352.403,4630943.3355],[628378.293,4630938.4055],[628427.4635,4630932.5155],[628453.3535,4630928.2655],[628536.7735,4630913.475],[628555.6835,4630910.325],[628556.4135,4630908.665],[628557.2335,4630906.775],[628559.8935,4630900.655],[628562.8335,4630893.935],[628565.553,4630884.025],[628568.773,4630867.435],[628571.8625,4630851.215],[628578.6825,4630828.435],[628586.3525,4630810.605],[628580.442,4630804.225],[628579.812,4630798.165],[628575.472,4630792.465],[628569.952,4630788.665],[628555.922,4630778.625],[628546.3315,4630771.655],[628530.4115,4630760.435],[628508.971,4630744.875],[628505.081,4630743.235],[628498.651,4630743.425],[628492.501,4630743.695],[628447.621,4630754.185],[628434.221,4630756.635],[628415.461,4630756.675],[628398.861,4630751.805],[628369.832,4630833.995],[628369.122,4630836.275],[628354.4225,4630883.7955],[628354.2325,4630884.3655]]]]}"
},
"id": 0
}
]
}
I don't know what is the problem