public function forward($p) { //alert("ll2m coords : ".coords); $lon = $p->x; $lat = $p->y; // Check ranges. Checks done in degrees, for clarity. if ($lat * Proj4Php::$common->R2D > 90.0 && $lat * Proj4Php::$common->R2D < -90.0 && $lon * Proj4Php::$common->R2D > 180.0 && $lon * Proj4Php::$common->R2D < -180.0) { Proj4Php::reportError("merc:forward: llInputOutOfRange: " . $lon . " : " . $lat); return null; } if (abs(abs($lat) - Proj4php::$common->HALF_PI) <= Proj4Php::$common->EPSLN) { Proj4php::reportError("merc:forward: ll2mAtPoles"); return null; } else { if ($this->sphere) { $x = $this->x0 + $this->a * $this->k0 * Proj4Php::$common->adjust_lon($lon - $this->long0); $y = $this->y0 + $this->a * $this->k0 * log(tan(Proj4Php::$common->FORTPI + 0.5 * $lat)); } else { $sinphi = sin($lat); $ts = Proj4Php::$common . tsfnz($this->e, $lat, $sinphi); $x = $this->x0 + $this->a * $this->k0 * Proj4Php::$common->adjust_lon($lon - $this->long0); $y = $this->y0 - $this->a * $this->k0 * log($ts); } $p->x = $x; $p->y = $y; return $p; } }
public function forward($p) { /* Forward equations ----------------- */ $lon = $p->x; $lat = $p->y; $delta_lon = Proj4php::$common->adjust_lon($lon - $this->long0); $theta = $lat; $con = Proj4php::$common->PI * sin($lat); /* Iterate using the Newton-Raphson method to find theta ----------------------------------------------------- */ for ($i = 0; true; ++$i) { $delta_theta = -($theta + sin($theta) - $con) / (1.0 + cos($theta)); $theta += $delta_theta; if (abs($delta_theta) < Proj4php::$common->EPSLN) { break; } if ($i >= 50) { Proj4php::reportError("moll:Fwd:IterationError"); //return(241); } } $theta /= 2.0; /* If the latitude is 90 deg, force the x coordinate to be "0 . false easting" this is done here because of precision problems with "cos(theta)" -------------------------------------------------------------------------- */ if (Proj4php::$common->PI / 2 - abs($lat) < Proj4php::$common->EPSLN) { $delta_lon = 0; } $x = 0.900316316158 * $this->a * $delta_lon * cos($theta) + $this->x0; $y = 1.4142135623731 * $this->a * sin($theta) + $this->y0; $p->x = $x; $p->y = $y; return $p; }
/** * * @param type $p * @return type */ public function inverse($p) { $Y = $p->x - $this->x0; $X = $p->y - $this->y0; $rotI = $Y / $this->R; $rotB = 2 * (atan(exp($X / $this->R)) - Proj4php::$common->PI / 4.0); $b = asin(cos($this->b0) * sin($rotB) + sin($this->b0) * cos($rotB) * cos($rotI)); $I = atan(sin($rotI) / (cos($this->b0) * cos($rotI) - sin($this->b0) * tan($rotB))); $lambda = $this->lambda0 + $I / $this->alpha; $S = 0.0; $phy = $b; $prevPhy = -1000.0; $iteration = 0; while (abs($phy - $prevPhy) > 1.0E-7) { if (++$iteration > 20) { Proj4php::reportError("omercFwdInfinity"); return; } //S = log(tan(PI / 4.0 + phy / 2.0)); $S = 1.0 / $this->alpha * (log(tan(Proj4php::$common->PI / 4.0 + $b / 2.0)) - $this->K) + $this->e * log(tan(Proj4php::$common->PI / 4.0 + asin($this->e * sin($phy)) / 2.0)); $prevPhy = $phy; $phy = 2.0 * atan(exp($S)) - Proj4php::$common->PI / 2.0; } $p->x = $lambda; $p->y = $phy; return $p; }
public function inverse($p) { $p->x -= $this->x0; $p->y -= $this->y0; $lat = $p->y / $this->a; if (abs($lat) > Proj4php::$common->HALF_PI) { Proj4php::reportError("equi:Inv:DataError"); } $lon = Proj4php::$common->adjust_lon($this->long0 + $p->x / ($this->a * cos($this->lat0))); $p->x = $lon; $p->y = $lat; }
/** * * @return void */ public function init() { if (!isset($this->zone)) { Proj4php::reportError("utm:init: zone must be specified for UTM"); return; } $this->lat0 = 0.0; $this->long0 = (6 * abs($this->zone) - 183) * Proj4php::$common->D2R; $this->x0 = 500000.0; $this->y0 = $this->utmSouth ? 10000000.0 : 0.0; $this->k0 = 0.9996; }
/** * * @return void */ public function init() { if (!$this->rc) { Proj4php::reportError("sterea:init:E_ERROR_0"); return; } $this->sinc0 = sin($this->phic0); $this->cosc0 = cos($this->phic0); $this->R2 = 2.0 * $this->rc; if (!$this->title) { $this->title = "Oblique Stereographic Alternative"; } }
public function forward($p) { $sinphi; $cosphi; /* sin and cos value */ $dlon; /* delta longitude value */ $coslon; /* cos of longitude */ $ksp; /* scale factor */ $g; $lon = $p->x; $lat = $p->y; /* Forward equations -----------------*/ $dlon = Proj4php::$common->adjust_lon($lon - $this->long0); $sinphi = sin($lat); $cosphi = cos($lat); $coslon = cos($dlon); $g = $this->sin_p14 * $sinphi + $this->cos_p14 * $cosphi * $coslon; $ksp = 1.0; if (g > 0 || abs(g) <= Proj4php::$common->EPSLN) { $x = $this->x0 + $this->a * $ksp * $cosphi * sin($dlon) / $g; $y = $this->y0 + $this->a * $ksp * ($this->cos_p14 * $sinphi - $this->sin_p14 * $cosphi * $coslon) / $g; } else { Proj4php::reportError("orthoFwdPointError"); // Point is in the opposing hemisphere and is unprojectable // We still need to return a reasonable point, so we project // to infinity, on a bearing // equivalent to the northern hemisphere equivalent // This is a reasonable approximation for short shapes and lines that // straddle the horizon. $x = $this->x0 + $this->infinity_dist * $cosphi * sin($dlon); $y = $this->y0 + $this->infinity_dist * ($this->cos_p14 * $sinphi - $this->sin_p14 * $cosphi * $coslon); } $p->x = $x; $p->y = $y; return $p; }
/** * * @param type $p * @return null */ public function inverse($p) { $DEL_TOL = 1.0E-14; $lon = $p->x / $this->C; $lat = $p->y; $num = pow(tan(0.5 * $lat + Proj4php::$common->FORTPI) / $this->K, 1.0 / $this->C); for ($i = Proj4php::$common->MAX_ITER; $i > 0; --$i) { $lat = 2.0 * atan($num * Proj4php::$common->srat($this->e * sin($p->y), -0.5 * $this->e)) - Proj4php::$common->HALF_PI; if (abs($lat - $p->y) < $DEL_TOL) { break; } $p->y = $lat; } /* convergence failed */ if (!$i) { Proj4php::reportError("gauss:inverse:convergence failed"); return null; } $p->x = $lon; $p->y = $lat; return $p; }
public function inverse($p) { $p->x -= $this->x0; $p->y -= $this->y0; $rh = sqrt($p->x * $p->x + $p->y * $p->y); if ($rh > 2.0 * Proj4php::$common->HALF_PI * $this->a) { Proj4php::reportError("aeqdInvDataError"); return; } $z = $rh / $this->a; $sinz = sin($z); $cosz = cos($z); $lon = $this->long0; $lat; if (abs($rh) <= Proj4php::$common->EPSLN) { $lat = $this->lat0; } else { $lat = Proj4php::$common->asinz($cosz * $this->sin_p12 + $p->y * $sinz * $this->cos_p12 / $rh); $con = abs($this->lat0) - Proj4php::$common->HALF_PI; if (abs($con) <= Proj4php::$common->EPSLN) { if ($lat0 >= 0.0) { $lon = Proj4php::$common->adjust_lon($this->long0 + atan2($p->x, -$p->y)); } else { $lon = Proj4php::$common->adjust_lon($this->long0 - atan2(-$p->x, $p->y)); } } else { $con = $cosz - $this->sin_p12 * sin($lat); if (abs($con) < Proj4php::$common->EPSLN && abs($p->x) < Proj4php::$common->EPSLN) { //no-op, just keep the lon value as is } else { $temp = atan2($p->x * $sinz * $this->cos_p12, $con * $rh); $lon = Proj4php::$common->adjust_lon($this->long0 + atan2($p->x * $sinz * $this->cos_p12, $con * $rh)); } } } $p->x = $lon; $p->y = $lat; return $p; }
function phi4z($eccent, $e0, $e1, $e2, $e3, $a, $b, &$c, $phi) { /* $sinphi; $sin2ph; $tanph; $ml; $mlp; $con1; $con2; $con3; $dphi; $i; */ $phi = $a; for ($i = 1; $i <= 15; $i++) { $sinphi = sin($phi); $tanphi = tan($phi); $c = $tanphi * sqrt(1.0 - $eccent * $sinphi * $sinphi); $sin2ph = sin(2.0 * $phi); /* ml = e0 * *phi - e1 * sin2ph + e2 * sin (4.0 * *phi); mlp = e0 - 2.0 * e1 * cos (2.0 * *phi) + 4.0 * e2 * cos (4.0 * *phi); */ $ml = $e0 * $phi - $e1 * $sin2ph + $e2 * sin(4.0 * $phi) - $e3 * sin(6.0 * $phi); $mlp = $e0 - 2.0 * $e1 * cos(2.0 * $phi) + 4.0 * $e2 * cos(4.0 * $phi) - 6.0 * $e3 * cos(6.0 * $phi); $con1 = 2.0 * $ml + $c * ($ml * $ml + $b) - 2.0 * $a * ($c * $ml + 1.0); $con2 = $eccent * $sin2ph * ($ml * $ml + $b - 2.0 * $a * $ml) / (2.0 * $c); $con3 = 2.0 * ($a - $ml) * ($c * $mlp - 2.0 / $sin2ph) - 2.0 * $mlp; $dphi = $con1 / ($con2 + $con3); $phi += $dphi; if (abs($dphi) <= 1.0E-10) { return $phi; } } Proj4php::reportError("phi4z: No convergence"); return null; }
public function inverse($p) { $lat; $temp; $lon; /* Inverse equations -----------------*/ $p->x -= $this->x0; $p->y -= $this->y0; $lat = $p->y / $this->R; if (abs($lat) > Proj4php::$common->HALF_PI) { Proj4php::reportError("sinu:Inv:DataError"); } $temp = abs($lat) - Proj4php::$common->HALF_PI; if (abs($temp) > Proj4php::$common->EPSLN) { $temp = $this->long0 + $p->x / ($this->R * cos($lat)); $lon = Proj4php::$common->adjust_lon($temp); } else { $lon = $this->long0; } $p->x = $lon; $p->y = $lat; return $p; }
/** * Function: deriveConstants * Sets several derived constant values and initialization of datum and ellipse parameters. * */ public function deriveConstants() { if (isset($this->nagrids) && $this->nagrids == '@null') { $this->datumCode = 'none'; } if (isset($this->datumCode) && $this->datumCode != 'none') { $datumDef = Proj4php::$datum[$this->datumCode]; if (is_array($datumDef)) { $this->datum_params = array_key_exists('towgs84', $datumDef) ? explode(',', $datumDef['towgs84']) : null; $this->ellps = $datumDef['ellipse']; $this->datumName = array_key_exists('datumName', $datumDef) ? $datumDef['datumName'] : $this->datumCode; } } if (!isset($this->a)) { // do we have an ellipsoid? if (!isset($this->ellps) || strlen($this->ellps) == 0 || !array_key_exists($this->ellps, Proj4php::$ellipsoid)) { $ellipse = Proj4php::$ellipsoid['WGS84']; } else { $ellipse = Proj4php::$ellipsoid[$this->ellps]; } Proj4php::extend($this, $ellipse); } if (isset($this->rf) && !isset($this->b)) { $this->b = (1.0 - 1.0 / $this->rf) * $this->a; } if (isset($this->rf) && $this->rf === 0 || abs($this->a - $this->b) < Proj4php::$common->EPSLN) { $this->sphere = true; $this->b = $this->a; } $this->a2 = $this->a * $this->a; // used in geocentric $this->b2 = $this->b * $this->b; // used in geocentric $this->es = ($this->a2 - $this->b2) / $this->a2; // e ^ 2 $this->e = sqrt($this->es); // eccentricity if (isset($this->R_A)) { $this->a *= 1.0 - $this->es * (Proj4php::$common->SIXTH + $this->es * (Proj4php::$common->RA4 + $this->es * Proj4php::$common->RA6)); $this->a2 = $this->a * $this->a; $this->b2 = $this->b * $this->b; $this->es = 0.0; } $this->ep2 = ($this->a2 - $this->b2) / $this->b2; // used in geocentric if (!isset($this->k0)) { $this->k0 = 1.0; } //default value //DGR 2010-11-12: axis if (!isset($this->axis)) { $this->axis = "enu"; } $this->datum = new Proj4phpDatum($this); }
/** * * @param type $p * @return type */ public function inverse($p) { /* $rh; // height above ellipsoid $z; // angle $sinz; $cosz; // sin of z and cos of z $temp; $con; $lon; $lat; */ /* Inverse equations ----------------- */ $p->x -= $this->x0; $p->y -= $this->y0; $rh = sqrt($p->x * $p->x + $p->y * $p->y); if ($rh > $this->a + 1.0E-7) { Proj4php::reportError("orthoInvDataError"); } $z = Proj4php::$common->asinz($rh / $this->a); $sinz = sin($z); $cosz = cos($z); $lon = $this->long0; if (abs($rh) <= Proj4php::$common->EPSLN) { $lat = $this->lat0; } $lat = Proj4php::$common->asinz($cosz * $this->sin_p14 + $p->y * $sinz * $this->cos_p14 / $rh); $con = abs($this->lat0) - Proj4php::$common->HALF_PI; if (abs(con) <= Proj4php::$common->EPSLN) { if ($this->lat0 >= 0) { $lon = Proj4php::$common->adjust_lon($this->long0 + atan2($p->x, -$p->y)); } else { $lon = Proj4php::$common->adjust_lon($this->long0 - atan2(-$p->x, $p->y)); } } $con = $cosz - $this->sin_p14 * sin($lat); $p->x = $lon; $p->y = $lat; return $p; }
/** * coordinate system definition, * point to transform in geocentric coordinates (x,y,z) * Note: this will change the point by reference. */ public function geocentric_from_wgs84(Point $p) { Proj4php::reportDebug('geocentric_from_wgs84(' . $p->x . ',' . $p->y . ")\n"); 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]; $x_tmp = ($p->x - $Dx_BF) / $M_BF; $y_tmp = ($p->y - $Dy_BF) / $M_BF; $z_tmp = ($p->z - $Dz_BF) / $M_BF; $p->x = $x_tmp + $Rz_BF * $y_tmp - $Ry_BF * $z_tmp; $p->y = -$Rz_BF * $x_tmp + $y_tmp + $Rx_BF * $z_tmp; $p->z = $Ry_BF * $x_tmp - $Rx_BF * $y_tmp + $z_tmp; } }
/** * Get layer tile info. * */ public static function getLayerTileInfo($layerName, $project, $wms_xml, $tileMatrixSetList) { $DOTS_PER_INCH = 72; $METERS_PER_INCH = 0.0254000508001016; $INCHES_PER_UNIT = array('inches' => 1.0, 'ft' => 12.0, 'mi' => 63360.0, 'm' => 39.37, 'km' => 39370, 'dd' => 4374754, 'yd' => 36); $INCHES_PER_UNIT["in"] = $INCHES_PER_UNIT['inches']; $INCHES_PER_UNIT["degrees"] = $INCHES_PER_UNIT['dd']; $INCHES_PER_UNIT["nmi"] = 1852 * $INCHES_PER_UNIT['m']; $tileWidth = 256.0; $tileHeight = 256.0; $rootLayer = $wms_xml->xpath("//wms:Capability/wms:Layer"); if (!$rootLayer || count($rootLayer) == 0) { return null; } $rootLayer = $rootLayer[0]; $rootExtent = array((double) $rootLayer->EX_GeographicBoundingBox->westBoundLongitude, (double) $rootLayer->EX_GeographicBoundingBox->southBoundLatitude, (double) $rootLayer->EX_GeographicBoundingBox->eastBoundLongitude, (double) $rootLayer->EX_GeographicBoundingBox->northBoundLatitude); $opt = $project->getOptions(); $scales = array_merge(array(), $opt->mapScales); rsort($scales); $layers = $project->getLayers(); $layer = $layers->{$layerName}; $xmlLayer = $wms_xml->xpath('//wms:Layer/wms:Name[. ="' . $layer->name . '"]/parent::*'); if (!$rootLayer || count($rootLayer) == 0) { return null; } $xmlLayer = $xmlLayer[0]; $layerExtent = null; $xmlLayers = $wms_xml->xpath('//wms:Layer/wms:Name[. ="' . $layer->name . '"]/parent::*//wms:Layer'); foreach ($xmlLayers as $xmlcLayer) { if (!property_exists($xmlcLayer, 'Layer')) { if ($layerExtent == null) { $layerExtent = array((double) $xmlcLayer->EX_GeographicBoundingBox->westBoundLongitude, (double) $xmlcLayer->EX_GeographicBoundingBox->southBoundLatitude, (double) $xmlcLayer->EX_GeographicBoundingBox->eastBoundLongitude, (double) $xmlcLayer->EX_GeographicBoundingBox->northBoundLatitude); } else { if ($layerExtent[0] > (double) $xmlcLayer->EX_GeographicBoundingBox->westBoundLongitude) { $layerExtent[0] = (double) $xmlcLayer->EX_GeographicBoundingBox->westBoundLongitude; } if ($layerExtent[1] > (double) $xmlcLayer->EX_GeographicBoundingBox->southBoundLatitude) { $layerExtent[1] = (double) $xmlcLayer->EX_GeographicBoundingBox->southBoundLatitude; } if ($layerExtent[2] < (double) $xmlcLayer->EX_GeographicBoundingBox->eastBoundLongitude) { $layerExtent[2] = (double) $xmlcLayer->EX_GeographicBoundingBox->eastBoundLongitude; } if ($layerExtent[3] < (double) $xmlcLayer->EX_GeographicBoundingBox->northBoundLatitude) { $layerExtent[3] = (double) $xmlcLayer->EX_GeographicBoundingBox->northBoundLatitude; } } } } if ($layerExtent == null) { $layerExtent = array((double) $xmlLayer->EX_GeographicBoundingBox->westBoundLongitude, (double) $xmlLayer->EX_GeographicBoundingBox->southBoundLatitude, (double) $xmlLayer->EX_GeographicBoundingBox->eastBoundLongitude, (double) $xmlLayer->EX_GeographicBoundingBox->northBoundLatitude); } // cannot be extra rootExtent if ($layerExtent[0] < $rootExtent[0]) { $layerExtent[0] = $rootExtent[0]; } if ($layerExtent[1] < $rootExtent[1]) { $layerExtent[1] = $rootExtent[1]; } if ($layerExtent[2] > $rootExtent[2]) { $layerExtent[2] = $rootExtent[2]; } if ($layerExtent[3] > $rootExtent[3]) { $layerExtent[3] = $rootExtent[3]; } $lowerCorner = (object) array('x' => $layerExtent[0], 'y' => $layerExtent[1]); $upperCorner = (object) array('x' => $layerExtent[2], 'y' => $layerExtent[3]); $opt = $project->getOptions(); jClasses::inc("proj4php~proj4php"); $proj4 = new Proj4php(); Proj4php::$defs[$opt->projection->ref] = $opt->projection->proj4; $sourceProj = new Proj4phpProj('EPSG:4326', $proj4); $tileMatrixSetLinkList = array(); foreach ($tileMatrixSetList as $tileMatrixSet) { $destProj = new Proj4phpProj($tileMatrixSet->ref, $proj4); $sourceMinPt = new proj4phpPoint($layerExtent[0], $layerExtent[1]); $destMinPt = $proj4->transform($sourceProj, $destProj, $sourceMinPt); $sourceMaxPt = new proj4phpPoint($layerExtent[2], $layerExtent[3]); $destMaxPt = $proj4->transform($sourceProj, $destProj, $sourceMaxPt); $extent = array($destMinPt->x, $destMinPt->y, $destMaxPt->x, $destMaxPt->y); $tileMatrixList = $tileMatrixSet->tileMatrixList; $tileMatrixLimits = array(); foreach ($tileMatrixList as $k => $tileMatrix) { $maxScale = $layer->maxScale; /* if ( $maxScale > $scales[0] ) $maxScale = $scales[0]; * */ $minScale = $layer->minScale; /* if ( $minScale < $scales[ count($scales) - 1 ] ) $minScale = $scales[ count($scales) - 1 ]; * */ if ($tileMatrix->scaleDenominator <= $maxScale && $tileMatrix->scaleDenominator >= $minScale) { $res = $tileMatrix->resolution; $minCol = floor(($extent[0] - $tileMatrix->left) / ($tileWidth * $res)); $maxCol = floor(($extent[2] - $tileMatrix->left) / ($tileWidth * $res)); $minRow = floor(($tileMatrix->top - $extent[3]) / ($tileHeight * $res)); $maxRow = floor(($tileMatrix->top - $extent[1]) / ($tileHeight * $res)); $tileMatrixLimits[] = (object) array('id' => $k, 'minRow' => $minRow, 'maxRow' => $maxRow, 'minCol' => $minCol, 'maxCol' => $maxCol); } } $tileMatrixSetLink = (object) array('ref' => $tileMatrixSet->ref, 'tileMatrixLimits' => null); $tileMatrixSetLink->tileMatrixLimits = $tileMatrixLimits; $tileMatrixSetLinkList[] = $tileMatrixSetLink; } $l = (object) array('id' => $layer->id, 'name' => $layer->name, 'title' => $layer->title, 'abstract' => $layer->abstract, 'imageFormat' => $layer->imageFormat, 'lowerCorner' => $lowerCorner, 'upperCorner' => $upperCorner, 'minScale' => $layer->minScale, 'maxScale' => $layer->maxScale, 'tileMatrixSetLinkList' => null); $l->tileMatrixSetLinkList = $tileMatrixSetLinkList; return $l; }
} else { $tgtProjection = 'EPSG:4326'; } } /** * Format */ if (isset($_GET['format'])) { $format = $_GET['format']; if (!($format == 'xml' || $format == 'json')) { $error = true; } } else { $format = 'xml'; } $proj4 = new Proj4php(); $projsource = new Proj4phpProj($srcProjection, $proj4); $projdest = new Proj4phpProj($tgtProjection, $proj4); // check the projections if (Proj4php::$defs[$srcProjection] == Proj4php::$defs['WGS84'] && $srcProjection != 'EPSG:4326') { $error = true; } if (Proj4php::$defs[$tgtProjection] == Proj4php::$defs['WGS84'] && $tgtProjection != 'EPSG:4326') { $error = true; } if ($error === true) { if ($format == 'json') { echo "{\"status\":\"error\", \"erreur\": {\"code\": 2, \"message\": \"Wrong parameters.\"} }"; exit; } else { echo "<reponse>";
public function inverse($p) { $p->x -= $this->x0; $p->y -= $this->y0; $x = $p->x / $this->a; $y = $p->y / $this->a; if ($this->sphere) { $cosz = 0.0; #$rh; $sinz = 0.0; $rh = sqrt($x * $x + $y * $y); $phi = $rh * 0.5; if ($phi > 1.0) { Proj4php::reportError("laea:Inv:DataError"); return null; } $phi = 2.0 * asin($phi); if ($this->mode == $this->OBLIQ || $this->mode == $this->EQUIT) { $sinz = sin($phi); $cosz = cos($phi); } switch ($this->mode) { case $this->EQUIT: $phi = abs($rh) <= Proj4php::$common->EPSLN ? 0.0 : asin($y * $sinz / $rh); $x *= $sinz; $y = $cosz * $rh; break; case $this->OBLIQ: $phi = abs($rh) <= Proj4php::$common->EPSLN ? $this->phi0 : asin($cosz * $this->sinph0 + $y * $sinz * $this->cosph0 / $rh); $x *= $sinz * $this->cosph0; $y = ($cosz - sin($phi) * $this->sinph0) * $rh; break; case $this->N_POLE: $y = -$y; $phi = Proj4php::$common->HALF_PI - $phi; break; case $this->S_POLE: $phi -= Proj4php::$common->HALF_PI; break; } $lam = $y == 0.0 && ($this->mode == $this->EQUIT || $this->mode == $this->OBLIQ) ? 0.0 : atan2($x, $y); } else { /* $cCe; $sCe; $q; $rho; */ $ab = 0.0; switch ($this->mode) { case $this->EQUIT: case $this->OBLIQ: $x /= $this->dd; $y *= $this->dd; $rho = sqrt($x * $x + $y * $y); if ($rho < Proj4php::$common->EPSLN) { $p->x = 0.0; $p->y = $this->phi0; return $p; } $sCe = 2.0 * asin(0.5 * $rho / $this->rq); $cCe = cos($sCe); $x *= $sCe = sin($sCe); if ($this->mode == $this->OBLIQ) { $ab = $cCe * $this->sinb1 + $y * $sCe * $this->cosb1 / $rho; $q = $this->qp * $ab; $y = $rho * $this->cosb1 * $cCe - $y * $this->sinb1 * $sCe; } else { $ab = $y * $sCe / $rho; $q = $this->qp * $ab; $y = $rho * $cCe; } break; case $this->N_POLE: $y = -$y; case $this->S_POLE: $q = $x * $x + $y * $y; if (!$q) { $p->x = 0.0; $p->y = $this->phi0; return $p; } /* q = $this->qp - q; */ $ab = 1.0 - $q / $this->qp; if ($this->mode == $this->S_POLE) { $ab = -$ab; } break; } $lam = atan2($x, $y); $phi = $this->authlat(asin($ab), $this->apa); } /* $Rh = sqrt($p->x *$p->x +$p->y * $p->y); $temp = Rh / (2.0 * $this->a); if (temp > 1) { Proj4php::reportError("laea:Inv:DataError"); return null; } $z = 2.0 * Proj4php::$common.asinz(temp); $sin_z=sin(z); $cos_z=cos(z); $lon =$this->long0; if (abs(Rh) > Proj4php::$common->EPSLN) { $lat = Proj4php::$common.asinz($this->sin_lat_o * cos_z +$this-> cos_lat_o * sin_z *$p->y / Rh); $temp =abs($this->lat0) - Proj4php::$common->HALF_PI; if (abs(temp) > Proj4php::$common->EPSLN) { temp = cos_z -$this->sin_lat_o * sin(lat); if(temp!=0.0) lon=Proj4php::$common->adjust_lon($this->long0+atan2($p->x*sin_z*$this->cos_lat_o,temp*Rh)); } else if ($this->lat0 < 0.0) { lon = Proj4php::$common->adjust_lon($this->long0 - atan2(-$p->x,$p->y)); } else { lon = Proj4php::$common->adjust_lon($this->long0 + atan2($p->x, -$p->y)); } } else { lat = $this->lat0; } */ //return(OK); $p->x = Proj4php::$common->adjust_lon($this->long0 + $lam); $p->y = $phi; return $p; }
public function inverse($p) { $x = $p->x - $this->x0; $y = $p->y - $this->y0; if ($this->sphere) { $lat = Proj4php::$common->HALF_PI - 2.0 * atan(exp(-$y / $this->a * $this->k0)); } else { $ts = exp(-$y / ($this->a * $this->k0)); $lat = Proj4php::$common->phi2z($this->e, $ts); if ($lat == -9999) { Proj4php::reportError("merc:inverse: lat = -9999"); return null; } } $lon = Proj4php::$common->adjust_lon($this->long0 + $x / ($this->a * $this->k0)); $p->x = $lon; $p->y = $lat; return $p; }
<?php // 資料來源: http://data.gov.tw/opendata/Details?sno=301000000A-00023 // 臺灣地區地名資料 if (!$_SERVER['argv'][1]) { die("php trans.php {proj4php.php position}"); } include $_SERVER['argv'][1]; $proj4 = new Proj4php(); $projSrc = new Proj4phpProj('EPSG:TM2', $proj4); $projDst = new Proj4phpProj('WGS84', $proj4); $twd67to97 = function ($point) { $A = 1.549E-5; $B = 6.521E-6; $X67 = $point[0]; $Y67 = $point[1]; $X97 = $X67 + 807.8 + $A * $X67 + $B * $Y67; $Y97 = $Y67 - 248.6 + $A * $Y67 + $B * $X67; return array($X97, $Y97); }; $fp = fopen('road.csv', 'r'); $output = fopen('php://output', 'w'); $columns = fgetcsv($fp); fputcsv($output, $columns); while ($rows = fgetcsv($fp)) { if ($rows[13] == 99 and $rows[14] == 99 or !$rows[13]) { $rows[13] = $rows[14] = ''; } else { // 有些資料 X, Y 寫反,所以加上 min, max 判斷 $point = $twd67to97(array(min($rows[13], $rows[14]), max($rows[13], $rows[14]))); $pointSrc = new proj4phpPoint($point[0], $point[1]);
public function readData($source_definition, $rest_parameters = array()) { // It may take a while for the SHP to be read set_time_limit(0); // Get the limit and offset list($limit, $offset) = Pager::calculateLimitAndOffset(); // Disregard the paging when rest parameters are given if (!empty($rest_parameters)) { $limit = PHP_INT_MAX; $offset = 0; } $uri = $source_definition['uri']; $columns = array(); $epsg = $source_definition['epsg']; // The tmp folder of the system, if none is given // abort the process $tmp_path = sys_get_temp_dir(); if (empty($tmp_path)) { // If this occurs then the server is not configured correctly, thus a 500 error is thrown \App::abort(500, "The temp directory, retrieved by the operating system, could not be retrieved."); } // Get the columns $columns = $this->tabular_columns->getColumnAliases($source_definition['id'], 'ShpDefinition'); // Get the geo properties $geo_properties = $this->geo_property->getGeoProperties($source_definition['id'], 'ShpDefinition'); $geo = array(); foreach ($geo_properties as $geo_prop) { $geo[$geo_prop['property']] = $geo_prop['path']; } if (!$columns) { \App::abort(500, "Cannot find the columns of the SHP definition."); } try { // Create the array in which all the resulting objects will be placed $arrayOfRowObjects = array(); // Prepare the options to read the SHP file $options = array('noparts' => false); $is_url = substr($uri, 0, 4) == "http"; // If the shape files are located on an HTTP address, fetch them and store them locally if ($is_url) { $tmp_file_name = uniqid(); $tmp_file = $tmp_path . "/" . $tmp_file_name; file_put_contents($tmp_file . ".shp", file_get_contents(substr($uri, 0, strlen($uri) - 4) . ".shp")); file_put_contents($tmp_file . ".dbf", file_get_contents(substr($uri, 0, strlen($uri) - 4) . ".dbf")); file_put_contents($tmp_file . ".shx", file_get_contents(substr($uri, 0, strlen($uri) - 4) . ".shx")); // Along this file the class will use file.shx and file.dbf $shp = new ShapeReader($tmp_file . ".shp", $options); } else { $shp = new ShapeReader($uri, $options); // along this file the class will use file.shx and file.dbf } // Keep track of the total amount of rows $total_rows = 0; // Get the shape records in the binary file while ($record = $shp->getNext()) { if ($offset <= $total_rows && $offset + $limit > $total_rows) { // Every shape record is parsed as an anonymous object with the properties attached to it $rowobject = new \stdClass(); // Get the dBASE data $dbf_data = $record->getDbfData(); foreach ($dbf_data as $property => $value) { $property_alias = $columns[$property]; $property = trim($property); $property_alias = $columns[$property]; $rowobject->{$property_alias} = trim($value); } // Read the shape data $shp_data = $record->getShpData(); if (!empty($epsg)) { $proj4 = new \Proj4php(); $projSrc = new \Proj4phpProj('EPSG:' . $epsg, $proj4); $projDest = new \Proj4phpProj('EPSG:4326', $proj4); } // It it's not a point, it's a collection of coordinates describing a shape if (!empty($shp_data['parts'])) { $parts = array(); foreach ($shp_data['parts'] as $part) { $points = array(); foreach ($part['points'] as $point) { $x = $point['x']; $y = $point['y']; // Translate the coordinates to WSG84 geo coordinates if (!empty($epsg)) { $pointSrc = new \proj4phpPoint($x, $y); $pointDest = $proj4->transform($projSrc, $projDest, $pointSrc); $x = $pointDest->x; $y = $pointDest->y; } $points[] = $x . ',' . $y; } array_push($parts, implode(" ", $points)); } // Parts only contains 1 shape, thus 1 geo entry $alias = reset($geo); $rowobject->{$alias} = implode(';', $parts); } if (isset($shp_data['x'])) { $x = $shp_data['x']; $y = $shp_data['y']; if (!empty($epsg)) { $pointSrc = new \proj4phpPoint($x, $y); $pointDest = $proj4->transform($projSrc, $projDest, $pointSrc); $x = $pointDest->x; $y = $pointDest->y; } $rowobject->{$geo}['longitude'] = $x; $rowobject->{$geo}['latitude'] = $y; } array_push($arrayOfRowObjects, $rowobject); } $total_rows++; } // Calculate the paging headers properties $paging = Pager::calculatePagingHeaders($limit, $offset, $total_rows); $data_result = new Data(); $data_result->data = $arrayOfRowObjects; $data_result->geo = $geo; $data_result->paging = $paging; $data_result->preferred_formats = array('map'); return $data_result; } catch (Exception $ex) { \App::abort(500, "Something went wrong while putting the SHP files in a temporary directory or during the extraction of the SHP data. The error message is: {$ex->getMessage}()."); } }
public function geodetic_to_geocentric($p) { $Longitude = $p->x; $Latitude = $p->y; $Height = isset($p->z) ? $p->z : 0; //Z value not always supplied $Error_Code = 0; // GEOCENT_NO_ERROR; /* * * Don't blow up if Latitude is just a little out of the value * * range as it may just be a rounding issue. Also removed longitude * * test, it should be wrapped by cos() and sin(). NFW for PROJ.4, Sep/2001. */ if ($Latitude < -Proj4php::$common->HALF_PI && $Latitude > -1.001 * Proj4php::$common->HALF_PI) { $Latitude = -Proj4php::$common->HALF_PI; } else { if ($Latitude > Proj4php::$common->HALF_PI && $Latitude < 1.001 * Proj4php::$common->HALF_PI) { $Latitude = Proj4php::$common->HALF_PI; } else { if ($Latitude < -Proj4php::$common->HALF_PI || $Latitude > Proj4php::$common->HALF_PI) { /* Latitude out of range */ Proj4php::reportError('geocent:lat out of range:' . $Latitude); return null; } } } if ($Longitude > Proj4php::$common->PI) { $Longitude -= 2 * Proj4php::$common->PI; } $Sin_Lat = sin($Latitude); /* sin(Latitude) */ $Cos_Lat = cos($Latitude); /* cos(Latitude) */ $Sin2_Lat = $Sin_Lat * $Sin_Lat; /* Square of sin(Latitude) */ $Rn = $this->a / sqrt(1.0 - $this->es * $Sin2_Lat); /* Earth radius at location */ $p->x = ($Rn + $Height) * $Cos_Lat * cos($Longitude); $p->y = ($Rn + $Height) * $Cos_Lat * sin($Longitude); $p->z = ($Rn * (1 - $this->es) + $Height) * $Sin_Lat; return $Error_Code; }
public function forward($p) { /* $theta; // angle $sin_phi; $cos_phi; // sin and cos value $b; // temporary values $c; $t; $tq; // temporary values $con; $n; $ml; // cone constant, small m $q; $us; $vl; $ul; $vs; $s; $dlon; $ts1; */ $lon = $p->x; $lat = $p->y; /* Forward equations ----------------- */ $sin_phi = sin($lat); $dlon = Proj4php::$common->adjust_lon($lon - $this->longc); $vl = sin($this->bl * $dlon); if (abs(abs($lat) - Proj4php::$common->HALF_PI) > Proj4php::$common->EPSLN) { $ts1 = Proj4php::$common->tsfnz($this->e, $lat, $sin_phi); $q = $this->el / pow($ts1, $this->bl); $s = 0.5 * ($q - 1.0 / $q); $t = 0.5 * ($q + 1.0 / $q); $ul = ($s * $this->singam - $vl * $this->cosgam) / $t; $con = cos($this->bl * $dlon); if (abs(con) < 1.0E-7) { $us = $this->al * $this->bl * $dlon; } else { $us = $this->al * atan(($s * $this->cosgam + $vl * $this->singam) / $con) / $this->bl; if ($con < 0) { $us = $us + Proj4php::$common->PI * $this->al / $this->bl; } } } else { if ($lat >= 0) { $ul = $this->singam; } else { $ul = -$this->singam; } $us = $this->al * $lat / $this->bl; } if (abs(abs($ul) - 1.0) <= Proj4php::$common->EPSLN) { //alert("Point projects into infinity","omer-for"); Proj4php::reportError("omercFwdInfinity"); //return(205); } $vs = 0.5 * $this->al * log((1.0 - $ul) / (1.0 + $ul)) / $this->bl; $us = $us - $this->u; $p->x = $this->x0 + $vs * $this->cosaz + $us * $this->sinaz; $p->y = $this->y0 + $us * $this->cosaz - $vs * $this->sinaz; return $p; }
/** * calculate lat/lon from xy * * @param Point $p * @return Point $p */ public function inverse($p) { /* Transformation */ /* revert y, x */ $tmp = $p->x; $p->x = $p->y; $p->y = $tmp; if ($this->czech) { $p->y *= -1.0; $p->x *= -1.0; } $ro = sqrt($p->x * $p->x + $p->y * $p->y); $eps = atan2($p->y, $p->x); $d = $eps / sin($this->s0); $s = 2.0 * (atan(pow($this->ro0 / $ro, 1.0 / $this->n) * tan($this->s0 / 2.0 + $this->s45)) - $this->s45); $u = asin(cos($this->ad) * sin(s) - sin($this->ad) * cos(s) * cos(d)); $deltav = asin(cos($s) * sin($d) / cos($u)); $p->x = $this->long0 - $deltav / $this->alfa; /* ITERATION FOR $lat */ $fi1 = $u; $ok = 0; $iter = 0; do { $p->y = 2.0 * (atan(pow($this->k, -1.0 / $this->alfa) * pow(tan($u / 2.0 + $this->s45), 1.0 / $this->alfa) * pow((1.0 + $this->e * sin($fi1)) / (1.0 - $this->e * sin($fi1)), $this->e / 2.0)) - $this->s45); if (abs($fi1 - $p->y) < 1.0E-10) { $ok = 1; } $fi1 = $p->y; $iter += 1; } while ($ok == 0 && $iter < 15); if ($iter >= 15) { Proj4php::reportError("PHI3Z-CONV:Latitude failed to converge after 15 iterations"); //console.log('iter:', iter); return null; } return $p; }
public function phi3z($ml, $e0, $e1, $e2, $e3) { $phi = $ml; for ($i = 0; $i < 15; $i++) { $dphi = ($ml + $e1 * sin(2.0 * $phi) - $e2 * sin(4.0 * $phi) + $e3 * sin(6.0 * $phi)) / $e0 - $phi; $phi += $dphi; if (abs($dphi) <= 1.0E-10) { return $phi; } } Proj4php::reportError("PHI3Z-CONV:Latitude failed to converge after 15 iterations"); return null; }
/** * */ public function __construct() { $this->initWKTProjections(); $this->initDefs(); $this->initDatum(); $this->initEllipsoid(); $this->initPrimeMeridian(); self::$proj['longlat'] = new proj4phpLongLat(); self::$proj['identity'] = new proj4phpLongLat(); self::$common = new proj4phpCommon(); self::$WGS84 = new Proj4phpProj('WGS84'); }
/** Transverse Mercator Inverse - x/y to long/lat */ public function inverse($p) { #$phi; /* temporary angles */ #$delta_phi; /* difference between longitudes */ $max_iter = 6; /* maximun number of iterations */ if (isset($this->sphere) && $this->sphere === true) { /* spherical form */ $f = exp($p->x / ($this->a * $this->k0)); $g = 0.5 * ($f - 1 / $f); $temp = $this->lat0 + $p->y / ($this->a * $this->k0); $h = cos($temp); $con = sqrt((1.0 - $h * $h) / (1.0 + $g * $g)); $lat = Proj4php::$common->asinz($con); if ($temp < 0) { $lat = -$lat; } if ($g == 0 && $h == 0) { $lon = $this->long0; } else { $lon = Proj4php::$common->adjust_lon(atan2($g, $h) + $this->long0); } } else { // ellipsoidal form $x = $p->x - $this->x0; $y = $p->y - $this->y0; $con = ($this->ml0 + $y / $this->k0) / $this->a; $phi = $con; for ($i = 0; true; $i++) { $delta_phi = ($con + $this->e1 * sin(2.0 * $phi) - $this->e2 * sin(4.0 * $phi) + $this->e3 * sin(6.0 * $phi)) / $this->e0 - $phi; $phi += $delta_phi; if (abs($delta_phi) <= Proj4php::$common->EPSLN) { break; } if ($i >= $max_iter) { Proj4php::reportError("tmerc:inverse: Latitude failed to converge"); return 95; } } // for() if (abs($phi) < Proj4php::$common->HALF_PI) { // sincos(phi, &sin_phi, &cos_phi); $sin_phi = sin($phi); $cos_phi = cos($phi); $tan_phi = tan($phi); $c = $this->ep2 * pow($cos_phi, 2); $cs = pow($c, 2); $t = pow($tan_phi, 2); $ts = pow($t, 2); $con = 1.0 - $this->es * pow($sin_phi, 2); $n = $this->a / sqrt($con); $r = $n * (1.0 - $this->es) / $con; $d = $x / ($n * $this->k0); $ds = pow($d, 2); $lat = $phi - $n * $tan_phi * $ds / $r * (0.5 - $ds / 24.0 * (5.0 + 3.0 * $t + 10.0 * $c - 4.0 * $cs - 9.0 * $this->ep2 - $ds / 30.0 * (61.0 + 90.0 * $t + 298.0 * $c + 45.0 * $ts - 252.0 * $this->ep2 - 3.0 * $cs))); $lon = Proj4php::$common->adjust_lon($this->long0 + $d * (1.0 - $ds / 6.0 * (1.0 + 2.0 * $t + $c - $ds / 20.0 * (5.0 - 2.0 * $c + 28.0 * $t - 3.0 * $cs + 8.0 * $this->ep2 + 24.0 * $ts))) / $cos_phi); } else { $lat = Proj4php::$common->HALF_PI * Proj4php::$common->sign($y); $lon = $this->long0; } } $p->x = $lon; $p->y = $lat; return $p; }
/** * Stereographic forward equations--mapping lat,long to x,y * * @param type $p * @return type */ public function forward($p) { $lon = $p->x; $lon = Proj4php::$common->adjust_lon($lon - $this->long0); $lat = $p->y; #$x; #$y; if ($this->sphere) { /* $sinphi; $cosphi; $coslam; $sinlam; */ $sinphi = sin($lat); $cosphi = cos($lat); $coslam = cos($lon); $sinlam = sin($lon); switch ($this->mode) { case $this->EQUIT: $y = 1.0 + $cosphi * $coslam; if (y <= Proj4php::$common->EPSLN) { Proj4php::reportError("stere:forward:Equit"); } $y = $this->akm1 / $y; $x = $y * $cosphi * $sinlam; $y *= $sinphi; break; case $this->OBLIQ: $y = 1.0 + $this->sinph0 * $sinphi + $this->cosph0 * $cosphi * $coslam; if ($y <= Proj4php::$common->EPSLN) { Proj4php::reportError("stere:forward:Obliq"); } $y = $this->akm1 / $y; $x = $y * $cosphi * $sinlam; $y *= $this->cosph0 * $sinphi - $this->sinph0 * $cosphi * $coslam; break; case $this->N_POLE: $coslam = -$coslam; $lat = -$lat; //Note no break here so it conitnues through S_POLE //Note no break here so it conitnues through S_POLE case $this->S_POLE: if (abs($lat - Proj4php::$common->HALF_PI) < $this->TOL) { Proj4php::reportError("stere:forward:S_POLE"); } $y = $this->akm1 * tan(Proj4php::$common->FORTPI + 0.5 * $lat); $x = $sinlam * $y; $y *= $coslam; break; } } else { $coslam = cos($lon); $sinlam = sin($lon); $sinphi = sin($lat); if ($this->mode == $this->OBLIQ || $this->mode == $this->EQUIT) { $Xt = 2.0 * atan($this->ssfn_($lat, $sinphi, $this->e)); $sinX = sin($Xt - Proj4php::$common->HALF_PI); $cosX = cos($Xt); } switch ($this->mode) { case $this->OBLIQ: $A = $this->akm1 / ($this->cosX1 * (1.0 + $this->sinX1 * $sinX + $this->cosX1 * $cosX * $coslam)); $y = $A * ($this->cosX1 * $sinX - $this->sinX1 * $cosX * $coslam); $x = $A * $cosX; break; case $this->EQUIT: $A = 2.0 * $this->akm1 / (1.0 + $cosX * $coslam); $y = $A * $sinX; $x = $A * $cosX; break; case $this->S_POLE: $lat = -$lat; $coslam = -$coslam; $sinphi = -$sinphi; case $this->N_POLE: $x = $this->akm1 * Proj4php::$common->tsfnz($this->e, $lat, $sinphi); $y = -$x * $coslam; break; } $x = $x * $sinlam; } $p->x = $x * $this->a + $this->x0; $p->y = $y * $this->a + $this->y0; return $p; }
public function forward($p) { $lon = $p->x; $lat = $p->y; // convert to radians if ($lat <= 90.0 && $lat >= -90.0 && $lon <= 180.0 && $lon >= -180.0) { //lon = lon * Proj4php::$common.D2R; //lat = lat * Proj4php::$common.D2R; } else { Proj4php::reportError("lcc:forward: llInputOutOfRange: " . $lon . " : " . $lat); return null; } $con = abs(abs($lat) - Proj4php::$common->HALF_PI); $ts; $rh1; if ($con > Proj4php::$common->EPSLN) { $ts = Proj4php::$common->tsfnz($this->e, $lat, sin($lat)); $rh1 = $this->a * $this->f0 * pow($ts, $this->ns); } else { $con = $lat * $this->ns; if ($con <= 0) { Proj4php::reportError("lcc:forward: No Projection"); return null; } $rh1 = 0; } $theta = $this->ns * Proj4php::$common->adjust_lon($lon - $this->long0); $p->x = $this->k0 * ($rh1 * sin($theta)) + $this->x0; $p->y = $this->k0 * ($this->rh - $rh1 * cos($theta)) + $this->y0; return $p; }
<?php include_once "../src/proj4php/proj4php.php"; $proj4 = new Proj4php(); $projL93 = new Proj4phpProj('EPSG:2154', $proj4); $projWGS84 = new Proj4phpProj('EPSG:4326', $proj4); $projLI = new Proj4phpProj('EPSG:27571', $proj4); $projLSud = new Proj4phpProj('EPSG:27563', $proj4); $projL72 = new Proj4phpProj('EPSG:31370', $proj4); $proj25833 = new Proj4phpProj('EPSG:25833', $proj4); $proj31468 = new Proj4phpProj('EPSG:31468', $proj4); // GPS // latitude longitude // 48,831938 2,355781 // 48°49'54.977'' 2°21'20.812'' // // L93 // 652709.401 6859290.946 // // LI // 601413.709 1125717.730 // $pointSrc = new proj4phpPoint('652709.401', '6859290.946'); echo "Source : " . $pointSrc->toShortString() . " in L93 <br>"; $pointDest = $proj4->transform($projL93, $projWGS84, $pointSrc); echo "Conversion : " . $pointDest->toShortString() . " in WGS84<br><br>"; $pointSrc = $pointDest; echo "Source : " . $pointSrc->toShortString() . " in WGS84<br>"; $pointDest = $proj4->transform($projWGS84, $projLSud, $pointSrc); echo "Conversion : " . $pointDest->toShortString() . " in Lambert Sud<br><br>"; $pointSrc = $pointDest;
/** * * @param type $arg * @param type $es * @param type $en * @return type */ public static function pj_inv_mlfn($arg, $es, $en) { $k = (double) 1 / (1 - $es); $phi = $arg; for ($i = Common::MAX_ITER; $i; --$i) { // rarely goes over 2 iterations $s = sin($phi); $t = 1.0 - $es * $s * $s; //$t = static::pj_mlfn($phi, $s, cos($phi), $en) - $arg; //$phi -= $t * ($t * sqrt($t)) * $k; $t = (static::pj_mlfn($phi, $s, cos($phi), $en) - $arg) * ($t * sqrt($t)) * $k; $phi -= $t; if (abs($t) < Common::EPSLN) { return $phi; } } Proj4php::reportError("cass:pj_inv_mlfn: Convergence error"); return $phi; }