Converts coordinates from the 1903 Swiss national grid system to WGS-84.
964476
def ConvertCH1903(x, y):
  ""
  yb = (x - 600000.0) / 1e6;
  xb = (y - 200000.0) / 1e6;
  lam = 2.6779094 \
     + 4.728982 * yb \
     + 0.791484 * yb * xb \
     + 0.1306 * yb * xb * xb \
     - 0.0436 * yb * yb * yb
  phi = 16.9023892 \
     + 3.238372 * xb \
     - 0.270978 * yb * yb \
     - 0.002582 * xb * xb \
     - 0.0447 * yb * yb * xb \
     - 0.0140 * xb * xb * xb
  return (phi * 100.0 / 36.0, lam * 100.0 / 36.0)
1147316
function convertGeoPoints() {
                if (!{}.hasOwnProperty.call(this.schema.__meta, 'geoPointsProps')) {
                    return;
                }

                this.schema.__meta.geoPointsProps.forEach((property) => {
                    if ({}.hasOwnProperty.call(_this.entityData, property)
                        && _this.entityData[property] !== null
                        && _this.entityData[property].constructor.name !== 'GeoPoint') {
                        _this.entityData[property] = _this.gstore.ds.geoPoint(_this.entityData[property]);
                    }
                });
            }
1342620
def _convert_point(cls, feature):
        """"""
        lon, lat = feature['geometry']['coordinates']
        popup = feature['properties'].get('name', '')
        return cls(lat, lon)
154445
def convert_column(data, schemae):
    """"""
    ctype = schemae.converted_type
    if ctype == parquet_thrift.ConvertedType.DECIMAL:
        scale_factor = Decimal("10e-{}".format(schemae.scale))
        if schemae.type == parquet_thrift.Type.INT32 or schemae.type == parquet_thrift.Type.INT64:
            return [Decimal(unscaled) * scale_factor for unscaled in data]
        return [Decimal(intbig(unscaled)) * scale_factor for unscaled in data]
    elif ctype == parquet_thrift.ConvertedType.DATE:
        return [datetime.date.fromordinal(d) for d in data]
    elif ctype == parquet_thrift.ConvertedType.TIME_MILLIS:
        return [datetime.timedelta(milliseconds=d) for d in data]
    elif ctype == parquet_thrift.ConvertedType.TIMESTAMP_MILLIS:
        return [datetime.datetime.utcfromtimestamp(d / 1000.0) for d in data]
    elif ctype == parquet_thrift.ConvertedType.UTF8:
        return [codecs.decode(item, "utf-8") for item in data]
    elif ctype == parquet_thrift.ConvertedType.UINT_8:
        return _convert_unsigned(data, 'b')
    elif ctype == parquet_thrift.ConvertedType.UINT_16:
        return _convert_unsigned(data, 'h')
    elif ctype == parquet_thrift.ConvertedType.UINT_32:
        return _convert_unsigned(data, 'i')
    elif ctype == parquet_thrift.ConvertedType.UINT_64:
        return _convert_unsigned(data, 'q')
    elif ctype == parquet_thrift.ConvertedType.JSON:
        return [json.loads(s) for s in codecs.iterdecode(data, "utf-8")]
    elif ctype == parquet_thrift.ConvertedType.BSON and bson:
        return [bson.BSON(s).decode() for s in data]
    else:
        logger.info("Converted type '%s'' not handled",
                    parquet_thrift.ConvertedType._VALUES_TO_NAMES[ctype])  # pylint:disable=protected-access
    return data
146775
def convert_coordinates(self):
        
        coord_list_str = regex_coordinate.findall(self.reg_str) + regex_length.findall(self.reg_str)
        coord_list = []

        if self.region_type == 'poly':
            if len(coord_list_str) < 4:
                self._raise_error('Not in proper format: {} polygon should have > 4 coordinates'.format(self.reg_str))
            if coord_list_str[0] != coord_list_str[-1]:
                self._raise_error("Not in proper format: '{0}', "
                                  "In polygon, the last and first coordinates should be same".format(self.reg_str))
        else:
            if len(coord_list_str) != len(self.language_spec[self.region_type]):
                self._raise_error("Not in proper format: '{0}', "
                                  "Does not contain expected number of parameters for the region '{1}'"
                                  .format(self.reg_str, self.region_type))

        for attr_spec, val_str in zip(self.language_spec[self.region_type], coord_list_str):

            if attr_spec == 'c':
                if len(val_str) == 2 and val_str[1] != '':
                    coord_list.append(CoordinateParser.parse_coordinate(val_str[0]))
                    coord_list.append(CoordinateParser.parse_coordinate(val_str[1]))
                else:
                    self._raise_error("Not in proper format: {0} should be a coordinate".format(val_str))
            if attr_spec == 'pl':
                if len(val_str) == 2 and val_str[1] != '':
                    coord_list.append(CoordinateParser.parse_angular_length_quantity(val_str[0]))
                    coord_list.append(CoordinateParser.parse_angular_length_quantity(val_str[1]))
                else:
                    self._raise_error("Not in proper format: {0} should be a pair of length".format(val_str))
            if attr_spec == 'l':
                if isinstance(val_str, six.string_types):
                    coord_list.append(CoordinateParser.parse_angular_length_quantity(val_str))
                else:
                    self._raise_error("Not in proper format: {0} should be a single length".format(val_str))
            if attr_spec == 's':
                if self.region_type == 'symbol':
                    if val_str in valid_symbols:
                        self.meta['symbol'] = val_str
                    else:
                        self._raise_error("Not in proper format: '{0}' should be a symbol".format(val_str))
                elif self.region_type == 'text':
                    self.meta['text'] = val_str[1:-1]

        self.coord = coord_list
