Parses a geosgeometry string into struct.

    Example:
        SRID=5432;POINT(12.0 13.0)
    Returns:
        >> [5432, 12.0, 13.0]
198491
def geosgeometry_str_to_struct(value):
    '''
    
    '''

    result = geos_ptrn.match(value)

    if not result:
        return None

    return {
        'srid': result.group(1),
        'x': result.group(2),
        'y': result.group(3),
    }
741926
def parse_struct(path_dir):
        
        with open(os.path.join(path_dir, "boltztrap.struct"), 'r') as f:
            tokens = f.readlines()
            return Lattice([[Length(float(tokens[i].split()[j]), "bohr").
                           to("ang") for j in range(3)] for i in
                            range(1, 4)]).volume
379297
def postgis_type(self):
        
        dimz = "Z" if self.dimz else ""
        dimm = "M" if self.dimm else ""
        if self.srid:
            return "geometry({}{}{},{})".format(self.type, dimz, dimm, self.srid)
        else:
            return "geometry({}{}{})".format(self.type, dimz, dimm)
29432
def parse_coordinates(self, coords_str):
        
        if coords_str.strip() == '':
            return (None, None)
        ra = '%s:%s:%s' % (coords_str[0:2], coords_str[2:4], coords_str[4:8])
        dec = '%s:%s:%s' % (coords_str[8:11], coords_str[11:13], coords_str[13:15])
        return (ra, dec)
849675
public static Geometry toGeometry(byte[] bytes, int srid) throws SQLException{
        if(bytes==null) {
            return null;
        }
        WKBReader wkbReader = new WKBReader();
        try {
            Geometry geometry = wkbReader.read(bytes);
            geometry.setSRID(srid);
            return geometry;
        } catch (ParseException ex) {
            throw new SQLException("Cannot parse the input bytes",ex);
        }
    }
377588
def dmstodd(self, dms):
        
        size = len(dms)
        letters = 'WENS'
        is_annotated = False

        try:
            float(dms)
        except ValueError:
            for letter in letters:
                if letter in dms.upper():
                    is_annotated = True
                    break
            if not is_annotated:
                raise core.RTreeError("unable to parse '%s' to decimal degrees" % dms)
        is_negative = False
        if is_annotated:
            dms_upper = dms.upper()
            if 'W' in dms_upper or 'S' in dms_upper:
                is_negative = True
        else:
            if dms < 0:
                is_negative = True

        if is_annotated:
            bletters = letters.encode(encoding='utf-8')
            bdms = dms.encode(encoding = 'utf-8')
            dms = bdms.translate(None, bletters).decode('ascii')

            # bletters = bytes(letters, encoding='utf-8')
            # bdms = bytes(dms, encoding='utf-8')
            # dms = bdms.translate(None, bletters).decode('ascii')

            # dms = dms.translate(None, letters) # Python 2.x version

        pieces = dms.split(".")
        D = 0.0
        M = 0.0
        S = 0.0
        divisor = 3600.0
        if len(pieces) == 1:
            S = dms[-2:]
            M = dms[-4:-2]
            D = dms[:-4]
        else:
            S = '{0:s}.{1:s}'.format (pieces[0][-2:], pieces[1])
            M = pieces[0][-4:-2]
            D = pieces[0][:-4]

        DD = float(D) + float(M)/60.0 + float(S)/divisor
        if is_negative:
            DD = DD * -1.0
        return DD
1293156
def get_type(data):
    
    import six
    from ..datageometry import DataGeometry

    if isinstance(data, list):
        if isinstance(data[0], (six.string_types, six.text_type, six.binary_type)):
            return 'list_str'
        elif isinstance(data[0], (int, float)):
            return 'list_num'
        elif isinstance(data[0], np.ndarray):
            return 'list_arr'
        else:
            raise TypeError('Unsupported data type passed. Supported types: '
                            'Numpy Array, Pandas DataFrame, String, List of strings'
                            ', List of numbers')
    elif isinstance(data, np.ndarray):
        if isinstance(data[0][0], (six.string_types, six.text_type, six.binary_type)):
            return 'arr_str'
        else:
            return 'arr_num'
    elif isinstance(data, pd.DataFrame):
        return 'df'
    elif isinstance(data, (six.string_types, six.text_type, six.binary_type)):
        return 'str'
    elif isinstance(data, DataGeometry):
        return 'geo'
    else:
        raise TypeError('Unsupported data type passed. Supported types: '
                        'Numpy Array, Pandas DataFrame, String, List of strings'
                        ', List of numbers')
