Refactor gis file export tests
Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
@ -378,26 +378,31 @@ class GisVisualization
|
||||
*/
|
||||
public function toFileAsPdf(string $fileName): void
|
||||
{
|
||||
// create pdf
|
||||
$pdf = new TCPDF('', 'pt', Config::getInstance()->config->PDFDefaultPageSize, true, 'UTF-8', false);
|
||||
|
||||
// disable header and footer
|
||||
$pdf->setPrintHeader(false);
|
||||
$pdf->setPrintFooter(false);
|
||||
|
||||
//set auto page breaks
|
||||
$pdf->setAutoPageBreak(false);
|
||||
|
||||
// add a page
|
||||
$pdf->AddPage();
|
||||
|
||||
$fileName = $this->sanitizeName($fileName, 'pdf');
|
||||
$pdf = $this->createEmptyPdf(Config::getInstance()->config->PDFDefaultPageSize ?? 'A4');
|
||||
$this->prepareDataSet($this->data, 'pdf', $pdf);
|
||||
|
||||
// sanitize file name
|
||||
$fileName = $this->sanitizeName($fileName, 'pdf');
|
||||
$pdf->Output($fileName, 'D');
|
||||
}
|
||||
|
||||
private function createEmptyPdf(string $format): TCPDF
|
||||
{
|
||||
$pdf = new TCPDF(
|
||||
orientation: 'P',
|
||||
unit: 'pt',
|
||||
format: $format,
|
||||
unicode: true,
|
||||
encoding: 'UTF-8',
|
||||
diskcache: false,
|
||||
);
|
||||
$pdf->setPrintHeader(false);
|
||||
$pdf->setPrintFooter(false);
|
||||
$pdf->setAutoPageBreak(false);
|
||||
$pdf->AddPage();
|
||||
|
||||
return $pdf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert file to given format
|
||||
*
|
||||
|
||||
3
tests/test_data/gis/.gitignore
vendored
@ -1 +1,4 @@
|
||||
*-actual.json
|
||||
*-actual.pdf
|
||||
*-actual.png
|
||||
*-actual.svg
|
||||
|
||||
BIN
tests/test_data/gis/empty-expected.png
Normal file
|
After Width: | Height: | Size: 364 B |
5
tests/test_data/gis/empty-expected.svg
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg version="1.1" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="200" height="150">
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 189 B |
BIN
tests/test_data/gis/geometries-expected.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
14
tests/test_data/gis/geometries-expected.svg
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg version="1.1" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="200" height="150">
|
||||
<g>
|
||||
<circle cx="100" cy="75" r="3" class="point vector" fill="white" stroke="#b02ee0" stroke-width="2" data-label="Point"/>
|
||||
<polyline points="25,85 15,135 65,125 " class="linestring vector" fill="none" stroke="#e0642e" stroke-width="2" data-label="LineString"/>
|
||||
<path d="M15,15L15,65L65,15ZM22,28L22,48L31,38ZM28,22L48,22L38,31Z" class="polygon vector" stroke="black" stroke-width="0.5" fill="#e0d62e" fill-rule="evenodd" fill-opacity="0.8" data-label="Polygon"/>
|
||||
<circle cx="25" cy="75" r="3" class="multipoint vector" fill="white" stroke="#2e97e0" stroke-width="2" data-label="MultiPoint"/>
|
||||
<circle cx="175" cy="75" r="3" class="multipoint vector" fill="white" stroke="#2e97e0" stroke-width="2" data-label="MultiPoint"/>
|
||||
<polyline points="135,15 180,15 135,25 " class="linestring vector" fill="none" stroke="#bce02e" stroke-width="2" data-label="MultiLineString"/>
|
||||
<polyline points="185,65 185,20 175,65 " class="linestring vector" fill="none" stroke="#bce02e" stroke-width="2" data-label="MultiLineString"/>
|
||||
<path d="M185,135L185,85L135,135ZM175,125L175,110L160,125Z" class="multipolygon vector" stroke="black" stroke-width="0.5" fill="#e02e75" fill-rule="evenodd" fill-opacity="0.8" data-label="MultiPolygon"/>
|
||||
<path d="M175,85L125,85L125,135ZM150,95L135,95L135,110Z" class="multipolygon vector" stroke="black" stroke-width="0.5" fill="#e02e75" fill-rule="evenodd" fill-opacity="0.8" data-label="MultiPolygon"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.5 KiB |
14
tests/test_data/gis/geometrycollection-expected.svg
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg version="1.1" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="200" height="150">
|
||||
<g>
|
||||
<circle cx="100" cy="75" r="3" class="point vector" fill="white" stroke="#b02ee0" stroke-width="2" data-label="GeometryCollection"/>
|
||||
<polyline points="25,85 15,135 65,125 " class="linestring vector" fill="none" stroke="#b02ee0" stroke-width="2" data-label="GeometryCollection"/>
|
||||
<path d="M15,15L15,65L65,15ZM22,28L22,48L31,38ZM28,22L48,22L38,31Z" class="polygon vector" stroke="black" stroke-width="0.5" fill="#b02ee0" fill-rule="evenodd" fill-opacity="0.8" data-label="GeometryCollection"/>
|
||||
<circle cx="25" cy="75" r="3" class="multipoint vector" fill="white" stroke="#b02ee0" stroke-width="2" data-label="GeometryCollection"/>
|
||||
<circle cx="175" cy="75" r="3" class="multipoint vector" fill="white" stroke="#b02ee0" stroke-width="2" data-label="GeometryCollection"/>
|
||||
<polyline points="135,15 180,15 135,25 " class="linestring vector" fill="none" stroke="#b02ee0" stroke-width="2" data-label="GeometryCollection"/>
|
||||
<polyline points="185,65 185,20 175,65 " class="linestring vector" fill="none" stroke="#b02ee0" stroke-width="2" data-label="GeometryCollection"/>
|
||||
<path d="M185,135L185,85L135,135ZM175,125L175,110L160,125Z" class="multipolygon vector" stroke="black" stroke-width="0.5" fill="#b02ee0" fill-rule="evenodd" fill-opacity="0.8" data-label="GeometryCollection"/>
|
||||
<path d="M175,85L125,85L125,135ZM150,95L135,95L135,110Z" class="multipolygon vector" stroke="black" stroke-width="0.5" fill="#b02ee0" fill-rule="evenodd" fill-opacity="0.8" data-label="GeometryCollection"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 836 B |
|
Before Width: | Height: | Size: 766 B |
|
Before Width: | Height: | Size: 705 B |
1
tests/test_data/gis/ol-empty-null-expected.json
Normal file
@ -0,0 +1 @@
|
||||
[]
|
||||
318
tests/test_data/gis/ol-geometries-0-expected.json
Normal file
@ -0,0 +1,318 @@
|
||||
[
|
||||
{
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
85,
|
||||
0
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"circle": {
|
||||
"fill": {
|
||||
"color": "white"
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224
|
||||
],
|
||||
"width": 2
|
||||
},
|
||||
"radius": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "LineString",
|
||||
"coordinates": [
|
||||
[
|
||||
10,
|
||||
-10
|
||||
],
|
||||
[
|
||||
0,
|
||||
-60
|
||||
],
|
||||
[
|
||||
50,
|
||||
-50
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"stroke": {
|
||||
"color": [
|
||||
224,
|
||||
100,
|
||||
46
|
||||
],
|
||||
"width": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "Polygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
0,
|
||||
60
|
||||
],
|
||||
[
|
||||
0,
|
||||
10
|
||||
],
|
||||
[
|
||||
50,
|
||||
60
|
||||
],
|
||||
[
|
||||
0,
|
||||
60
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
7,
|
||||
47
|
||||
],
|
||||
[
|
||||
7,
|
||||
27
|
||||
],
|
||||
[
|
||||
16,
|
||||
37
|
||||
],
|
||||
[
|
||||
7,
|
||||
47
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
13,
|
||||
53
|
||||
],
|
||||
[
|
||||
33,
|
||||
53
|
||||
],
|
||||
[
|
||||
23,
|
||||
44
|
||||
],
|
||||
[
|
||||
13,
|
||||
53
|
||||
]
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"fill": {
|
||||
"color": [
|
||||
224,
|
||||
214,
|
||||
46,
|
||||
0.8
|
||||
]
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"width": 0.5
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "MultiPoint",
|
||||
"coordinates": [
|
||||
[
|
||||
10,
|
||||
0
|
||||
],
|
||||
[
|
||||
160,
|
||||
0
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"circle": {
|
||||
"fill": {
|
||||
"color": "white"
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
46,
|
||||
151,
|
||||
224
|
||||
],
|
||||
"width": 2
|
||||
},
|
||||
"radius": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "MultiLineString",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
120,
|
||||
60
|
||||
],
|
||||
[
|
||||
165,
|
||||
60
|
||||
],
|
||||
[
|
||||
120,
|
||||
50
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
170,
|
||||
10
|
||||
],
|
||||
[
|
||||
170,
|
||||
55
|
||||
],
|
||||
[
|
||||
160,
|
||||
10
|
||||
]
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"stroke": {
|
||||
"color": [
|
||||
188,
|
||||
224,
|
||||
46
|
||||
],
|
||||
"width": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "MultiPolygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
[
|
||||
170,
|
||||
-60
|
||||
],
|
||||
[
|
||||
170,
|
||||
-10
|
||||
],
|
||||
[
|
||||
120,
|
||||
-60
|
||||
],
|
||||
[
|
||||
170,
|
||||
-60
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
160,
|
||||
-50
|
||||
],
|
||||
[
|
||||
160,
|
||||
-35
|
||||
],
|
||||
[
|
||||
145,
|
||||
-50
|
||||
],
|
||||
[
|
||||
160,
|
||||
-50
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
[
|
||||
160,
|
||||
-10
|
||||
],
|
||||
[
|
||||
110,
|
||||
-10
|
||||
],
|
||||
[
|
||||
110,
|
||||
-60
|
||||
],
|
||||
[
|
||||
160,
|
||||
-10
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
135,
|
||||
-20
|
||||
],
|
||||
[
|
||||
120,
|
||||
-20
|
||||
],
|
||||
[
|
||||
120,
|
||||
-35
|
||||
],
|
||||
[
|
||||
135,
|
||||
-20
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"fill": {
|
||||
"color": [
|
||||
224,
|
||||
46,
|
||||
117,
|
||||
0.8
|
||||
]
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"width": 0.5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
318
tests/test_data/gis/ol-geometries-4326-expected.json
Normal file
@ -0,0 +1,318 @@
|
||||
[
|
||||
{
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
85,
|
||||
0
|
||||
],
|
||||
"srid": 4326
|
||||
},
|
||||
"style": {
|
||||
"circle": {
|
||||
"fill": {
|
||||
"color": "white"
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224
|
||||
],
|
||||
"width": 2
|
||||
},
|
||||
"radius": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "LineString",
|
||||
"coordinates": [
|
||||
[
|
||||
10,
|
||||
-10
|
||||
],
|
||||
[
|
||||
0,
|
||||
-60
|
||||
],
|
||||
[
|
||||
50,
|
||||
-50
|
||||
]
|
||||
],
|
||||
"srid": 4326
|
||||
},
|
||||
"style": {
|
||||
"stroke": {
|
||||
"color": [
|
||||
224,
|
||||
100,
|
||||
46
|
||||
],
|
||||
"width": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "Polygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
0,
|
||||
60
|
||||
],
|
||||
[
|
||||
0,
|
||||
10
|
||||
],
|
||||
[
|
||||
50,
|
||||
60
|
||||
],
|
||||
[
|
||||
0,
|
||||
60
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
7,
|
||||
47
|
||||
],
|
||||
[
|
||||
7,
|
||||
27
|
||||
],
|
||||
[
|
||||
16,
|
||||
37
|
||||
],
|
||||
[
|
||||
7,
|
||||
47
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
13,
|
||||
53
|
||||
],
|
||||
[
|
||||
33,
|
||||
53
|
||||
],
|
||||
[
|
||||
23,
|
||||
44
|
||||
],
|
||||
[
|
||||
13,
|
||||
53
|
||||
]
|
||||
]
|
||||
],
|
||||
"srid": 4326
|
||||
},
|
||||
"style": {
|
||||
"fill": {
|
||||
"color": [
|
||||
224,
|
||||
214,
|
||||
46,
|
||||
0.8
|
||||
]
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"width": 0.5
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "MultiPoint",
|
||||
"coordinates": [
|
||||
[
|
||||
10,
|
||||
0
|
||||
],
|
||||
[
|
||||
160,
|
||||
0
|
||||
]
|
||||
],
|
||||
"srid": 4326
|
||||
},
|
||||
"style": {
|
||||
"circle": {
|
||||
"fill": {
|
||||
"color": "white"
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
46,
|
||||
151,
|
||||
224
|
||||
],
|
||||
"width": 2
|
||||
},
|
||||
"radius": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "MultiLineString",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
120,
|
||||
60
|
||||
],
|
||||
[
|
||||
165,
|
||||
60
|
||||
],
|
||||
[
|
||||
120,
|
||||
50
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
170,
|
||||
10
|
||||
],
|
||||
[
|
||||
170,
|
||||
55
|
||||
],
|
||||
[
|
||||
160,
|
||||
10
|
||||
]
|
||||
]
|
||||
],
|
||||
"srid": 4326
|
||||
},
|
||||
"style": {
|
||||
"stroke": {
|
||||
"color": [
|
||||
188,
|
||||
224,
|
||||
46
|
||||
],
|
||||
"width": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "MultiPolygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
[
|
||||
170,
|
||||
-60
|
||||
],
|
||||
[
|
||||
170,
|
||||
-10
|
||||
],
|
||||
[
|
||||
120,
|
||||
-60
|
||||
],
|
||||
[
|
||||
170,
|
||||
-60
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
160,
|
||||
-50
|
||||
],
|
||||
[
|
||||
160,
|
||||
-35
|
||||
],
|
||||
[
|
||||
145,
|
||||
-50
|
||||
],
|
||||
[
|
||||
160,
|
||||
-50
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
[
|
||||
160,
|
||||
-10
|
||||
],
|
||||
[
|
||||
110,
|
||||
-10
|
||||
],
|
||||
[
|
||||
110,
|
||||
-60
|
||||
],
|
||||
[
|
||||
160,
|
||||
-10
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
135,
|
||||
-20
|
||||
],
|
||||
[
|
||||
120,
|
||||
-20
|
||||
],
|
||||
[
|
||||
120,
|
||||
-35
|
||||
],
|
||||
[
|
||||
135,
|
||||
-20
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
"srid": 4326
|
||||
},
|
||||
"style": {
|
||||
"fill": {
|
||||
"color": [
|
||||
224,
|
||||
46,
|
||||
117,
|
||||
0.8
|
||||
]
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"width": 0.5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
318
tests/test_data/gis/ol-geometries-null-expected.json
Normal file
@ -0,0 +1,318 @@
|
||||
[
|
||||
{
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
85,
|
||||
0
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"circle": {
|
||||
"fill": {
|
||||
"color": "white"
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224
|
||||
],
|
||||
"width": 2
|
||||
},
|
||||
"radius": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "LineString",
|
||||
"coordinates": [
|
||||
[
|
||||
10,
|
||||
-10
|
||||
],
|
||||
[
|
||||
0,
|
||||
-60
|
||||
],
|
||||
[
|
||||
50,
|
||||
-50
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"stroke": {
|
||||
"color": [
|
||||
224,
|
||||
100,
|
||||
46
|
||||
],
|
||||
"width": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "Polygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
0,
|
||||
60
|
||||
],
|
||||
[
|
||||
0,
|
||||
10
|
||||
],
|
||||
[
|
||||
50,
|
||||
60
|
||||
],
|
||||
[
|
||||
0,
|
||||
60
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
7,
|
||||
47
|
||||
],
|
||||
[
|
||||
7,
|
||||
27
|
||||
],
|
||||
[
|
||||
16,
|
||||
37
|
||||
],
|
||||
[
|
||||
7,
|
||||
47
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
13,
|
||||
53
|
||||
],
|
||||
[
|
||||
33,
|
||||
53
|
||||
],
|
||||
[
|
||||
23,
|
||||
44
|
||||
],
|
||||
[
|
||||
13,
|
||||
53
|
||||
]
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"fill": {
|
||||
"color": [
|
||||
224,
|
||||
214,
|
||||
46,
|
||||
0.8
|
||||
]
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"width": 0.5
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "MultiPoint",
|
||||
"coordinates": [
|
||||
[
|
||||
10,
|
||||
0
|
||||
],
|
||||
[
|
||||
160,
|
||||
0
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"circle": {
|
||||
"fill": {
|
||||
"color": "white"
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
46,
|
||||
151,
|
||||
224
|
||||
],
|
||||
"width": 2
|
||||
},
|
||||
"radius": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "MultiLineString",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
120,
|
||||
60
|
||||
],
|
||||
[
|
||||
165,
|
||||
60
|
||||
],
|
||||
[
|
||||
120,
|
||||
50
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
170,
|
||||
10
|
||||
],
|
||||
[
|
||||
170,
|
||||
55
|
||||
],
|
||||
[
|
||||
160,
|
||||
10
|
||||
]
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"stroke": {
|
||||
"color": [
|
||||
188,
|
||||
224,
|
||||
46
|
||||
],
|
||||
"width": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "MultiPolygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
[
|
||||
170,
|
||||
-60
|
||||
],
|
||||
[
|
||||
170,
|
||||
-10
|
||||
],
|
||||
[
|
||||
120,
|
||||
-60
|
||||
],
|
||||
[
|
||||
170,
|
||||
-60
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
160,
|
||||
-50
|
||||
],
|
||||
[
|
||||
160,
|
||||
-35
|
||||
],
|
||||
[
|
||||
145,
|
||||
-50
|
||||
],
|
||||
[
|
||||
160,
|
||||
-50
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
[
|
||||
160,
|
||||
-10
|
||||
],
|
||||
[
|
||||
110,
|
||||
-10
|
||||
],
|
||||
[
|
||||
110,
|
||||
-60
|
||||
],
|
||||
[
|
||||
160,
|
||||
-10
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
135,
|
||||
-20
|
||||
],
|
||||
[
|
||||
120,
|
||||
-20
|
||||
],
|
||||
[
|
||||
120,
|
||||
-35
|
||||
],
|
||||
[
|
||||
135,
|
||||
-20
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"fill": {
|
||||
"color": [
|
||||
224,
|
||||
46,
|
||||
117,
|
||||
0.8
|
||||
]
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"width": 0.5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
323
tests/test_data/gis/ol-geometrycollection-0-expected.json
Normal file
@ -0,0 +1,323 @@
|
||||
[
|
||||
{
|
||||
"isCollection": true,
|
||||
"geometries": [
|
||||
{
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
85,
|
||||
0
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"circle": {
|
||||
"fill": {
|
||||
"color": "white"
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224
|
||||
],
|
||||
"width": 2
|
||||
},
|
||||
"radius": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "LineString",
|
||||
"coordinates": [
|
||||
[
|
||||
10,
|
||||
-10
|
||||
],
|
||||
[
|
||||
0,
|
||||
-60
|
||||
],
|
||||
[
|
||||
50,
|
||||
-50
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"stroke": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224
|
||||
],
|
||||
"width": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "Polygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
0,
|
||||
60
|
||||
],
|
||||
[
|
||||
0,
|
||||
10
|
||||
],
|
||||
[
|
||||
50,
|
||||
60
|
||||
],
|
||||
[
|
||||
0,
|
||||
60
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
7,
|
||||
47
|
||||
],
|
||||
[
|
||||
7,
|
||||
27
|
||||
],
|
||||
[
|
||||
16,
|
||||
37
|
||||
],
|
||||
[
|
||||
7,
|
||||
47
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
13,
|
||||
53
|
||||
],
|
||||
[
|
||||
33,
|
||||
53
|
||||
],
|
||||
[
|
||||
23,
|
||||
44
|
||||
],
|
||||
[
|
||||
13,
|
||||
53
|
||||
]
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"fill": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224,
|
||||
0.8
|
||||
]
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"width": 0.5
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "MultiPoint",
|
||||
"coordinates": [
|
||||
[
|
||||
10,
|
||||
0
|
||||
],
|
||||
[
|
||||
160,
|
||||
0
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"circle": {
|
||||
"fill": {
|
||||
"color": "white"
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224
|
||||
],
|
||||
"width": 2
|
||||
},
|
||||
"radius": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "MultiLineString",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
120,
|
||||
60
|
||||
],
|
||||
[
|
||||
165,
|
||||
60
|
||||
],
|
||||
[
|
||||
120,
|
||||
50
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
170,
|
||||
10
|
||||
],
|
||||
[
|
||||
170,
|
||||
55
|
||||
],
|
||||
[
|
||||
160,
|
||||
10
|
||||
]
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"stroke": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224
|
||||
],
|
||||
"width": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "MultiPolygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
[
|
||||
170,
|
||||
-60
|
||||
],
|
||||
[
|
||||
170,
|
||||
-10
|
||||
],
|
||||
[
|
||||
120,
|
||||
-60
|
||||
],
|
||||
[
|
||||
170,
|
||||
-60
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
160,
|
||||
-50
|
||||
],
|
||||
[
|
||||
160,
|
||||
-35
|
||||
],
|
||||
[
|
||||
145,
|
||||
-50
|
||||
],
|
||||
[
|
||||
160,
|
||||
-50
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
[
|
||||
160,
|
||||
-10
|
||||
],
|
||||
[
|
||||
110,
|
||||
-10
|
||||
],
|
||||
[
|
||||
110,
|
||||
-60
|
||||
],
|
||||
[
|
||||
160,
|
||||
-10
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
135,
|
||||
-20
|
||||
],
|
||||
[
|
||||
120,
|
||||
-20
|
||||
],
|
||||
[
|
||||
120,
|
||||
-35
|
||||
],
|
||||
[
|
||||
135,
|
||||
-20
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"fill": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224,
|
||||
0.8
|
||||
]
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"width": 0.5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
323
tests/test_data/gis/ol-geometrycollection-4326-expected.json
Normal file
@ -0,0 +1,323 @@
|
||||
[
|
||||
{
|
||||
"isCollection": true,
|
||||
"geometries": [
|
||||
{
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
85,
|
||||
0
|
||||
],
|
||||
"srid": 4326
|
||||
},
|
||||
"style": {
|
||||
"circle": {
|
||||
"fill": {
|
||||
"color": "white"
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224
|
||||
],
|
||||
"width": 2
|
||||
},
|
||||
"radius": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "LineString",
|
||||
"coordinates": [
|
||||
[
|
||||
10,
|
||||
-10
|
||||
],
|
||||
[
|
||||
0,
|
||||
-60
|
||||
],
|
||||
[
|
||||
50,
|
||||
-50
|
||||
]
|
||||
],
|
||||
"srid": 4326
|
||||
},
|
||||
"style": {
|
||||
"stroke": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224
|
||||
],
|
||||
"width": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "Polygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
0,
|
||||
60
|
||||
],
|
||||
[
|
||||
0,
|
||||
10
|
||||
],
|
||||
[
|
||||
50,
|
||||
60
|
||||
],
|
||||
[
|
||||
0,
|
||||
60
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
7,
|
||||
47
|
||||
],
|
||||
[
|
||||
7,
|
||||
27
|
||||
],
|
||||
[
|
||||
16,
|
||||
37
|
||||
],
|
||||
[
|
||||
7,
|
||||
47
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
13,
|
||||
53
|
||||
],
|
||||
[
|
||||
33,
|
||||
53
|
||||
],
|
||||
[
|
||||
23,
|
||||
44
|
||||
],
|
||||
[
|
||||
13,
|
||||
53
|
||||
]
|
||||
]
|
||||
],
|
||||
"srid": 4326
|
||||
},
|
||||
"style": {
|
||||
"fill": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224,
|
||||
0.8
|
||||
]
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"width": 0.5
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "MultiPoint",
|
||||
"coordinates": [
|
||||
[
|
||||
10,
|
||||
0
|
||||
],
|
||||
[
|
||||
160,
|
||||
0
|
||||
]
|
||||
],
|
||||
"srid": 4326
|
||||
},
|
||||
"style": {
|
||||
"circle": {
|
||||
"fill": {
|
||||
"color": "white"
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224
|
||||
],
|
||||
"width": 2
|
||||
},
|
||||
"radius": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "MultiLineString",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
120,
|
||||
60
|
||||
],
|
||||
[
|
||||
165,
|
||||
60
|
||||
],
|
||||
[
|
||||
120,
|
||||
50
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
170,
|
||||
10
|
||||
],
|
||||
[
|
||||
170,
|
||||
55
|
||||
],
|
||||
[
|
||||
160,
|
||||
10
|
||||
]
|
||||
]
|
||||
],
|
||||
"srid": 4326
|
||||
},
|
||||
"style": {
|
||||
"stroke": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224
|
||||
],
|
||||
"width": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "MultiPolygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
[
|
||||
170,
|
||||
-60
|
||||
],
|
||||
[
|
||||
170,
|
||||
-10
|
||||
],
|
||||
[
|
||||
120,
|
||||
-60
|
||||
],
|
||||
[
|
||||
170,
|
||||
-60
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
160,
|
||||
-50
|
||||
],
|
||||
[
|
||||
160,
|
||||
-35
|
||||
],
|
||||
[
|
||||
145,
|
||||
-50
|
||||
],
|
||||
[
|
||||
160,
|
||||
-50
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
[
|
||||
160,
|
||||
-10
|
||||
],
|
||||
[
|
||||
110,
|
||||
-10
|
||||
],
|
||||
[
|
||||
110,
|
||||
-60
|
||||
],
|
||||
[
|
||||
160,
|
||||
-10
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
135,
|
||||
-20
|
||||
],
|
||||
[
|
||||
120,
|
||||
-20
|
||||
],
|
||||
[
|
||||
120,
|
||||
-35
|
||||
],
|
||||
[
|
||||
135,
|
||||
-20
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
"srid": 4326
|
||||
},
|
||||
"style": {
|
||||
"fill": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224,
|
||||
0.8
|
||||
]
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"width": 0.5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
323
tests/test_data/gis/ol-geometrycollection-null-expected.json
Normal file
@ -0,0 +1,323 @@
|
||||
[
|
||||
{
|
||||
"isCollection": true,
|
||||
"geometries": [
|
||||
{
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
85,
|
||||
0
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"circle": {
|
||||
"fill": {
|
||||
"color": "white"
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224
|
||||
],
|
||||
"width": 2
|
||||
},
|
||||
"radius": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "LineString",
|
||||
"coordinates": [
|
||||
[
|
||||
10,
|
||||
-10
|
||||
],
|
||||
[
|
||||
0,
|
||||
-60
|
||||
],
|
||||
[
|
||||
50,
|
||||
-50
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"stroke": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224
|
||||
],
|
||||
"width": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "Polygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
0,
|
||||
60
|
||||
],
|
||||
[
|
||||
0,
|
||||
10
|
||||
],
|
||||
[
|
||||
50,
|
||||
60
|
||||
],
|
||||
[
|
||||
0,
|
||||
60
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
7,
|
||||
47
|
||||
],
|
||||
[
|
||||
7,
|
||||
27
|
||||
],
|
||||
[
|
||||
16,
|
||||
37
|
||||
],
|
||||
[
|
||||
7,
|
||||
47
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
13,
|
||||
53
|
||||
],
|
||||
[
|
||||
33,
|
||||
53
|
||||
],
|
||||
[
|
||||
23,
|
||||
44
|
||||
],
|
||||
[
|
||||
13,
|
||||
53
|
||||
]
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"fill": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224,
|
||||
0.8
|
||||
]
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"width": 0.5
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "MultiPoint",
|
||||
"coordinates": [
|
||||
[
|
||||
10,
|
||||
0
|
||||
],
|
||||
[
|
||||
160,
|
||||
0
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"circle": {
|
||||
"fill": {
|
||||
"color": "white"
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224
|
||||
],
|
||||
"width": 2
|
||||
},
|
||||
"radius": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "MultiLineString",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
120,
|
||||
60
|
||||
],
|
||||
[
|
||||
165,
|
||||
60
|
||||
],
|
||||
[
|
||||
120,
|
||||
50
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
170,
|
||||
10
|
||||
],
|
||||
[
|
||||
170,
|
||||
55
|
||||
],
|
||||
[
|
||||
160,
|
||||
10
|
||||
]
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"stroke": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224
|
||||
],
|
||||
"width": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"geometry": {
|
||||
"type": "MultiPolygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
[
|
||||
170,
|
||||
-60
|
||||
],
|
||||
[
|
||||
170,
|
||||
-10
|
||||
],
|
||||
[
|
||||
120,
|
||||
-60
|
||||
],
|
||||
[
|
||||
170,
|
||||
-60
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
160,
|
||||
-50
|
||||
],
|
||||
[
|
||||
160,
|
||||
-35
|
||||
],
|
||||
[
|
||||
145,
|
||||
-50
|
||||
],
|
||||
[
|
||||
160,
|
||||
-50
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
[
|
||||
160,
|
||||
-10
|
||||
],
|
||||
[
|
||||
110,
|
||||
-10
|
||||
],
|
||||
[
|
||||
110,
|
||||
-60
|
||||
],
|
||||
[
|
||||
160,
|
||||
-10
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
135,
|
||||
-20
|
||||
],
|
||||
[
|
||||
120,
|
||||
-20
|
||||
],
|
||||
[
|
||||
120,
|
||||
-35
|
||||
],
|
||||
[
|
||||
135,
|
||||
-20
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
"srid": 0
|
||||
},
|
||||
"style": {
|
||||
"fill": {
|
||||
"color": [
|
||||
176,
|
||||
46,
|
||||
224,
|
||||
0.8
|
||||
]
|
||||
},
|
||||
"stroke": {
|
||||
"color": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"width": 0.5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
Before Width: | Height: | Size: 587 B |
|
Before Width: | Height: | Size: 663 B |
@ -1,77 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Abstract parent class for all Gis<Geom_type> test classes
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Tests\Gis;
|
||||
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use ReflectionProperty;
|
||||
use TCPDF;
|
||||
use TCPDF_STATIC;
|
||||
|
||||
use function getcwd;
|
||||
use function md5;
|
||||
use function php_uname;
|
||||
|
||||
use const PHP_INT_MAX;
|
||||
|
||||
/**
|
||||
* Abstract parent class for all Gis<Geom_type> test classes
|
||||
*/
|
||||
abstract class GisGeomTestCase extends AbstractTestCase
|
||||
{
|
||||
protected string $testDir = '';
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->testDir = 'file://' . getcwd() . '/tests/test_data/gis';
|
||||
|
||||
(new ReflectionProperty(TCPDF_STATIC::class, 'tcpdf_version'))->setValue(null, '6.6.2');
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
$property = new ReflectionProperty(TCPDF_STATIC::class, 'tcpdf_version');
|
||||
$property->setValue(null, $property->getDefaultValue());
|
||||
}
|
||||
|
||||
protected function getArch(): string
|
||||
{
|
||||
$arch = php_uname('m');
|
||||
if ($arch === 'x86_64' && PHP_INT_MAX === 2147483647) {
|
||||
$arch = 'x86';
|
||||
}
|
||||
|
||||
return $arch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new pdf document with predictable timestamps and ids.
|
||||
*
|
||||
* @param string $id Used as a seed for the internal file_id
|
||||
*
|
||||
* @return TCPDF A pdf document with an empty page
|
||||
*/
|
||||
protected static function createEmptyPdf(string $id): TCPDF
|
||||
{
|
||||
$pdf = new TCPDF();
|
||||
$prop = new ReflectionProperty($pdf, 'file_id');
|
||||
$prop->setValue($pdf, md5($id));
|
||||
$pdf->setDocCreationTimestamp(1600000000);
|
||||
$pdf->setDocModificationTimestamp(1600000000);
|
||||
$pdf->setAutoPageBreak(false);
|
||||
$pdf->setCompression(false);
|
||||
$pdf->setPrintFooter(false);
|
||||
$pdf->setPrintHeader(false);
|
||||
$pdf->AddPage();
|
||||
|
||||
return $pdf;
|
||||
}
|
||||
}
|
||||
@ -5,20 +5,17 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Tests\Gis;
|
||||
|
||||
use PhpMyAdmin\Gis\Ds\Extent;
|
||||
use PhpMyAdmin\Gis\Ds\ScaleData;
|
||||
use PhpMyAdmin\Gis\GisGeometryCollection;
|
||||
use PhpMyAdmin\Image\ImageWrapper;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\PreserveGlobalState;
|
||||
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
|
||||
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
|
||||
use TCPDF;
|
||||
|
||||
#[CoversClass(GisGeometryCollection::class)]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[RunTestsInSeparateProcesses]
|
||||
class GisGeometryCollectionTest extends GisGeomTestCase
|
||||
class GisGeometryCollectionTest extends AbstractTestCase
|
||||
{
|
||||
/**
|
||||
* Data provider for testGetExtent() test case
|
||||
@ -276,171 +273,4 @@ class GisGeometryCollectionTest extends GisGeomTestCase
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
#[RequiresPhpExtension('gd')]
|
||||
public function testPrepareRowAsPng(): void
|
||||
{
|
||||
$object = new GisGeometryCollection();
|
||||
$image = ImageWrapper::create(200, 124, ['red' => 229, 'green' => 229, 'blue' => 229]);
|
||||
self::assertNotNull($image);
|
||||
$object->prepareRowAsPng(
|
||||
'GEOMETRYCOLLECTION(POLYGON((35 10,10 20,15 40,45 45,35 10),(20 30,35 32,30 20,20 30)),'
|
||||
. 'LINESTRING(5 30,4 4))',
|
||||
'image',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: -19, offsetY: -3, scale: 2.29, height: 124),
|
||||
$image,
|
||||
);
|
||||
self::assertSame(200, $image->width());
|
||||
self::assertSame(124, $image->height());
|
||||
|
||||
$fileExpected = $this->testDir . '/geometrycollection-expected.png';
|
||||
$fileActual = $this->testDir . '/geometrycollection-actual.png';
|
||||
self::assertTrue($image->png($fileActual));
|
||||
self::assertFileEquals($fileExpected, $fileActual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for prepareRowAsPdf
|
||||
*
|
||||
* @param string $spatial string to parse
|
||||
* @param string $label field label
|
||||
* @param int[] $color line color
|
||||
* @param ScaleData $scaleData scaling parameters
|
||||
* @param TCPDF $pdf expected output
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsPdf')]
|
||||
public function testPrepareRowAsPdf(
|
||||
string $spatial,
|
||||
string $label,
|
||||
array $color,
|
||||
ScaleData $scaleData,
|
||||
TCPDF $pdf,
|
||||
): void {
|
||||
$object = new GisGeometryCollection();
|
||||
$object->prepareRowAsPdf($spatial, $label, $color, $scaleData, $pdf);
|
||||
|
||||
$fileExpected = $this->testDir . '/geometrycollection-expected.pdf';
|
||||
self::assertStringEqualsFile($fileExpected, $pdf->Output(dest: 'S'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testPrepareRowAsPdf() test case
|
||||
*
|
||||
* @return array<array{string, string, int[], ScaleData, TCPDF}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsPdf(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'GEOMETRYCOLLECTION(POLYGON((35 10,10 20,15 40,45 45,35 10),(20 30,35 32,30 20,20 30)),'
|
||||
. 'LINESTRING(5 30,4 4))',
|
||||
'pdf',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: 1, offsetY: -9, scale: 4.39, height: 297),
|
||||
|
||||
parent::createEmptyPdf('GEOMETRYCOLLECTION'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for prepareRowAsSvg
|
||||
*
|
||||
* @param string $spatial string to parse
|
||||
* @param string $label field label
|
||||
* @param int[] $color line color
|
||||
* @param ScaleData $scaleData scaling parameters
|
||||
* @param string $output expected output
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsSvg')]
|
||||
public function testPrepareRowAsSvg(
|
||||
string $spatial,
|
||||
string $label,
|
||||
array $color,
|
||||
ScaleData $scaleData,
|
||||
string $output,
|
||||
): void {
|
||||
$object = new GisGeometryCollection();
|
||||
$svg = $object->prepareRowAsSvg($spatial, $label, $color, $scaleData);
|
||||
self::assertSame($output, $svg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testPrepareRowAsSvg() test case
|
||||
*
|
||||
* @return array<array{string, string, int[], ScaleData, string}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsSvg(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'GEOMETRYCOLLECTION(POLYGON((35 10,10 20,15 40,45 45,35 10),(20 30,35 32,30 20,20 30)))',
|
||||
'svg',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: 12, offsetY: 69, scale: 2, height: 150),
|
||||
'<path d="M46,268L-4,248L6,208L66,198ZM16,228L46,224L36,248Z"'
|
||||
. ' class="polygon vector" stroke="black" stroke-width="0.5"'
|
||||
. ' fill="#b02ee0" fill-rule="evenodd" fill-opacity="0.8" data-label="svg"/>',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for prepareRowAsOl
|
||||
*
|
||||
* @param string $spatial string to parse
|
||||
* @param int $srid SRID
|
||||
* @param string $label field label
|
||||
* @param int[] $color line color
|
||||
* @param array<string, mixed> $expected
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsOl')]
|
||||
public function testPrepareRowAsOl(
|
||||
string $spatial,
|
||||
int $srid,
|
||||
string $label,
|
||||
array $color,
|
||||
array $expected,
|
||||
): void {
|
||||
$object = new GisGeometryCollection();
|
||||
self::assertSame($expected, $object->prepareRowAsOl($spatial, $srid, $label, $color));
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testPrepareRowAsOl() test case
|
||||
*
|
||||
* @return array<array{string, int, string, int[], array<string, mixed>}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsOl(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'GEOMETRYCOLLECTION(POLYGON((35 10,10 20,15 40,45 45,35 10),(20 30,35 32,30 20,20 30)))',
|
||||
4326,
|
||||
'Ol',
|
||||
[176, 46, 224],
|
||||
[
|
||||
'isCollection' => true,
|
||||
'geometries' => [
|
||||
[
|
||||
'geometry' => [
|
||||
'type' => 'Polygon',
|
||||
'coordinates' => [
|
||||
[[35.0, 10.0], [10.0, 20.0], [15.0, 40.0], [45.0, 45.0], [35.0, 10.0]],
|
||||
[[20.0, 30.0], [35.0, 32.0], [30.0, 20.0], [20.0, 30.0]],
|
||||
],
|
||||
'srid' => 4326,
|
||||
],
|
||||
'style' => [
|
||||
'fill' => ['color' => [176, 46, 224, 0.8]],
|
||||
'stroke' => ['color' => [0, 0, 0], 'width' => 0.5],
|
||||
'text' => ['text' => 'Ol'],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,20 +5,17 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Tests\Gis;
|
||||
|
||||
use PhpMyAdmin\Gis\Ds\Extent;
|
||||
use PhpMyAdmin\Gis\Ds\ScaleData;
|
||||
use PhpMyAdmin\Gis\GisLineString;
|
||||
use PhpMyAdmin\Image\ImageWrapper;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\PreserveGlobalState;
|
||||
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
|
||||
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
|
||||
use TCPDF;
|
||||
|
||||
#[CoversClass(GisLineString::class)]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[RunTestsInSeparateProcesses]
|
||||
class GisLineStringTest extends GisGeomTestCase
|
||||
class GisLineStringTest extends AbstractTestCase
|
||||
{
|
||||
/**
|
||||
* data provider for testGenerateWkt
|
||||
@ -150,163 +147,4 @@ class GisLineStringTest extends GisGeomTestCase
|
||||
['LINESTRING(12 35,48 75,69 23,25 45,14 53,35 78)', new Extent(minX: 12, minY: 23, maxX: 69, maxY: 78)],
|
||||
];
|
||||
}
|
||||
|
||||
#[RequiresPhpExtension('gd')]
|
||||
public function testPrepareRowAsPng(): void
|
||||
{
|
||||
$object = new GisLineString();
|
||||
$image = ImageWrapper::create(200, 124, ['red' => 229, 'green' => 229, 'blue' => 229]);
|
||||
self::assertNotNull($image);
|
||||
$object->prepareRowAsPng(
|
||||
'LINESTRING(12 35,48 75,69 23,25 45,14 53,35 78)',
|
||||
'image',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: -18, offsetY: 14, scale: 1.71, height: 124),
|
||||
$image,
|
||||
);
|
||||
self::assertSame(200, $image->width());
|
||||
self::assertSame(124, $image->height());
|
||||
|
||||
$fileExpected = $this->testDir . '/linestring-expected.png';
|
||||
$fileActual = $this->testDir . '/linestring-actual.png';
|
||||
self::assertTrue($image->png($fileActual));
|
||||
self::assertFileEquals($fileExpected, $fileActual);
|
||||
}
|
||||
|
||||
/**
|
||||
* test case for prepareRowAsPdf() method
|
||||
*
|
||||
* @param string $spatial GIS LINESTRING object
|
||||
* @param string $label label for the GIS LINESTRING object
|
||||
* @param int[] $color color for the GIS LINESTRING object
|
||||
* @param ScaleData $scaleData array containing data related to scaling
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsPdf')]
|
||||
public function testPrepareRowAsPdf(
|
||||
string $spatial,
|
||||
string $label,
|
||||
array $color,
|
||||
ScaleData $scaleData,
|
||||
TCPDF $pdf,
|
||||
): void {
|
||||
$object = new GisLineString();
|
||||
$object->prepareRowAsPdf($spatial, $label, $color, $scaleData, $pdf);
|
||||
|
||||
$fileExpected = $this->testDir . '/linestring-expected.pdf';
|
||||
self::assertStringEqualsFile($fileExpected, $pdf->Output(dest: 'S'));
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for testPrepareRowAsPdf() test case
|
||||
*
|
||||
* @return array<array{string, string, int[], ScaleData, TCPDF}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsPdf(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'LINESTRING(12 35,48 75,69 23,25 45,14 53,35 78)',
|
||||
'pdf',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: 7, offsetY: 3, scale: 3.15, height: 297),
|
||||
|
||||
parent::createEmptyPdf('LINESTRING'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* test case for prepareRowAsSvg() method
|
||||
*
|
||||
* @param string $spatial GIS LINESTRING object
|
||||
* @param string $label label for the GIS LINESTRING object
|
||||
* @param int[] $color color for the GIS LINESTRING object
|
||||
* @param ScaleData $scaleData array containing data related to scaling
|
||||
* @param string $output expected output
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsSvg')]
|
||||
public function testPrepareRowAsSvg(
|
||||
string $spatial,
|
||||
string $label,
|
||||
array $color,
|
||||
ScaleData $scaleData,
|
||||
string $output,
|
||||
): void {
|
||||
$object = new GisLineString();
|
||||
$svg = $object->prepareRowAsSvg($spatial, $label, $color, $scaleData);
|
||||
self::assertSame($output, $svg);
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for testPrepareRowAsSvg() test case
|
||||
*
|
||||
* @return array<array{string, string, int[], ScaleData, string}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsSvg(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'LINESTRING(12 35,48 75,69 23,25 45,14 53,35 78)',
|
||||
'svg',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: 12, offsetY: 69, scale: 2, height: 150),
|
||||
'<polyline points="0,218 72,138 114,242 26,198 4,182 46,132 " '
|
||||
. 'class="linestring vector" fill="none" '
|
||||
. 'stroke="#b02ee0" stroke-width="2" data-label="svg"/>',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* test case for prepareRowAsOl() method
|
||||
*
|
||||
* @param string $spatial GIS LINESTRING object
|
||||
* @param int $srid spatial reference ID
|
||||
* @param string $label label for the GIS LINESTRING object
|
||||
* @param int[] $color color for the GIS LINESTRING object
|
||||
* @param mixed[] $expected
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsOl')]
|
||||
public function testPrepareRowAsOl(
|
||||
string $spatial,
|
||||
int $srid,
|
||||
string $label,
|
||||
array $color,
|
||||
array $expected,
|
||||
): void {
|
||||
$object = new GisLineString();
|
||||
self::assertSame($expected, $object->prepareRowAsOl($spatial, $srid, $label, $color));
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for testPrepareRowAsOl() test case
|
||||
*
|
||||
* @return array<array{string, int, string, int[], mixed[]}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsOl(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'LINESTRING(12 35,48 75,69 23,25 45,14 53,35 78)',
|
||||
4326,
|
||||
'Ol',
|
||||
[176, 46, 224],
|
||||
[
|
||||
'geometry' => [
|
||||
'type' => 'LineString',
|
||||
'coordinates' => [
|
||||
[12.0, 35.0],
|
||||
[48.0, 75.0],
|
||||
[69.0, 23.0],
|
||||
[25.0, 45.0],
|
||||
[14.0, 53.0],
|
||||
[35.0, 78.0],
|
||||
],
|
||||
'srid' => 4326,
|
||||
],
|
||||
'style' => ['stroke' => ['color' => [176, 46, 224], 'width' => 2], 'text' => ['text' => 'Ol']],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,20 +5,17 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Tests\Gis;
|
||||
|
||||
use PhpMyAdmin\Gis\Ds\Extent;
|
||||
use PhpMyAdmin\Gis\Ds\ScaleData;
|
||||
use PhpMyAdmin\Gis\GisMultiLineString;
|
||||
use PhpMyAdmin\Image\ImageWrapper;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\PreserveGlobalState;
|
||||
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
|
||||
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
|
||||
use TCPDF;
|
||||
|
||||
#[CoversClass(GisMultiLineString::class)]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[RunTestsInSeparateProcesses]
|
||||
class GisMultiLineStringTest extends GisGeomTestCase
|
||||
class GisMultiLineStringTest extends AbstractTestCase
|
||||
{
|
||||
/**
|
||||
* data provider for testGenerateWkt
|
||||
@ -158,161 +155,4 @@ class GisMultiLineStringTest extends GisGeomTestCase
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
#[RequiresPhpExtension('gd')]
|
||||
public function testPrepareRowAsPng(): void
|
||||
{
|
||||
$object = new GisMultiLineString();
|
||||
$image = ImageWrapper::create(200, 124, ['red' => 229, 'green' => 229, 'blue' => 229]);
|
||||
self::assertNotNull($image);
|
||||
$object->prepareRowAsPng(
|
||||
'MULTILINESTRING((36 14,47 23,62 75),(36 10,17 23,178 53))',
|
||||
'image',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: 3, offsetY: -16, scale: 1.06, height: 124),
|
||||
$image,
|
||||
);
|
||||
self::assertSame(200, $image->width());
|
||||
self::assertSame(124, $image->height());
|
||||
|
||||
$fileExpected = $this->testDir . '/multilinestring-expected.png';
|
||||
$fileActual = $this->testDir . '/multilinestring-actual.png';
|
||||
self::assertTrue($image->png($fileActual));
|
||||
self::assertFileEquals($fileExpected, $fileActual);
|
||||
}
|
||||
|
||||
/**
|
||||
* test case for prepareRowAsPdf() method
|
||||
*
|
||||
* @param string $spatial GIS MULTILINESTRING object
|
||||
* @param string $label label for the GIS MULTILINESTRING object
|
||||
* @param int[] $color color for the GIS MULTILINESTRING object
|
||||
* @param ScaleData $scaleData array containing data related to scaling
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsPdf')]
|
||||
public function testPrepareRowAsPdf(
|
||||
string $spatial,
|
||||
string $label,
|
||||
array $color,
|
||||
ScaleData $scaleData,
|
||||
TCPDF $pdf,
|
||||
): void {
|
||||
$object = new GisMultiLineString();
|
||||
$object->prepareRowAsPdf($spatial, $label, $color, $scaleData, $pdf);
|
||||
|
||||
$fileExpected = $this->testDir . '/multilinestring-expected.pdf';
|
||||
self::assertStringEqualsFile($fileExpected, $pdf->Output(dest: 'S'));
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for testPrepareRowAsPdf() test case
|
||||
*
|
||||
* @return array<array{string, string, int[], ScaleData, TCPDF}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsPdf(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'MULTILINESTRING((36 14,47 23,62 75),(36 10,17 23,178 53))',
|
||||
'pdf',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: 4, offsetY: -90, scale: 1.12, height: 297),
|
||||
|
||||
parent::createEmptyPdf('MULTILINESTRING'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* test case for prepareRowAsSvg() method
|
||||
*
|
||||
* @param string $spatial GIS MULTILINESTRING object
|
||||
* @param string $label label for the GIS MULTILINESTRING object
|
||||
* @param int[] $color color for the GIS MULTILINESTRING object
|
||||
* @param ScaleData $scaleData array containing data related to scaling
|
||||
* @param string $output expected output
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsSvg')]
|
||||
public function testPrepareRowAsSvg(
|
||||
string $spatial,
|
||||
string $label,
|
||||
array $color,
|
||||
ScaleData $scaleData,
|
||||
string $output,
|
||||
): void {
|
||||
$object = new GisMultiLineString();
|
||||
$svg = $object->prepareRowAsSvg($spatial, $label, $color, $scaleData);
|
||||
self::assertSame($output, $svg);
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for testPrepareRowAsSvg() test case
|
||||
*
|
||||
* @return array<array{string, string, int[], ScaleData, string}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsSvg(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'MULTILINESTRING((36 14,47 23,62 75),(36 10,17 23,178 53))',
|
||||
'svg',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: 12, offsetY: 69, scale: 2, height: 150),
|
||||
'<polyline points="48,260 70,242 100,138 " '
|
||||
. 'class="linestring vector" fill="none" stroke="#b02ee0" '
|
||||
. 'stroke-width="2" data-label="svg"/><polyline points="48,268 10,'
|
||||
. '242 332,182 " class="linestring vector" fill="none" '
|
||||
. 'stroke="#b02ee0" stroke-width="2" data-label="svg"/>',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* test case for prepareRowAsOl() method
|
||||
*
|
||||
* @param string $spatial GIS MULTILINESTRING object
|
||||
* @param int $srid spatial reference ID
|
||||
* @param string $label label for the GIS MULTILINESTRING object
|
||||
* @param int[] $color color for the GIS MULTILINESTRING object
|
||||
* @param mixed[] $expected
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsOl')]
|
||||
public function testPrepareRowAsOl(
|
||||
string $spatial,
|
||||
int $srid,
|
||||
string $label,
|
||||
array $color,
|
||||
array $expected,
|
||||
): void {
|
||||
$object = new GisMultiLineString();
|
||||
self::assertSame($expected, $object->prepareRowAsOl($spatial, $srid, $label, $color));
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for testPrepareRowAsOl() test case
|
||||
*
|
||||
* @return array<array{string, int, string, int[], mixed[]}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsOl(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'MULTILINESTRING((36 14,47 23,62 75),(36 10,17 23,178 53))',
|
||||
4326,
|
||||
'Ol',
|
||||
[176, 46, 224],
|
||||
[
|
||||
'geometry' => [
|
||||
'type' => 'MultiLineString',
|
||||
'coordinates' => [
|
||||
[[36.0, 14.0], [47.0, 23.0], [62.0, 75.0]],
|
||||
[[36.0, 10.0], [17.0, 23.0], [178.0, 53.0]],
|
||||
],
|
||||
'srid' => 4326,
|
||||
],
|
||||
'style' => ['stroke' => ['color' => [176, 46, 224], 'width' => 2], 'text' => ['text' => 'Ol']],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,22 +5,17 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Tests\Gis;
|
||||
|
||||
use PhpMyAdmin\Gis\Ds\Extent;
|
||||
use PhpMyAdmin\Gis\Ds\ScaleData;
|
||||
use PhpMyAdmin\Gis\GisMultiPoint;
|
||||
use PhpMyAdmin\Image\ImageWrapper;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\PreserveGlobalState;
|
||||
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
|
||||
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
|
||||
use TCPDF;
|
||||
|
||||
use function file_exists;
|
||||
|
||||
#[CoversClass(GisMultiPoint::class)]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[RunTestsInSeparateProcesses]
|
||||
class GisMultiPointTest extends GisGeomTestCase
|
||||
class GisMultiPointTest extends AbstractTestCase
|
||||
{
|
||||
/**
|
||||
* data provider for testGenerateWkt
|
||||
@ -135,179 +130,4 @@ class GisMultiPointTest extends GisGeomTestCase
|
||||
['MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)', new Extent(minX: 12, minY: 23, maxX: 69, maxY: 78)],
|
||||
];
|
||||
}
|
||||
|
||||
#[RequiresPhpExtension('gd')]
|
||||
public function testPrepareRowAsPng(): void
|
||||
{
|
||||
$object = new GisMultiPoint();
|
||||
$image = ImageWrapper::create(200, 124, ['red' => 229, 'green' => 229, 'blue' => 229]);
|
||||
self::assertNotNull($image);
|
||||
$object->prepareRowAsPng(
|
||||
'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)',
|
||||
'image',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: -18, offsetY: 14, scale: 1.71, height: 124),
|
||||
$image,
|
||||
);
|
||||
self::assertSame(200, $image->width());
|
||||
self::assertSame(124, $image->height());
|
||||
|
||||
$fileExpected = $this->testDir . '/multipoint-expected.png';
|
||||
$fileActual = $this->testDir . '/multipoint-actual.png';
|
||||
self::assertTrue($image->png($fileActual));
|
||||
self::assertFileEquals($fileExpected, $fileActual);
|
||||
}
|
||||
|
||||
/**
|
||||
* test case for prepareRowAsPdf() method
|
||||
*
|
||||
* @param string $spatial GIS MULTIPOINT object
|
||||
* @param string $label label for the GIS MULTIPOINT object
|
||||
* @param int[] $color color for the GIS MULTIPOINT object
|
||||
* @param ScaleData $scaleData array containing data related to scaling
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsPdf')]
|
||||
public function testPrepareRowAsPdf(
|
||||
string $spatial,
|
||||
string $label,
|
||||
array $color,
|
||||
ScaleData $scaleData,
|
||||
TCPDF $pdf,
|
||||
): void {
|
||||
$object = new GisMultiPoint();
|
||||
$object->prepareRowAsPdf($spatial, $label, $color, $scaleData, $pdf);
|
||||
|
||||
$fileExpectedArch = $this->testDir . '/multipoint-expected-' . $this->getArch() . '.pdf';
|
||||
$fileExpectedGeneric = $this->testDir . '/multipoint-expected.pdf';
|
||||
$fileExpected = file_exists($fileExpectedArch) ? $fileExpectedArch : $fileExpectedGeneric;
|
||||
self::assertStringEqualsFile($fileExpected, $pdf->Output(dest: 'S'));
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for testPrepareRowAsPdf() test case
|
||||
*
|
||||
* @return array<array{string, string, int[], ScaleData, TCPDF}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsPdf(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)',
|
||||
'pdf',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: 7, offsetY: 3, scale: 3.16, height: 297),
|
||||
|
||||
parent::createEmptyPdf('MULTIPOINT'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* test case for prepareRowAsSvg() method
|
||||
*
|
||||
* @param string $spatial GIS MULTIPOINT object
|
||||
* @param string $label label for the GIS MULTIPOINT object
|
||||
* @param int[] $color color for the GIS MULTIPOINT object
|
||||
* @param ScaleData $scaleData array containing data related to scaling
|
||||
* @param string $output expected output
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsSvg')]
|
||||
public function testPrepareRowAsSvg(
|
||||
string $spatial,
|
||||
string $label,
|
||||
array $color,
|
||||
ScaleData $scaleData,
|
||||
string $output,
|
||||
): void {
|
||||
$object = new GisMultiPoint();
|
||||
$svg = $object->prepareRowAsSvg($spatial, $label, $color, $scaleData);
|
||||
self::assertSame($output, $svg);
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for testPrepareRowAsSvg() test case
|
||||
*
|
||||
* @return array<array{string, string, int[], ScaleData, string}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsSvg(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)',
|
||||
'svg',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: 12, offsetY: 69, scale: 2, height: 150),
|
||||
'<circle cx="72" cy="138" r="3" class="multipoint '
|
||||
. 'vector" fill="white" stroke="#b02ee0" stroke-width="2" data-label="svg"'
|
||||
. '/><circle cx="114" cy="242" r="3" class="mult'
|
||||
. 'ipoint vector" fill="white" stroke="#b02ee0" stroke-width="2" data-label="svg"'
|
||||
. '/><circle cx="26" cy="198" r="3" class='
|
||||
. '"multipoint vector" fill="white" stroke="#b02ee0" stroke-width='
|
||||
. '"2" data-label="svg"/><circle cx="4" cy="182" r="3" '
|
||||
. 'class="multipoint vector" fill="white" stroke="#b02ee0" stroke-'
|
||||
. 'width="2" data-label="svg"/><circle cx="46" cy="132" r="3" class="multipoint vector"'
|
||||
. ' fill="white" stroke="#b02ee0" stroke-width="2" data-label="svg"/>',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* test case for prepareRowAsOl() method
|
||||
*
|
||||
* @param string $spatial GIS MULTIPOINT object
|
||||
* @param int $srid spatial reference ID
|
||||
* @param string $label label for the GIS MULTIPOINT object
|
||||
* @param int[] $color color for the GIS MULTIPOINT object
|
||||
* @param mixed[] $expected
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsOl')]
|
||||
public function testPrepareRowAsOl(
|
||||
string $spatial,
|
||||
int $srid,
|
||||
string $label,
|
||||
array $color,
|
||||
array $expected,
|
||||
): void {
|
||||
$object = new GisMultiPoint();
|
||||
self::assertSame($expected, $object->prepareRowAsOl($spatial, $srid, $label, $color));
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for testPrepareRowAsOl() test case
|
||||
*
|
||||
* @return array<array{string, int, string, int[], mixed[]}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsOl(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)',
|
||||
4326,
|
||||
'Ol',
|
||||
[176, 46, 224],
|
||||
[
|
||||
'geometry' => [
|
||||
'type' => 'MultiPoint',
|
||||
'coordinates' => [
|
||||
[12.0, 35.0],
|
||||
[48.0, 75.0],
|
||||
[69.0, 23.0],
|
||||
[25.0, 45.0],
|
||||
[14.0, 53.0],
|
||||
[35.0, 78.0],
|
||||
],
|
||||
'srid' => 4326,
|
||||
],
|
||||
'style' => [
|
||||
'circle' => [
|
||||
'fill' => ['color' => 'white'],
|
||||
'stroke' => ['color' => [176, 46, 224], 'width' => 2],
|
||||
'radius' => 3,
|
||||
],
|
||||
'text' => ['text' => 'Ol', 'offsetY' => -9],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,20 +5,17 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Tests\Gis;
|
||||
|
||||
use PhpMyAdmin\Gis\Ds\Extent;
|
||||
use PhpMyAdmin\Gis\Ds\ScaleData;
|
||||
use PhpMyAdmin\Gis\GisMultiPolygon;
|
||||
use PhpMyAdmin\Image\ImageWrapper;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\PreserveGlobalState;
|
||||
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
|
||||
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
|
||||
use TCPDF;
|
||||
|
||||
#[CoversClass(GisMultiPolygon::class)]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[RunTestsInSeparateProcesses]
|
||||
class GisMultiPolygonTest extends GisGeomTestCase
|
||||
class GisMultiPolygonTest extends AbstractTestCase
|
||||
{
|
||||
/**
|
||||
* Provide some common data to data providers
|
||||
@ -242,173 +239,4 @@ class GisMultiPolygonTest extends GisGeomTestCase
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
#[RequiresPhpExtension('gd')]
|
||||
public function testPrepareRowAsPng(): void
|
||||
{
|
||||
$object = new GisMultiPolygon();
|
||||
$image = ImageWrapper::create(200, 124, ['red' => 229, 'green' => 229, 'blue' => 229]);
|
||||
self::assertNotNull($image);
|
||||
$object->prepareRowAsPng(
|
||||
'MULTIPOLYGON(((5 5,95 5,95 95,5 95,5 5),(10 10,10 40,40 40,40 10,10 10),(60 60,90 60,90 90,60 90,6'
|
||||
. '0 60)),((-5 -5,-95 -5,-95 -95,-5 -95,-5 -5),(-10 -10,-10 -40,-40 -40,-40 -10,-10 -10),(-60 -60,-90'
|
||||
. ' -60,-90 -90,-60 -90,-60 -60)))',
|
||||
'image',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: -202, offsetY: -125, scale: 0.50, height: 124),
|
||||
$image,
|
||||
);
|
||||
self::assertSame(200, $image->width());
|
||||
self::assertSame(124, $image->height());
|
||||
|
||||
$fileExpected = $this->testDir . '/multipolygon-expected.png';
|
||||
$fileActual = $this->testDir . '/multipolygon-actual.png';
|
||||
self::assertTrue($image->png($fileActual));
|
||||
self::assertFileEquals($fileExpected, $fileActual);
|
||||
}
|
||||
|
||||
/**
|
||||
* test case for prepareRowAsPdf() method
|
||||
*
|
||||
* @param string $spatial GIS MULTIPOLYGON object
|
||||
* @param string $label label for the GIS MULTIPOLYGON object
|
||||
* @param int[] $color color for the GIS MULTIPOLYGON object
|
||||
* @param ScaleData $scaleData array containing data related to scaling
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsPdf')]
|
||||
public function testPrepareRowAsPdf(
|
||||
string $spatial,
|
||||
string $label,
|
||||
array $color,
|
||||
ScaleData $scaleData,
|
||||
TCPDF $pdf,
|
||||
): void {
|
||||
$object = new GisMultiPolygon();
|
||||
$object->prepareRowAsPdf($spatial, $label, $color, $scaleData, $pdf);
|
||||
|
||||
$fileExpected = $this->testDir . '/multipolygon-expected.pdf';
|
||||
self::assertStringEqualsFile($fileExpected, $pdf->Output(dest: 'S'));
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for testPrepareRowAsPdf() test case
|
||||
*
|
||||
* @return array<array{string, string, int[], ScaleData, TCPDF}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsPdf(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'MULTIPOLYGON(((5 5,95 5,95 95,5 95,5 5),(10 10,10 40,40 40,40 10,10 10),(60 60,90 60,90 90,60 90,6'
|
||||
. '0 60)),((-5 -5,-95 -5,-95 -95,-5 -95,-5 -5),(-10 -10,-10 -40,-40 -40,-40 -10,-10 -10),(-60 -60,-90'
|
||||
. ' -60,-90 -90,-60 -90,-60 -60)))',
|
||||
'pdf',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: -110, offsetY: -157, scale: 0.95, height: 297),
|
||||
|
||||
parent::createEmptyPdf('MULTIPOLYGON'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* test case for prepareRowAsSvg() method
|
||||
*
|
||||
* @param string $spatial GIS MULTIPOLYGON object
|
||||
* @param string $label label for the GIS MULTIPOLYGON object
|
||||
* @param int[] $color color for the GIS MULTIPOLYGON object
|
||||
* @param ScaleData $scaleData array containing data related to scaling
|
||||
* @param string $output expected output
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsSvg')]
|
||||
public function testPrepareRowAsSvg(
|
||||
string $spatial,
|
||||
string $label,
|
||||
array $color,
|
||||
ScaleData $scaleData,
|
||||
string $output,
|
||||
): void {
|
||||
$object = new GisMultiPolygon();
|
||||
$svg = $object->prepareRowAsSvg($spatial, $label, $color, $scaleData);
|
||||
self::assertSame($output, $svg);
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for testPrepareRowAsSvg() test case
|
||||
*
|
||||
* @return array<array{string, string, int[], ScaleData, string}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsSvg(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'MULTIPOLYGON(((5 5,95 5,95 95,5 95,5 5),(10 10,10 40,40 40,40 10,10 10),(60 60,90 60,90 90,60 90,6'
|
||||
. '0 60)),((-5 -5,-95 -5,-95 -95,-5 -95,-5 -5),(-10 -10,-10 -40,-40 -40,-40 -10,-10 -10),(-60 -60,-90'
|
||||
. ' -60,-90 -90,-60 -90,-60 -60)))',
|
||||
'svg',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: -50, offsetY: -50, scale: 2, height: 400),
|
||||
'<path d="M110,290L290,290L290,110L110,110ZM120,280L120,220L180,220L180,280ZM220,180L280,180L280,120'
|
||||
. 'L220,120Z" class="multipolygon vector" stroke='
|
||||
. '"black" stroke-width="0.5" fill="#b02ee0" fill-rule="evenodd" fill-opacity="0.8" data-label="svg"'
|
||||
. '/><path d="M90,310L-90,310L-90,490L90,490ZM80,320L80,380L20,380L20,320Z'
|
||||
. 'M-20,420L-80,420L-80,480L-20,480Z" class="multipolygon vector"'
|
||||
. ' stroke="black" stroke-width="0.5" fill="#b02ee0" fill-rule="evenodd" fill-opacity="0.8"'
|
||||
. ' data-label="svg"/>',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* test case for prepareRowAsOl() method
|
||||
*
|
||||
* @param string $spatial GIS MULTIPOLYGON object
|
||||
* @param int $srid spatial reference ID
|
||||
* @param string $label label for the GIS MULTIPOLYGON object
|
||||
* @param int[] $color color for the GIS MULTIPOLYGON object
|
||||
* @param array<string, array<string, mixed>> $expected
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsOl')]
|
||||
public function testPrepareRowAsOl(
|
||||
string $spatial,
|
||||
int $srid,
|
||||
string $label,
|
||||
array $color,
|
||||
array $expected,
|
||||
): void {
|
||||
$object = new GisMultiPolygon();
|
||||
self::assertSame($expected, $object->prepareRowAsOl($spatial, $srid, $label, $color));
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for testPrepareRowAsOl() test case
|
||||
*
|
||||
* @return array<array{string, int, string, int[], array<string, array<string, mixed>>}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsOl(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'MULTIPOLYGON(((136 40,147 83,16 75,136 40)),((105 0,56 20,78 73,105 0)))',
|
||||
4326,
|
||||
'Ol',
|
||||
[176, 46, 224],
|
||||
[
|
||||
'geometry' => [
|
||||
'type' => 'MultiPolygon',
|
||||
'coordinates' => [
|
||||
[[[136.0, 40.0], [147.0, 83.0], [16.0, 75.0], [136.0, 40.0]]],
|
||||
[[[105.0, 0.0], [56.0, 20.0], [78.0, 73.0], [105.0, 0.0]]],
|
||||
],
|
||||
'srid' => 4326,
|
||||
],
|
||||
'style' => [
|
||||
'fill' => ['color' => [176, 46, 224, 0.8]],
|
||||
'stroke' => ['color' => [0, 0, 0], 'width' => 0.5],
|
||||
'text' => ['text' => 'Ol'],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,22 +5,17 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Tests\Gis;
|
||||
|
||||
use PhpMyAdmin\Gis\Ds\Extent;
|
||||
use PhpMyAdmin\Gis\Ds\ScaleData;
|
||||
use PhpMyAdmin\Gis\GisPoint;
|
||||
use PhpMyAdmin\Image\ImageWrapper;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\PreserveGlobalState;
|
||||
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
|
||||
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
|
||||
use TCPDF;
|
||||
|
||||
use function file_exists;
|
||||
|
||||
#[CoversClass(GisPoint::class)]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[RunTestsInSeparateProcesses]
|
||||
class GisPointTest extends GisGeomTestCase
|
||||
class GisPointTest extends AbstractTestCase
|
||||
{
|
||||
/**
|
||||
* data provider for testGenerateWkt
|
||||
@ -146,159 +141,4 @@ class GisPointTest extends GisGeomTestCase
|
||||
{
|
||||
return [['POINT(12 35)', new Extent(minX: 12, minY: 35, maxX: 12, maxY: 35)]];
|
||||
}
|
||||
|
||||
#[RequiresPhpExtension('gd')]
|
||||
public function testPrepareRowAsPng(): void
|
||||
{
|
||||
$object = new GisPoint();
|
||||
$image = ImageWrapper::create(200, 124, ['red' => 229, 'green' => 229, 'blue' => 229]);
|
||||
self::assertNotNull($image);
|
||||
$object->prepareRowAsPng(
|
||||
'POINT(12 35)',
|
||||
'image',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: -88, offsetY: -27, scale: 1, height: 124),
|
||||
$image,
|
||||
);
|
||||
self::assertSame(200, $image->width());
|
||||
self::assertSame(124, $image->height());
|
||||
|
||||
$fileExpected = $this->testDir . '/point-expected.png';
|
||||
$fileActual = $this->testDir . '/point-actual.png';
|
||||
self::assertTrue($image->png($fileActual));
|
||||
self::assertFileEquals($fileExpected, $fileActual);
|
||||
}
|
||||
|
||||
/**
|
||||
* test case for prepareRowAsPdf() method
|
||||
*
|
||||
* @param string $spatial GIS POINT object
|
||||
* @param string $label label for the GIS POINT object
|
||||
* @param int[] $color color for the GIS POINT object
|
||||
* @param ScaleData $scaleData array containing data related to scaling
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsPdf')]
|
||||
public function testPrepareRowAsPdf(
|
||||
string $spatial,
|
||||
string $label,
|
||||
array $color,
|
||||
ScaleData $scaleData,
|
||||
TCPDF $pdf,
|
||||
): void {
|
||||
$object = new GisPoint();
|
||||
$object->prepareRowAsPdf($spatial, $label, $color, $scaleData, $pdf);
|
||||
|
||||
$fileExpectedArch = $this->testDir . '/point-expected-' . $this->getArch() . '.pdf';
|
||||
$fileExpectedGeneric = $this->testDir . '/point-expected.pdf';
|
||||
$fileExpected = file_exists($fileExpectedArch) ? $fileExpectedArch : $fileExpectedGeneric;
|
||||
self::assertStringEqualsFile($fileExpected, $pdf->Output(dest: 'S'));
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for testPrepareRowAsPdf() test case
|
||||
*
|
||||
* @return array<array{string, string, int[], ScaleData, TCPDF}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsPdf(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'POINT(12 35)',
|
||||
'pdf',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: -93, offsetY: -114, scale: 1, height: 297),
|
||||
|
||||
parent::createEmptyPdf('POINT'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* test case for prepareRowAsSvg() method
|
||||
*
|
||||
* @param string $spatial GIS POINT object
|
||||
* @param string $label label for the GIS POINT object
|
||||
* @param int[] $color color for the GIS POINT object
|
||||
* @param ScaleData $scaleData array containing data related to scaling
|
||||
* @param string $output expected output
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsSvg')]
|
||||
public function testPrepareRowAsSvg(
|
||||
string $spatial,
|
||||
string $label,
|
||||
array $color,
|
||||
ScaleData $scaleData,
|
||||
string $output,
|
||||
): void {
|
||||
$object = new GisPoint();
|
||||
$svg = $object->prepareRowAsSvg($spatial, $label, $color, $scaleData);
|
||||
self::assertSame($output, $svg);
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for prepareRowAsSvg() test case
|
||||
*
|
||||
* @return array<array{string, string, int[], ScaleData, string}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsSvg(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'POINT(12 35)',
|
||||
'svg',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: 12, offsetY: 69, scale: 2, height: 150),
|
||||
'',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* test case for prepareRowAsOl() method
|
||||
*
|
||||
* @param string $spatial GIS POINT object
|
||||
* @param int $srid spatial reference ID
|
||||
* @param string $label label for the GIS POINT object
|
||||
* @param int[] $color color for the GIS POINT object
|
||||
* @param array<string, array<string, mixed>> $expected
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsOl')]
|
||||
public function testPrepareRowAsOl(
|
||||
string $spatial,
|
||||
int $srid,
|
||||
string $label,
|
||||
array $color,
|
||||
array $expected,
|
||||
): void {
|
||||
$object = new GisPoint();
|
||||
self::assertSame($expected, $object->prepareRowAsOl($spatial, $srid, $label, $color));
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for testPrepareRowAsOl() test case
|
||||
*
|
||||
* @return array<array{string, int, string, int[], array<string, array<string, mixed>>}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsOl(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'POINT(12 35)',
|
||||
4326,
|
||||
'Ol',
|
||||
[176, 46, 224],
|
||||
[
|
||||
'geometry' => ['type' => 'Point', 'coordinates' => [12.0, 35.0], 'srid' => 4326],
|
||||
'style' => [
|
||||
'circle' => [
|
||||
'fill' => ['color' => 'white'],
|
||||
'stroke' => ['color' => [176, 46, 224], 'width' => 2],
|
||||
'radius' => 3,
|
||||
],
|
||||
'text' => ['text' => 'Ol', 'offsetY' => -9],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,20 +5,17 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Tests\Gis;
|
||||
|
||||
use PhpMyAdmin\Gis\Ds\Extent;
|
||||
use PhpMyAdmin\Gis\Ds\ScaleData;
|
||||
use PhpMyAdmin\Gis\GisPolygon;
|
||||
use PhpMyAdmin\Image\ImageWrapper;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\PreserveGlobalState;
|
||||
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
|
||||
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
|
||||
use TCPDF;
|
||||
|
||||
#[CoversClass(GisPolygon::class)]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[RunTestsInSeparateProcesses]
|
||||
class GisPolygonTest extends GisGeomTestCase
|
||||
class GisPolygonTest extends AbstractTestCase
|
||||
{
|
||||
/**
|
||||
* Provide some common data to data providers
|
||||
@ -153,161 +150,4 @@ class GisPolygonTest extends GisGeomTestCase
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
#[RequiresPhpExtension('gd')]
|
||||
public function testPrepareRowAsPng(): void
|
||||
{
|
||||
$object = new GisPolygon();
|
||||
$image = ImageWrapper::create(200, 124, ['red' => 229, 'green' => 229, 'blue' => 229]);
|
||||
self::assertNotNull($image);
|
||||
$object->prepareRowAsPng(
|
||||
'POLYGON((0 0,100 0,100 100,0 100,0 0),(10 10,10 40,40 40,40 10,10 10),(60 60,90 60,90 90,60 90,60 60))',
|
||||
'image',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: -56, offsetY: -16, scale: 0.94, height: 124),
|
||||
$image,
|
||||
);
|
||||
self::assertSame(200, $image->width());
|
||||
self::assertSame(124, $image->height());
|
||||
|
||||
$fileExpected = $this->testDir . '/polygon-expected.png';
|
||||
$fileActual = $this->testDir . '/polygon-actual.png';
|
||||
self::assertTrue($image->png($fileActual));
|
||||
self::assertFileEquals($fileExpected, $fileActual);
|
||||
}
|
||||
|
||||
/**
|
||||
* test case for prepareRowAsPdf() method
|
||||
*
|
||||
* @param string $spatial GIS POLYGON object
|
||||
* @param string $label label for the GIS POLYGON object
|
||||
* @param int[] $color color for the GIS POLYGON object
|
||||
* @param ScaleData $scaleData array containing data related to scaling
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsPdf')]
|
||||
public function testPrepareRowAsPdf(
|
||||
string $spatial,
|
||||
string $label,
|
||||
array $color,
|
||||
ScaleData $scaleData,
|
||||
TCPDF $pdf,
|
||||
): void {
|
||||
$object = new GisPolygon();
|
||||
$object->prepareRowAsPdf($spatial, $label, $color, $scaleData, $pdf);
|
||||
|
||||
$fileExpected = $this->testDir . '/polygon-expected.pdf';
|
||||
self::assertStringEqualsFile($fileExpected, $pdf->Output(dest: 'S'));
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for testPrepareRowAsPdf() test case
|
||||
*
|
||||
* @return array<array{string, string, int[], ScaleData, TCPDF}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsPdf(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'POLYGON((0 0,100 0,100 100,0 100,0 0),(10 10,10 40,40 40,40 10,10 10),(60 60,90 60,90 90,60 90,60 6'
|
||||
. '0))',
|
||||
'pdf',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: -8, offsetY: -32, scale: 1.80, height: 297),
|
||||
|
||||
parent::createEmptyPdf('POLYGON'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* test case for prepareRowAsSvg() method
|
||||
*
|
||||
* @param string $spatial GIS POLYGON object
|
||||
* @param string $label label for the GIS POLYGON object
|
||||
* @param int[] $color color for the GIS POLYGON object
|
||||
* @param ScaleData $scaleData array containing data related to scaling
|
||||
* @param string $output expected output
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsSvg')]
|
||||
public function testPrepareRowAsSvg(
|
||||
string $spatial,
|
||||
string $label,
|
||||
array $color,
|
||||
ScaleData $scaleData,
|
||||
string $output,
|
||||
): void {
|
||||
$object = new GisPolygon();
|
||||
$svg = $object->prepareRowAsSvg($spatial, $label, $color, $scaleData);
|
||||
self::assertSame($output, $svg);
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for testPrepareRowAsSvg() test case
|
||||
*
|
||||
* @return array<array{string, string, int[], ScaleData, string}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsSvg(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'POLYGON((123 0,23 30,17 63,123 0),(99 12,30 35,25 55,99 12))',
|
||||
'svg',
|
||||
[176, 46, 224],
|
||||
new ScaleData(offsetX: 12, offsetY: 69, scale: 2, height: 150),
|
||||
'<path d="M222,288L22,228L10,162ZM174,264L36,218L26,178Z"'
|
||||
. ' class="polygon vector" stroke="black" stroke-width="0.5" fill="#b02ee0" fill-rule="evenod'
|
||||
. 'd" fill-opacity="0.8" data-label="svg"/>',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* test case for prepareRowAsOl() method
|
||||
*
|
||||
* @param string $spatial GIS POLYGON object
|
||||
* @param int $srid spatial reference ID
|
||||
* @param string $label label for the GIS POLYGON object
|
||||
* @param int[] $color color for the GIS POLYGON object
|
||||
* @param mixed[] $expected
|
||||
*/
|
||||
#[DataProvider('providerForPrepareRowAsOl')]
|
||||
public function testPrepareRowAsOl(
|
||||
string $spatial,
|
||||
int $srid,
|
||||
string $label,
|
||||
array $color,
|
||||
array $expected,
|
||||
): void {
|
||||
$object = new GisPolygon();
|
||||
self::assertSame($expected, $object->prepareRowAsOl($spatial, $srid, $label, $color));
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for testPrepareRowAsOl() test case
|
||||
*
|
||||
* @return array<array{string, int, string, int[], mixed[]}>
|
||||
*/
|
||||
public static function providerForPrepareRowAsOl(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'POLYGON((123 0,23 30,17 63,123 0))',
|
||||
4326,
|
||||
'Ol',
|
||||
[176, 46, 224],
|
||||
[
|
||||
'geometry' => [
|
||||
'type' => 'Polygon',
|
||||
'coordinates' => [[[123.0, 0.0], [23.0, 30.0], [17.0, 63.0], [123.0, 0.0]]],
|
||||
'srid' => 4326,
|
||||
],
|
||||
'style' => [
|
||||
'fill' => ['color' => [176, 46, 224, 0.8]],
|
||||
'stroke' => ['color' => [0, 0, 0], 'width' => 0.5],
|
||||
'text' => ['text' => 'Ol'],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,21 +4,62 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Tests\Gis;
|
||||
|
||||
use Generator;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Gis\Ds\ScaleData;
|
||||
use PhpMyAdmin\Gis\GisVisualization;
|
||||
use PhpMyAdmin\Gis\GisVisualizationSettings;
|
||||
use PhpMyAdmin\Image\ImageWrapper;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
use ReflectionProperty;
|
||||
use TCPDF;
|
||||
use TCPDF_STATIC;
|
||||
use Throwable;
|
||||
|
||||
use function array_map;
|
||||
use function assert;
|
||||
use function file_exists;
|
||||
use function file_put_contents;
|
||||
use function json_encode;
|
||||
use function md5;
|
||||
use function ob_get_clean;
|
||||
use function ob_start;
|
||||
use function php_uname;
|
||||
use function str_replace;
|
||||
use function strrpos;
|
||||
use function strtolower;
|
||||
use function substr_replace;
|
||||
|
||||
use const JSON_PRETTY_PRINT;
|
||||
use const JSON_THROW_ON_ERROR;
|
||||
use const PHP_INT_MAX;
|
||||
use const PNG_ALL_FILTERS;
|
||||
|
||||
#[CoversClass(GisVisualization::class)]
|
||||
class GisVisualizationTest extends AbstractTestCase
|
||||
{
|
||||
private static string $testDataDir = '';
|
||||
|
||||
/** @psalm-suppress PropertyNotSetInConstructor */
|
||||
private DatabaseInterface $dbi;
|
||||
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
self::$testDataDir = __DIR__ . '/../../test_data/gis';
|
||||
(new ReflectionProperty(TCPDF_STATIC::class, 'tcpdf_version'))->setValue(null, '6.6.2');
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
$property = new ReflectionProperty(TCPDF_STATIC::class, 'tcpdf_version');
|
||||
$property->setValue(null, $property->getDefaultValue());
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -27,6 +68,16 @@ class GisVisualizationTest extends AbstractTestCase
|
||||
DatabaseInterface::$instance = $this->dbi;
|
||||
}
|
||||
|
||||
private function getArch(): string
|
||||
{
|
||||
$arch = php_uname('m');
|
||||
if ($arch === 'x86_64' && PHP_INT_MAX === 2147483647) {
|
||||
$arch = 'x86';
|
||||
}
|
||||
|
||||
return $arch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scale the data set
|
||||
*/
|
||||
@ -197,4 +248,181 @@ class GisVisualizationTest extends AbstractTestCase
|
||||
$queryString,
|
||||
);
|
||||
}
|
||||
|
||||
/** @return array<string,list{string,list<array{label:string,wkt:string,srid:int|null}>}> */
|
||||
public static function providerTestGisData(): array
|
||||
{
|
||||
return [
|
||||
'empty' => ['empty', []],
|
||||
'Geometries' => [
|
||||
'Geometries',
|
||||
[
|
||||
[
|
||||
'label' => 'Point',
|
||||
'wkt' => 'POINT(85 0)',
|
||||
'srid' => null,
|
||||
],
|
||||
[
|
||||
'label' => 'LineString',
|
||||
'wkt' => 'LINESTRING(10 -10,0 -60,50 -50)',
|
||||
'srid' => null,
|
||||
],
|
||||
[
|
||||
'label' => 'Polygon',
|
||||
'wkt' => 'POLYGON((0 60,0 10,50 60,0 60),(7 47,7 27,16 37,7 47),(13 53,33 53,23 44,13 53))',
|
||||
'srid' => null,
|
||||
],
|
||||
[
|
||||
'label' => 'MultiPoint',
|
||||
'wkt' => 'MULTIPOINT(10 0,160 0)',
|
||||
'srid' => null,
|
||||
],
|
||||
[
|
||||
'label' => 'MultiLineString',
|
||||
'wkt' => 'MULTILINESTRING((120 60,165 60,120 50),(170 10,170 55,160 10))',
|
||||
'srid' => null,
|
||||
],
|
||||
[
|
||||
'label' => 'MultiPolygon',
|
||||
'wkt' => 'MULTIPOLYGON(((170 -60,170 -10,120 -60,170 -60),(160 -50,160 -35,145 -50,160 -50)),'
|
||||
. '((160 -10,110 -10,110 -60,160 -10),(135 -20,120 -20,120 -35,135 -20)))',
|
||||
'srid' => null,
|
||||
],
|
||||
],
|
||||
],
|
||||
'GeometryCollection' => [
|
||||
'GeometryCollection',
|
||||
[
|
||||
[
|
||||
'label' => 'GeometryCollection',
|
||||
'wkt' => 'GEOMETRYCOLLECTION('
|
||||
. 'POINT(85 0),'
|
||||
. 'LINESTRING(10 -10,0 -60,50 -50),'
|
||||
. 'POLYGON((0 60,0 10,50 60,0 60),(7 47,7 27,16 37,7 47),(13 53,33 53,23 44,13 53)),'
|
||||
. 'MULTIPOINT(10 0,160 0),'
|
||||
. 'MULTILINESTRING((120 60,165 60,120 50),(170 10,170 55,160 10)),'
|
||||
. 'MULTIPOLYGON(((170 -60,170 -10,120 -60,170 -60),(160 -50,160 -35,145 -50,160 -50)),'
|
||||
. '((160 -10,110 -10,110 -60,160 -10),(135 -20,120 -20,120 -35,135 -20))))',
|
||||
'srid' => null,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/** @return Generator<string,list{string,list<array{label:string,wkt:string,srid:int|null}>}> */
|
||||
public static function providerTestGisDataOl(): Generator
|
||||
{
|
||||
foreach (self::providerTestGisData() as $case) {
|
||||
yield $case[0] . '-null' => [$case[0] . '-null', $case[1]];
|
||||
|
||||
if ($case[1] === []) {
|
||||
continue;
|
||||
}
|
||||
|
||||
yield $case[0] . '-0' => [
|
||||
$case[0] . '-0',
|
||||
array_map(
|
||||
static fn (array $geom) => ['label' => $geom['label'], 'wkt' => $geom['wkt'], 'srid' => 0],
|
||||
$case[1],
|
||||
),
|
||||
];
|
||||
|
||||
yield $case[0] . '-4326' => [
|
||||
$case[0] . '-4326',
|
||||
array_map(
|
||||
static fn (array $geom) => ['label' => $geom['label'], 'wkt' => $geom['wkt'], 'srid' => 4326],
|
||||
$case[1],
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/** @param list<array{label:string,wkt:string,srid:int|null}> $data */
|
||||
#[DataProvider('providerTestGisDataOl')]
|
||||
public function testOl(string $name, array $data): void
|
||||
{
|
||||
$vis = GisVisualization::getByData(
|
||||
$data,
|
||||
new GisVisualizationSettings(width: 200, height: 150, spatialColumn: 'wkt'),
|
||||
);
|
||||
$ol = $vis->asOl();
|
||||
|
||||
$this->assertSameOrSaveNewVersion(
|
||||
'ol-' . $name,
|
||||
'json',
|
||||
json_encode($ol, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT),
|
||||
);
|
||||
}
|
||||
|
||||
/** @param list<array{label:string,wkt:string,srid:int|null}> $data */
|
||||
#[DataProvider('providerTestGisData')]
|
||||
public function testSvg(string $name, array $data): void
|
||||
{
|
||||
$vis = GisVisualization::getByData(
|
||||
$data,
|
||||
new GisVisualizationSettings(width: 200, height: 150, spatialColumn: 'wkt', labelColumn: 'label'),
|
||||
);
|
||||
$svg = $vis->asSVG();
|
||||
|
||||
$this->assertSameOrSaveNewVersion($name, 'svg', str_replace('><', ">\n<", $svg));
|
||||
}
|
||||
|
||||
/** @param list<array{label:string,wkt:string,srid:int|null}> $data */
|
||||
#[DataProvider('providerTestGisData')]
|
||||
public function testPdf(string $name, array $data): void
|
||||
{
|
||||
$visualization = GisVisualization::getByData(
|
||||
$data,
|
||||
new GisVisualizationSettings(width: 560, height: 420, spatialColumn: 'wkt', labelColumn: 'label'),
|
||||
);
|
||||
$vis = new ReflectionClass($visualization);
|
||||
/** @var TCPDF $pdf */
|
||||
$pdf = $vis->getMethod('createEmptyPdf')->invoke($visualization, 'A4');
|
||||
$pdf->setDocCreationTimestamp(1700000000);
|
||||
$pdf->setDocModificationTimestamp(1700000000);
|
||||
$pdf->setCompression(false);
|
||||
(new ReflectionProperty($pdf, 'file_id'))->setValue($pdf, md5($name));
|
||||
|
||||
$vis->getMethod('prepareDataSet')->invoke($visualization, $data, 'pdf', $pdf);
|
||||
$pdfBlob = $pdf->Output(dest: 'S');
|
||||
|
||||
$this->assertSameOrSaveNewVersion($name, 'pdf', $pdfBlob);
|
||||
}
|
||||
|
||||
/** @param list<array{label:string,wkt:string,srid:int|null}> $data */
|
||||
#[RequiresPhpExtension('gd')]
|
||||
#[DataProvider('providerTestGisData')]
|
||||
public function testPng(string $name, array $data): void
|
||||
{
|
||||
$vis = GisVisualization::getByData(
|
||||
$data,
|
||||
new GisVisualizationSettings(width: 200, height: 150, spatialColumn: 'wkt', labelColumn: 'label'),
|
||||
);
|
||||
/** @var ImageWrapper $image */
|
||||
$image = (new ReflectionMethod($vis, 'png'))->invoke($vis);
|
||||
ob_start();
|
||||
$image->png(null, 9, PNG_ALL_FILTERS);
|
||||
$blob = ob_get_clean();
|
||||
assert($blob !== false);
|
||||
|
||||
$this->assertSameOrSaveNewVersion($name, 'png', $blob);
|
||||
}
|
||||
|
||||
private function assertSameOrSaveNewVersion(string $name, string $extension, string $content): void
|
||||
{
|
||||
$name = strtolower($name);
|
||||
$fileExpectedArch = self::$testDataDir . '/' . $name . '-expected-' . $this->getArch() . '.' . $extension;
|
||||
$fileExpectedGeneric = self::$testDataDir . '/' . $name . '-expected.' . $extension;
|
||||
$fileExpected = file_exists($fileExpectedArch) ? $fileExpectedArch : $fileExpectedGeneric;
|
||||
try {
|
||||
self::assertStringEqualsFile($fileExpected, $content);
|
||||
} catch (Throwable $e) {
|
||||
$pos = strrpos($fileExpected, 'expected');
|
||||
assert($pos !== false);
|
||||
file_put_contents(substr_replace($fileExpected, 'actual', $pos, 8), $content);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||