653833
def to_ts(s):
        

        # Strip TZ portion if present
        m = Nginx.DATE_FMT.match(s)
        if m:
            s = m.group(1)
            delta = timedelta(seconds=int(m.group(3)) * (-1 if m.group(2) == '-' else 1)) # Offset from GMT
        else:
            delta = timedelta(seconds=0)
        dt = datetime.strptime(s, "%d/%b/%Y:%H:%M:%S")
        dt += delta
        return dt.strftime('%Y-%m-%dT%H:%M:%SZ')
586925
public static com.vividsolutions.jts.geom.Coordinate toJts(org.geomajas.geometry.Coordinate coordinate)
			throws JtsConversionException {
		if (coordinate == null) {
			throw new  JtsConversionException("Cannot convert null argument");
		}
		return new com.vividsolutions.jts.geom.Coordinate(coordinate.getX(), coordinate.getY());
	}
1308965
public static Geometry fromJts(com.vividsolutions.jts.geom.Geometry geometry) throws JtsConversionException {
		if (geometry == null) {
			throw new  JtsConversionException("Cannot convert null argument");
		}
		int srid = geometry.getSRID();
		int precision = -1;
		PrecisionModel precisionmodel = geometry.getPrecisionModel();
		if (!precisionmodel.isFloating()) {
			precision = (int) Math.log10(precisionmodel.getScale());
		}
		String geometryType = getGeometryType(geometry);
		Geometry dto = new Geometry(geometryType, srid, precision);
		if (geometry.isEmpty()) {
			// nothing to do
		} else if (geometry instanceof Point) {
			dto.setCoordinates(convertCoordinates(geometry));
		} else if (geometry instanceof LinearRing) {
			dto.setCoordinates(convertCoordinates(geometry));
		} else if (geometry instanceof LineString) {
			dto.setCoordinates(convertCoordinates(geometry));
		} else if (geometry instanceof Polygon) {
			Polygon polygon = (Polygon) geometry;
			Geometry[] geometries = new Geometry[polygon.getNumInteriorRing() + 1];
			for (int i = 0; i < geometries.length; i++) {
				if (i == 0) {
					geometries[i] = fromJts(polygon.getExteriorRing());
				} else {
					geometries[i] = fromJts(polygon.getInteriorRingN(i - 1));
				}
			}
			dto.setGeometries(geometries);
		} else if (geometry instanceof MultiPoint) {
			dto.setGeometries(convertGeometries(geometry));
		} else if (geometry instanceof MultiLineString) {
			dto.setGeometries(convertGeometries(geometry));
		} else if (geometry instanceof MultiPolygon) {
			dto.setGeometries(convertGeometries(geometry));
		} else {
			throw new JtsConversionException("Cannot convert geometry: Unsupported type.");
		}
		return dto;
	}
980221
def to_si(self, values, from_unit):
        """"""
        if from_unit in self.si_units:
            return values, from_unit
        elif from_unit == 'ton':
            return self.to_unit(values, 'tonne', from_unit), 'tonne'
        else:
            return self.to_unit(values, 'kg', from_unit), 'kg'
1087359
def convertWCS(inwcs,drizwcs):
    
    drizwcs[0] = inwcs.crpix[0]
    drizwcs[1] = inwcs.crval[0]
    drizwcs[2] = inwcs.crpix[1]
    drizwcs[3] = inwcs.crval[1]
    drizwcs[4] = inwcs.cd[0][0]
    drizwcs[5] = inwcs.cd[1][0]
    drizwcs[6] = inwcs.cd[0][1]
    drizwcs[7] = inwcs.cd[1][1]

    return drizwcs
646702
@Pure
	public static GeodesicPosition EL2_WSG84(double x, double y) {
		final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
				LAMBERT_2E_N,
				LAMBERT_2E_C,
				LAMBERT_2E_XS,
				LAMBERT_2E_YS);
		return NTFLambdaPhi_WSG84(ntfLambdaPhi.getX(), ntfLambdaPhi.getY());
	}
