Skip to content

Commit

Permalink
Access random id from Abstract GisGeometry
Browse files Browse the repository at this point in the history
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed May 28, 2020
1 parent 58eee2e commit 1d1f018
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
6 changes: 6 additions & 0 deletions libraries/classes/Gis/GisGeometry.php
Expand Up @@ -14,6 +14,7 @@
use function mb_strlen;
use function mb_strripos;
use function mb_substr;
use function mt_rand;
use function preg_match;
use function str_replace;
use function trim;
Expand Down Expand Up @@ -421,4 +422,9 @@ protected function getPointForOpenLayers(array $point, $srid)
. '.transform(new OpenLayers.Projection("EPSG:'
. intval($srid) . '"), map.getProjectionObject())';
}

protected function getRandomId(): int
{
return mt_rand();
}
}
3 changes: 1 addition & 2 deletions libraries/classes/Gis/GisLineString.php
Expand Up @@ -16,7 +16,6 @@
use function json_encode;
use function mb_strlen;
use function mb_substr;
use function mt_rand;
use function trim;

/**
Expand Down Expand Up @@ -219,7 +218,7 @@ public function prepareRowAsSvg($spatial, $label, $line_color, array $scale_data
{
$line_options = [
'name' => $label,
'id' => $label . mt_rand(),
'id' => $label . $this->getRandomId(),
'class' => 'linestring vector',
'fill' => 'none',
'stroke' => $line_color,
Expand Down
3 changes: 1 addition & 2 deletions libraries/classes/Gis/GisMultiLineString.php
Expand Up @@ -17,7 +17,6 @@
use function json_encode;
use function mb_strlen;
use function mb_substr;
use function mt_rand;
use function trim;

/**
Expand Down Expand Up @@ -267,7 +266,7 @@ public function prepareRowAsSvg($spatial, $label, $line_color, array $scale_data
$row .= $point[0] . ',' . $point[1] . ' ';
}
$row .= '"';
$line_options['id'] = $label . mt_rand();
$line_options['id'] = $label . $this->getRandomId();
foreach ($line_options as $option => $val) {
$row .= ' ' . $option . '="' . trim((string) $val) . '"';
}
Expand Down
3 changes: 1 addition & 2 deletions libraries/classes/Gis/GisMultiPoint.php
Expand Up @@ -16,7 +16,6 @@
use function json_encode;
use function mb_strlen;
use function mb_substr;
use function mt_rand;
use function trim;

/**
Expand Down Expand Up @@ -236,7 +235,7 @@ public function prepareRowAsSvg($spatial, $label, $point_color, array $scale_dat

$row .= '<circle cx="' . $point[0] . '" cy="'
. $point[1] . '" r="3"';
$point_options['id'] = $label . mt_rand();
$point_options['id'] = $label . $this->getRandomId();
foreach ($point_options as $option => $val) {
$row .= ' ' . $option . '="' . trim((string) $val) . '"';
}
Expand Down
3 changes: 1 addition & 2 deletions libraries/classes/Gis/GisMultiPolygon.php
Expand Up @@ -20,7 +20,6 @@
use function mb_strlen;
use function mb_strpos;
use function mb_substr;
use function mt_rand;
use function trim;

/**
Expand Down Expand Up @@ -309,7 +308,7 @@ public function prepareRowAsSvg($spatial, $label, $fill_color, array $scale_data
$row .= $this->_drawPath($inner_poly, $scale_data);
}
}
$polygon_options['id'] = $label . mt_rand();
$polygon_options['id'] = $label . $this->getRandomId();
$row .= '"';
foreach ($polygon_options as $option => $val) {
$row .= ' ' . $option . '="' . trim((string) $val) . '"';
Expand Down
3 changes: 1 addition & 2 deletions libraries/classes/Gis/GisPoint.php
Expand Up @@ -15,7 +15,6 @@
use function json_encode;
use function mb_strlen;
use function mb_substr;
use function mt_rand;
use function trim;

/**
Expand Down Expand Up @@ -217,7 +216,7 @@ public function prepareRowAsSvg($spatial, $label, $point_color, array $scale_dat
{
$point_options = [
'name' => $label,
'id' => $label . mt_rand(),
'id' => $label . $this->getRandomId(),
'class' => 'point vector',
'fill' => 'white',
'stroke' => $point_color,
Expand Down
3 changes: 1 addition & 2 deletions libraries/classes/Gis/GisPolygon.php
Expand Up @@ -22,7 +22,6 @@
use function mb_strpos;
use function mb_substr;
use function min;
use function mt_rand;
use function pow;
use function sqrt;
use function trim;
Expand Down Expand Up @@ -239,7 +238,7 @@ public function prepareRowAsSvg($spatial, $label, $fill_color, array $scale_data
{
$polygon_options = [
'name' => $label,
'id' => $label . mt_rand(),
'id' => $label . $this->getRandomId(),
'class' => 'polygon vector',
'stroke' => 'black',
'stroke-width' => 0.5,
Expand Down

0 comments on commit 1d1f018

Please sign in to comment.