upgrade bootstrap and js
This commit is contained in:
72
vendor/Shapefile/Geometry/Geometry.php
vendored
72
vendor/Shapefile/Geometry/Geometry.php
vendored
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* @package Shapefile
|
||||
* @author Gaspare Sganga
|
||||
* @version 3.3.0
|
||||
* @version 4.0.0dev
|
||||
* @license MIT
|
||||
* @link https://gasparesganga.com/labs/php-shapefile/
|
||||
*/
|
||||
@@ -473,44 +473,58 @@ abstract class Geometry
|
||||
* Return sanitized GeoJSON, keeping just the geometry part.
|
||||
* It attempts to sanitize user-provided GeoJSON and throws an exception if it appears to be invalid.
|
||||
*
|
||||
* If a GeoJSON Feature is provided, properties data will be stored within the Geometry.
|
||||
*
|
||||
* @param string $geojson The GeoJSON to sanitize.
|
||||
*
|
||||
* @return string
|
||||
* @return array [
|
||||
* "coordinates" => []
|
||||
* "flag_m" => bool
|
||||
* ]
|
||||
*/
|
||||
protected function geojsonSanitize($geojson)
|
||||
{
|
||||
$geojson = json_decode($geojson, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new ShapefileException(Shapefile::ERR_INPUT_GEOJSON_NOT_VALID, 'Cannot parse JSON input');
|
||||
}
|
||||
|
||||
// If it is null it means "an empty Geometry"
|
||||
if ($geojson === null) {
|
||||
// Treat any value other than a GeoJSON object as null (empty Geometry)
|
||||
if (!is_array($geojson)) {
|
||||
return null;
|
||||
}
|
||||
// If it is a Feature just keep the Geometry part
|
||||
if (isset($geojson['geometry'])) {
|
||||
$geojson = $geojson['geometry'];
|
||||
}
|
||||
// Check if "type" and "coordinates" are defined
|
||||
if (!isset($geojson['type'], $geojson['coordinates'])) {
|
||||
throw new ShapefileException(Shapefile::ERR_INPUT_GEOJSON_NOT_VALID);
|
||||
}
|
||||
// Check if "type" is consistent with current Geometry
|
||||
if (substr(strtoupper(trim($geojson['type'])), 0, strlen($this->getGeoJSONBasetype())) != strtoupper($this->getGeoJSONBasetype())) {
|
||||
throw new ShapefileException(Shapefile::ERR_INPUT_GEOJSON_NOT_VALID);
|
||||
|
||||
// Handle Feature
|
||||
$geojson = array_change_key_case($geojson, CASE_LOWER);
|
||||
if (isset($geojson['type']) && strtolower(trim($geojson['type'])) === 'feature') {
|
||||
if (!isset($geojson['properties']) || !is_array($geojson['properties'])) {
|
||||
throw new ShapefileException(Shapefile::ERR_INPUT_GEOJSON_NOT_VALID, 'Feature "properties" not defined');
|
||||
}
|
||||
$this->setDataArray($geojson['properties']);
|
||||
$geometry = !empty($geojson['geometry']) ? array_change_key_case($geojson['geometry'], CASE_LOWER) : null;
|
||||
} else {
|
||||
$geometry = $geojson;
|
||||
}
|
||||
|
||||
return $geojson;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if GeoJSON type represents a Geometry that has a M dimension.
|
||||
*
|
||||
* @param string $type The type speficied in the GeoJSON.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function geojsonIsM($type)
|
||||
{
|
||||
return substr($type, -1) == 'M';
|
||||
// If geometry is null it means "an empty Geometry"
|
||||
if ($geometry === null) {
|
||||
return null;
|
||||
}
|
||||
// Check if "type" and "coordinates" are defined and in correct format
|
||||
if (!isset($geometry['type'], $geometry['coordinates']) || !is_string($geometry['type']) || !is_array($geometry['coordinates'])) {
|
||||
throw new ShapefileException(Shapefile::ERR_INPUT_GEOJSON_NOT_VALID, 'Geometry "type" or "coordinates" not correctly defined');
|
||||
}
|
||||
// Check if "type" is consistent with current Geometry
|
||||
$type = strtoupper(trim($geometry['type']));
|
||||
if (substr($type, 0, strlen($this->getGeoJSONBasetype())) != strtoupper($this->getGeoJSONBasetype())) {
|
||||
throw new ShapefileException(Shapefile::ERR_INPUT_GEOJSON_NOT_VALID, 'Wrong Geometry type - ' . $geometry['type']);
|
||||
}
|
||||
|
||||
// Empty "coordinates" array means empty Geometry
|
||||
return empty($geometry['coordinates']) ? null : [
|
||||
'coordinates' => $geometry['coordinates'],
|
||||
'flag_m' => substr($type, -1) == 'M',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -603,7 +617,7 @@ abstract class Geometry
|
||||
($force_z && $force_m && $count < 4) ||
|
||||
$count > 4
|
||||
) {
|
||||
throw new ShapefileException($err_code);
|
||||
throw new ShapefileException($err_code, 'Wrong coordinates format');
|
||||
}
|
||||
|
||||
$ret = [
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* @package Shapefile
|
||||
* @author Gaspare Sganga
|
||||
* @version 3.3.0
|
||||
* @version 4.0.0dev
|
||||
* @license MIT
|
||||
* @link https://gasparesganga.com/labs/php-shapefile/
|
||||
*/
|
||||
|
||||
6
vendor/Shapefile/Geometry/Linestring.php
vendored
6
vendor/Shapefile/Geometry/Linestring.php
vendored
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* @package Shapefile
|
||||
* @author Gaspare Sganga
|
||||
* @version 3.3.0
|
||||
* @version 4.0.0dev
|
||||
* @license MIT
|
||||
* @link https://gasparesganga.com/labs/php-shapefile/
|
||||
*/
|
||||
@@ -188,8 +188,8 @@ class Linestring extends MultiPoint
|
||||
*/
|
||||
private function computeGaussArea($points, $exp = 0)
|
||||
{
|
||||
// If a coefficient of 10^9 is not enough, give up!
|
||||
if ($exp > 9) {
|
||||
// If a coefficient of 10^12 is not enough, give up!
|
||||
if ($exp > 12) {
|
||||
return 0;
|
||||
}
|
||||
$coef = pow(10, $exp);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* @package Shapefile
|
||||
* @author Gaspare Sganga
|
||||
* @version 3.3.0
|
||||
* @version 4.0.0dev
|
||||
* @license MIT
|
||||
* @link https://gasparesganga.com/labs/php-shapefile/
|
||||
*/
|
||||
@@ -105,11 +105,13 @@ class MultiLinestring extends GeometryCollection
|
||||
$this->checkInit();
|
||||
$geojson = $this->geojsonSanitize($geojson);
|
||||
if ($geojson !== null) {
|
||||
$force_m = $this->geojsonIsM($geojson['type']);
|
||||
foreach ($geojson['coordinates'] as $part) {
|
||||
if (!is_array($part)) {
|
||||
throw new ShapefileException(Shapefile::ERR_INPUT_GEOJSON_NOT_VALID, 'Wrong coordinates format');
|
||||
}
|
||||
$Linestring = new Linestring();
|
||||
foreach ($part as $geojson_coordinates) {
|
||||
$coordinates = $this->geojsonParseCoordinates($geojson_coordinates, $force_m);
|
||||
$coordinates = $this->geojsonParseCoordinates($geojson_coordinates, $geojson['flag_m']);
|
||||
$Point = new Point($coordinates['x'], $coordinates['y'], $coordinates['z'], $coordinates['m']);
|
||||
$Linestring->addPoint($Point);
|
||||
}
|
||||
|
||||
5
vendor/Shapefile/Geometry/MultiPoint.php
vendored
5
vendor/Shapefile/Geometry/MultiPoint.php
vendored
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* @package Shapefile
|
||||
* @author Gaspare Sganga
|
||||
* @version 3.3.0
|
||||
* @version 4.0.0dev
|
||||
* @license MIT
|
||||
* @link https://gasparesganga.com/labs/php-shapefile/
|
||||
*/
|
||||
@@ -88,9 +88,8 @@ class MultiPoint extends GeometryCollection
|
||||
$this->checkInit();
|
||||
$geojson = $this->geojsonSanitize($geojson);
|
||||
if ($geojson !== null) {
|
||||
$force_m = $this->geojsonIsM($geojson['type']);
|
||||
foreach ($geojson['coordinates'] as $geojson_coordinates) {
|
||||
$coordinates = $this->geojsonParseCoordinates($geojson_coordinates, $force_m);
|
||||
$coordinates = $this->geojsonParseCoordinates($geojson_coordinates, $geojson['flag_m']);
|
||||
$Point = new Point($coordinates['x'], $coordinates['y'], $coordinates['z'], $coordinates['m']);
|
||||
$this->addPoint($Point);
|
||||
}
|
||||
|
||||
11
vendor/Shapefile/Geometry/MultiPolygon.php
vendored
11
vendor/Shapefile/Geometry/MultiPolygon.php
vendored
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* @package Shapefile
|
||||
* @author Gaspare Sganga
|
||||
* @version 3.3.0
|
||||
* @version 4.0.0dev
|
||||
* @license MIT
|
||||
* @link https://gasparesganga.com/labs/php-shapefile/
|
||||
*/
|
||||
@@ -156,13 +156,18 @@ class MultiPolygon extends GeometryCollection
|
||||
$this->checkInit();
|
||||
$geojson = $this->geojsonSanitize($geojson);
|
||||
if ($geojson !== null) {
|
||||
$force_m = $this->geojsonIsM($geojson['type']);
|
||||
foreach ($geojson['coordinates'] as $part) {
|
||||
if (!is_array($part)) {
|
||||
throw new ShapefileException(Shapefile::ERR_INPUT_GEOJSON_NOT_VALID, 'Wrong coordinates format');
|
||||
}
|
||||
$Polygon = new Polygon(null, $this->closed_rings, $this->force_orientation);
|
||||
foreach ($part as $ring) {
|
||||
if (!is_array($ring)) {
|
||||
throw new ShapefileException(Shapefile::ERR_INPUT_GEOJSON_NOT_VALID, 'Wrong coordinates format');
|
||||
}
|
||||
$Linestring = new Linestring();
|
||||
foreach ($ring as $geojson_coordinates) {
|
||||
$coordinates = $this->geojsonParseCoordinates($geojson_coordinates, $force_m);
|
||||
$coordinates = $this->geojsonParseCoordinates($geojson_coordinates, $geojson['flag_m']);
|
||||
$Point = new Point($coordinates['x'], $coordinates['y'], $coordinates['z'], $coordinates['m']);
|
||||
$Linestring->addPoint($Point);
|
||||
}
|
||||
|
||||
4
vendor/Shapefile/Geometry/Point.php
vendored
4
vendor/Shapefile/Geometry/Point.php
vendored
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* @package Shapefile
|
||||
* @author Gaspare Sganga
|
||||
* @version 3.3.0
|
||||
* @version 4.0.0dev
|
||||
* @license MIT
|
||||
* @link https://gasparesganga.com/labs/php-shapefile/
|
||||
*/
|
||||
@@ -110,7 +110,7 @@ class Point extends Geometry
|
||||
$this->checkInit();
|
||||
$geojson = $this->geojsonSanitize($geojson);
|
||||
if ($geojson !== null) {
|
||||
$coordinates = $this->geojsonParseCoordinates($geojson['coordinates'], $this->geojsonIsM($geojson['type']));
|
||||
$coordinates = $this->geojsonParseCoordinates($geojson['coordinates'], $geojson['flag_m']);
|
||||
$this->init($coordinates['x'], $coordinates['y'], $coordinates['z'], $coordinates['m']);
|
||||
}
|
||||
return $this;
|
||||
|
||||
2
vendor/Shapefile/Geometry/Polygon.php
vendored
2
vendor/Shapefile/Geometry/Polygon.php
vendored
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* @package Shapefile
|
||||
* @author Gaspare Sganga
|
||||
* @version 3.3.0
|
||||
* @version 4.0.0dev
|
||||
* @license MIT
|
||||
* @link https://gasparesganga.com/labs/php-shapefile/
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user