265536
public function geocentric_to_wgs84(Point $p)
    {
        Proj4php::reportDebug(sprintf(
            "geocentric_to_wgs84(%s,%s)\n",
            $p->x,
            $p->y
        ));

        if ($this->datum_type == Common::PJD_3PARAM) {
            Proj4php::reportDebug("+x=".$this->datum_params[0]."\n");
            Proj4php::reportDebug("+y=".$this->datum_params[1]."\n");
            Proj4php::reportDebug("+z=".$this->datum_params[2]."\n");
            $p->x += $this->datum_params[0];
            $p->y += $this->datum_params[1];
            $p->z += $this->datum_params[2];
        } elseif ($this->datum_type == Common::PJD_7PARAM) {
            Proj4php::reportDebug("Dx=".$this->datum_params[0]."\n");
            Proj4php::reportDebug("Dy=".$this->datum_params[1]."\n");
            Proj4php::reportDebug("Dz=".$this->datum_params[2]."\n");
            Proj4php::reportDebug("Rx=".$this->datum_params[3]."\n");
            Proj4php::reportDebug("Ry=".$this->datum_params[4]."\n");
            Proj4php::reportDebug("Rz=".$this->datum_params[5]."\n");
            Proj4php::reportDebug("M=".$this->datum_params[6]."\n"); 
            $Dx_BF = $this->datum_params[0];
            $Dy_BF = $this->datum_params[1];
            $Dz_BF = $this->datum_params[2];
            $Rx_BF = $this->datum_params[3];
            $Ry_BF = $this->datum_params[4];
            $Rz_BF = $this->datum_params[5];
            $M_BF = $this->datum_params[6];

            $p->x = $M_BF * ($p->x - $Rz_BF * $p->y + $Ry_BF * $p->z) + $Dx_BF;
            $p->y = $M_BF * ($Rz_BF * $p->x + $p->y - $Rx_BF * $p->z) + $Dy_BF;
            $p->z = $M_BF * (-$Ry_BF * $p->x + $Rx_BF * $p->y + $p->z) + $Dz_BF;
        }
    }
137615
def upsample_geolocation(self, dsid, info):
        """"""
        from geotiepoints import SatelliteInterpolator
        # Read the fields needed:
        col_indices = self.nc['nx_reduced'].values
        row_indices = self.nc['ny_reduced'].values
        lat_reduced = self.scale_dataset(dsid, self.nc['lat_reduced'], info)
        lon_reduced = self.scale_dataset(dsid, self.nc['lon_reduced'], info)

        shape = (self.nc['y'].shape[0], self.nc['x'].shape[0])
        cols_full = np.arange(shape[1])
        rows_full = np.arange(shape[0])

        satint = SatelliteInterpolator((lon_reduced.values, lat_reduced.values),
                                       (row_indices,
                                        col_indices),
                                       (rows_full, cols_full))

        lons, lats = satint.interpolate()
        self.cache['lon'] = xr.DataArray(lons, attrs=lon_reduced.attrs, dims=['y', 'x'])
        self.cache['lat'] = xr.DataArray(lats, attrs=lat_reduced.attrs, dims=['y', 'x'])

        return
1153047
def wwln_to_geopandas(file):
    """"""
    tmp = pd.read_csv(file, parse_dates=True, header=None,
                      names=['date', 'time', 'lat', 'lon', 'err', '#sta'])
    list_dts = [gen_datetime(dvals, tvals)
                for dvals, tvals in zip(tmp['date'], tmp['time'])]
    points = [[Point(tmp.lat[row], tmp.lon[row]), dt]
              for row, dt in zip(tmp.index, list_dts)]
    df = gpd.GeoDataFrame(points, columns=['geometry', 'dt'])
    return df
994901
public GridGeometry2D getGridGeometry( CoordinateReferenceSystem crs ) {
        GridGeometry2D gridGeometry = CoverageUtilities.gridGeometryFromRegionParams(getRegionParams(), crs);
        return gridGeometry;
    }
1152488
def to_(self, data_pts):
        """"""
        data_pts = np.asarray(data_pts, dtype=np.float)
        has_z = (data_pts.shape[-1] > 2)

        if self.use_center:
            data_pts = data_pts - self.viewer.data_off

        # subtract data indexes at center reference pixel
        ref_pt = [self.viewer._org_x, self.viewer._org_y]
        if has_z:
            ref_pt.append(self.viewer._org_z)

        off_pts = np.subtract(data_pts, ref_pt)
        return off_pts
575946
@Pure
	public static GeodesicPosition L4_WSG84(double x, double y) {
		final Point2d ntfLambdaPhi = NTFLambert_NTFLambdaPhi(x, y,
				LAMBERT_4_N,
				LAMBERT_4_C,
				LAMBERT_4_XS,
				LAMBERT_4_YS);
		return NTFLambdaPhi_WSG84(ntfLambdaPhi.getX(), ntfLambdaPhi.getY());
	}