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nWl6qD|/uAo^Y X"{q[ZY'	+- w38њZG>*PXzm4%-5Y=iR/K*m	SmM'a׋B=BW0ܬWW[-]oR+yf:xB/#@|C_k;-w7U
I3kf4yL5RŖxniČµZaѤ~8*FQuq=}vfȩ("keUSEoXnj_
fPInSj?' Sp2bOJlÿ3bgA *!?)H1O
Nw}zjNi3L`EN.CK#|xbb|-$agN?@ It(?#0߃j8^'SHz+nObq	ڠ%%U!s^EW8ˮ5[͆q.xJ?.B_2fʚq8,_@DYėOy{%%G4#('mR&N\O#wU>/(S{.+DXeǁڨwŘZ]2`XV#u	_Zod𛋈frSeӲ-0(7l[`y^n$'hOg]dF2]w#WJ5l*;6?SԶ,J"*֯0;cs7慹oHCkP5~$|2ʯ2h3Nᾣ1#Ɏz9}1F;yny@mHHAnSj?'^\mܤ-O;wLBcC񩨘@[1s(H&^3Nᾣ1#Ɏz %hdY?:Zν
9v.O;#.
WA19 .iqm@/;"SԱ_A4❑gn#8s	sQ~LyʾC&;o	=uTyAU7Uw滵m\>F⼑H.$f61]SVL޼$xq?.>K>]0%vbGdinA+2m`^X\#/ֹ3w	k	s2ir<Xv0ߞWٿܤ,*vյ$a<@\@|
-guZ& odҦr!/7gf[
	fD#E{ o`<[vYS+c6-)RZ{8<.]v-X;z*4Fa:)֦m)w`Mx\J*ʦG{?X3cSބԅz9_b]j/v ygi/@G:kD<K0N7 TL%)sSOZ+{9m~RX*[o;d写|ozg=Bww*e.Ϲ_(~嵻cv6FJqt(P@X9tlW˾QlDǭZq-|I~ı/Kʫ".#C}yoTfRz&̛nQDϋQN#py7z)Y̡^!s*``v_v0W3S[JזV6x-$blue = hexdec(mb_substr($point_color, 4, 2));
        $line = array('width' => 1.25, 'color' => array($red, $green, $blue));

        // Trim to remove leading 'POINT(' and trailing ')'
        $point
            = mb_substr(
                $spatial,
                6,
                mb_strlen($spatial) - 7
            );
        $points_arr = $this->extractPoints($point, $scale_data);

        // draw a small circle to mark the point
        if ($points_arr[0][0] != '' && $points_arr[0][1] != '') {
            $pdf->Circle(
                $points_arr[0][0],
                $points_arr[0][1],
                2,
                0,
                360,
                'D',
                $line
            );
            // print label if applicable
            if (isset($label) && trim($label) != '') {
                $pdf->SetXY($points_arr[0][0], $points_arr[0][1]);
                $pdf->SetFontSize(5);
                $pdf->Cell(0, 0, trim($label));
            }
        }

        return $pdf;
    }

    /**
     * Prepares and returns the code related to a row in the GIS dataset as SVG.
     *
     * @param string $spatial     GIS POINT object
     * @param string $label       Label for the GIS POINT object
     * @param string $point_color Color for the GIS POINT object
     * @param array  $scale_data  Array containing data related to scaling
     *
     * @return string the code related to a row in the GIS dataset
     * @access public
     */
    public function prepareRowAsSvg($spatial, $label, $point_color, $scale_data)
    {
        $point_options = array(
            'name'         => $label,
            'id'           => $label . rand(),
            'class'        => 'point vector',
            'fill'         => 'white',
            'stroke'       => $point_color,
            'stroke-width' => 2,
        );

        // Trim to remove leading 'POINT(' and trailing ')'
        $point
            = mb_substr(
                $spatial,
                6,
                mb_strlen($spatial) - 7
            );
        $points_arr = $this->extractPoints($point, $scale_data);

        $row = '';
        if ($points_arr[0][0] != '' && $points_arr[0][1] != '') {
            $row .= '<circle cx="' . $points_arr[0][0]
                . '" cy="' . $points_arr[0][1] . '" r="3"';
            foreach ($point_options as $option => $val) {
                $row .= ' ' . $option . '="' . trim($val) . '"';
            }
            $row .= '/>';
        }

        return $row;
    }

    /**
     * Prepares JavaScript related to a row in the GIS dataset
     * to visualize it with OpenLayers.
     *
     * @param string $spatial     GIS POINT object
     * @param int    $srid        Spatial reference ID
     * @param string $label       Label for the GIS POINT object
     * @param string $point_color Color for the GIS POINT object
     * @param array  $scale_data  Array containing data related to scaling
     *
     * @return string JavaScript related to a row in the GIS dataset
     * @access public
     */
    public function prepareRowAsOl(
        $spatial,
        $srid,
        $label,
        $point_color,
        $scale_data
    ) {
        $style_options = array(
            'pointRadius'  => 3,
            'fillColor'    => '#ffffff',
            'strokeColor'  => $point_color,
            'strokeWidth'  => 2,
            'label'        => $label,
            'labelYOffset' => -8,
            'fontSize'     => 10,
        );
        if ($srid == 0) {
            $srid = 4326;
        }
        $result = $this->getBoundsForOl($srid, $scale_data);

        // Trim to remove leading 'POINT(' and trailing ')'
        $point
            = mb_substr(
                $spatial,
                6,
                mb_strlen($spatial) - 7
            );
        $points_arr = $this->extractPoints($point, null);

        if ($points_arr[0][0] != '' && $points_arr[0][1] != '') {
            $result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
                . $this->getPointForOpenLayers($points_arr[0], $srid) . ', null, '
                . json_encode($style_options) . '));';
        }

        return $result;
    }

    /**
     * Generate the WKT with the set of parameters passed by the GIS editor.
     *
     * @param array  $gis_data GIS data
     * @param int    $index    Index into the parameter object
     * @param string $empty    Point does not adhere to this parameter
     *
     * @return string WKT with the set of parameters passed by the GIS editor
     * @access public
     */
    public function generateWkt($gis_data, $index, $empty = '')
    {
        return 'POINT('
        . ((isset($gis_data[$index]['POINT']['x'])
            && trim($gis_data[$index]['POINT']['x']) != '')
            ? $gis_data[$index]['POINT']['x'] : '')
        . ' '
        . ((isset($gis_data[$index]['POINT']['y'])
            && trim($gis_data[$index]['POINT']['y']) != '')
            ? $gis_data[$index]['POINT']['y'] : '') . ')';
    }

    /**
     * Generate the WKT for the data from ESRI shape files.
     *
     * @param array $row_data GIS data
     *
     * @return string the WKT for the data from ESRI shape files
     * @access public
     */
    public function getShape($row_data)
    {
        return 'POINT(' . (isset($row_data['x']) ? $row_data['x'] : '')
        . ' ' . (isset($row_data['y']) ? $row_data['y'] : '') . ')';
    }

    /**
     * Generate parameters for the GIS data editor from the value of the GIS column.
     *
     * @param string $value of the GIS column
     * @param int    $index of the geometry
     *
     * @return array params for the GIS data editor from the value of the GIS column
     * @access public
     */
    public function generateParams($value, $index = -1)
    {
        $params = array();
        if ($index == -1) {
            $index = 0;
            $data = GISGeometry::generateParams($value);
            $params['srid'] = $data['srid'];
            $wkt = $data['wkt'];
        } else {
            $params[$index]['gis_type'] = 'POINT';
            $wkt = $value;
        }

        // Trim to remove leading 'POINT(' and trailing ')'
        $point
            = mb_substr(
                $wkt,
                6,
                mb_strlen($wkt) - 7
            );
        $points_arr = $this->extractPoints($point, null);

        $params[$index]['POINT']['x'] = $points_arr[0][0];
        $params[$index]['POINT']['y'] = $points_arr[0][1];

        return $params;
    }
}
