C:\xampp\phpMyAdmin\vendor\phpmyadmin\shapefile\src\Util.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/**
 * phpMyAdmin ShapeFile library
 * <https://github.com/phpmyadmin/shapefile/>.
 *
 * Copyright 2006-2007 Ovidio <ovidio AT users.sourceforge.net>
 * Copyright 2016 - 2017 Michal Čihař <michal@cihar.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, you can download one from
 * https://www.gnu.org/copyleft/gpl.html.
 */

namespace PhpMyAdmin\ShapeFile;

class 
Util
{
    private static 
$little_endian null;

    private static 
$shape_names = array(
        
=> 'Null Shape',
        
=> 'Point',
        
=> 'PolyLine',
        
=> 'Polygon',
        
=> 'MultiPoint',
        
11 => 'PointZ',
        
13 => 'PolyLineZ',
        
15 => 'PolygonZ',
        
18 => 'MultiPointZ',
        
21 => 'PointM',
        
23 => 'PolyLineM',
        
25 => 'PolygonM',
        
28 => 'MultiPointM',
        
31 => 'MultiPatch',
    );

    
/**
     * Reads data.
     *
     * @param string $type type for unpack()
     * @param string $data Data to process
     *
     * @return mixed
     */
    
public static function loadData($type$data)
    {
        if (
$data === false || strlen($data) == 0) {
            return 
false;
        }
        
$tmp unpack($type$data);

        return 
current($tmp);
    }

    
/**
     * Changes endianity.
     *
     * @param string $binValue Binary value
     *
     * @return string
     */
    
public static function swap($binValue)
    {
        
$result $binValue[strlen($binValue) - 1];
        for (
$i strlen($binValue) - 2$i >= 0; --$i) {
            
$result .= $binValue[$i];
        }

        return 
$result;
    }

    
/**
     * Encodes double value to correct endianity.
     *
     * @param float $value Value to pack
     *
     * @return string
     */
    
public static function packDouble($value)
    {
        
$bin pack('d', (float) $value);

        if (
is_null(self::$little_endian)) {
            
self::$little_endian = (pack('L'1) == pack('V'1));
        }

        if (
self::$little_endian) {
            return 
$bin;
        }

        return 
self::swap($bin);
    }

    
/**
     * Returns shape name.
     *
     * @param int $type
     *
     * @return string
     */
    
public static function nameShape($type)
    {
        if (isset(
self::$shape_names[$type])) {
            return 
self::$shape_names[$type];
        }

        return 
sprintf('Shape %d'$type);
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586