1108551
def parse(cls, string):
        
        match = re.match(r'^(?P<name>[A-Za-z0-9\.\-_]+)\s+' +
                         '(?P<value>[0-9\.]+)\s+' +
                         '(?P<timestamp>[0-9\.]+)(\n?)$',
                         string)
        try:
            groups = match.groupdict()
            # TODO: get precision from value string
            return Metric(groups['name'],
                          groups['value'],
                          float(groups['timestamp']))
        except:
            raise DiamondException(
                "Metric could not be parsed from string: %s." % string)
1261855
def decode(value):
  """"""
  assert value, "Invalid geohash: %s"%value
  # Get the GeoHash bits
  bits = _geohash_to_bits(value)
  # Unzip the GeoHash bits.
  lon = bits[0::2]
  lat = bits[1::2]
  # Convert to lat/lon
  return (
    _bits_to_float(lon, lower=-180.0, upper=180.0),
    _bits_to_float(lat)
  )
1115074
private Point parsePoint(String point) {
    int comma = point.indexOf(',');
    if (comma == -1)
      return null;

    float lat = Float.valueOf(point.substring(0, comma));
    float lng = Float.valueOf(point.substring(comma + 1));
    return spatialctx.makePoint(lng, lat);
  }
1244757
def parse_to_gvid(v):
    """"""
    from geoid.civick import GVid
    from geoid.acs import AcsGeoid

    m1 = ''

    try:
        return GVid.parse(v)
    except ValueError as e:
        m1 = str(e)

    try:
        return AcsGeoid.parse(v).convert(GVid)
    except ValueError as e:
        raise ValueError("Failed to parse to either ACS or GVid: {}; {}".format(m1, str(e)))
864242
public static Geometry toGeometry(String gmlFile, int srid) throws SAXException, IOException, ParserConfigurationException {
        if (gmlFile == null) {
            return null;
        }
        if (gf == null) {
            gf = new GeometryFactory(new PrecisionModel(), srid);
        }
        GMLReader gMLReader = new GMLReader();
        return gMLReader.read(gmlFile, gf);
    }
1156295
function parsePolygonGeometry(coordinates) {
		var polygonWkt = [];
		for (var i = 0; i < coordinates.length; i++) {
			polygonWkt.push('(' + parseLineGeometry(coordinates[i]) + ')');
		}
		return polygonWkt.join(', ');
	}
1008723
def structparser(token):
    """"""
    m = STRUCT_PACK_RE.match(token)
    if not m:
        return [token]
    else:
        endian = m.group('endian')
        if endian is None:
            return [token]
        # Split the format string into a list of 'q', '4h' etc.
        formatlist = re.findall(STRUCT_SPLIT_RE, m.group('fmt'))
        # Now deal with mulitiplicative factors, 4h -> hhhh etc.
        fmt = ''.join([f[-1] * int(f[:-1]) if len(f) != 1 else
                       f for f in formatlist])
        if endian == '@':
            # Native endianness
            if byteorder == 'little':
                endian = '<'
            else:
                assert byteorder == 'big'
                endian = '>'
        if endian == '<':
            tokens = [REPLACEMENTS_LE[c] for c in fmt]
        else:
            assert endian == '>'
            tokens = [REPLACEMENTS_BE[c] for c in fmt]
    return tokens
80027
def parse(text):
    ''''''
    if '@' in text:
        spatial, validity = text.split('@')
    else:
        spatial = text
        validity = 'latest'
    if ':' not in spatial:
        raise GeoIDError('Bad GeoID format: {0}'.format(text))
    # country-subset is a special case:
    if spatial.startswith('country-subset:'):
        level, code = spatial.split(':', 1)
    else:
        level, code = spatial.rsplit(':', 1)
    return level, code, validity
648943
def parse_from
      s0 = @current_pos
      s1 = match_str("打")
      if s1 != :failed
        @reported_pos = s0
        s1 = nil
      end
      s0 = s1
      if s0 == :failed
        s0 = @current_pos
        if match_str("(") != :failed
          s2 = match_regexp(/^[1-9]/)
          if s2 != :failed
            s3 = match_regexp(/^[1-9]/)
            if s3 != :failed
              if match_str(")") != :failed
                @reported_pos = s0
                s0 = { "x" => s2.to_i, "y" => s3.to_i }
              else
                @current_pos = s0
                s0 = :failed
              end
            else
              @current_pos = s0
              s0 = :failed
            end
          else
            @current_pos = s0
            s0 = :failed
          end
        else
          @current_pos = s0
          s0 = :failed
        end
      end
      s0
    end
1196034
def get_string(self, offset, length):
        
        return struct.unpack(str(length) + "s", self.data[
                                                offset:offset + length
                                                ])[0]