This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Чему равен: $x = 2 * "15%" - 18 + "$23"; | |
Ответ: 12 | |
Обоснование: Здесь использутся математические вычисления. А значит, 15% - приводятся к числу 30, а "$23" вообще не может быть вычислено и является NULL для матвечислений | |
2. Чему будет равен $z = (empty($x) && isset($y)) ? 10:20, если: | |
a) $x = 0; $y = 0; | |
//карман $x есть , в кармане пусто, занчит true | |
//карман $y есть, значит true; | |
Ответ: 10 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//https://github.com/jsor/geokit/blob/master/src/Polygon.php | |
$polygon = array([59.908456,29.659262],[59.885888,29.679213],[59.869938,29.74622],[59.863651,29.793783],[59.826761,29.824958],[59.812481,29.891431],[59.822211,29.967316],[59.816563,30.012207],[59.815913,30.076178],[59.801366,30.148366],[59.802641,30.173356],[59.812262,30.198768],[59.825935,30.233399],[59.833165,30.281853],[59.812214,30.319813],[59.811782,30.343651],[59.816016,30.380928],[59.825793,30.435141],[59.845107,30.458015],[59.853578,30.487691],[59.865128,30.527404],[59.889652,30.524301],[59.91036,30.526205],[59.927852,30.533823],[59.949187,30.543342],[59.966752,30.552995],[59.979217,30.525869],[59.984258,30.496359],[59.999108,30.47677],[60.012867,30.471708],[60.025186,30.450557],[60.041604,30.437535],[60.052483,30.404479],[60.066082,30.38521],[60.090189,30.371481],[60.095391,30.323246],[60.099381,30.278742],[60.092028,30.24515],[60.084021,30.214452],[60.07635,30.182448],[60.058877,30.144609],[60.045573,30.044505],[60.039066,29.980322 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//https://github.com/davidkonrad | |
//https://stackoverflow.com/questions/14818567/point-in-polygon-algorithm-giving-wrong-results-sometimes?answertab=active#tab-top | |
//Modified function pointInPolygon to use with arrays as arguments | |
//You can sumply convert to class this mod to class version | |
//More points in poligon - more result precision | |
// Polygon points for Saint-Pieterburg and Moscow circle road |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* is (lon, lat) inside the polygon $p? | |
* use ray casting algorithm (http://en.wikipedia.org/wiki/Point_in_polygon) | |
* ie. project a horizontal line from our point to each segment | |
* code adapted from http://stackoverflow.com/questions/14149099/raycasting-algorithm-with-gps-coordinates | |
*/ | |
function inside_polygon($test_point, $points) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//https://github.com/davidkonrad | |
//https://stackoverflow.com/questions/14818567/point-in-polygon-algorithm-giving-wrong-results-sometimes?answertab=active#tab-top | |
$polygon_kad_points['Санкт-Петербург'] = array([59.908456,29.659262],[59.885888,29.679213],[59.869938,29.74622],[59.863651,29.793783],[59.826761,29.824958],[59.812481,29.891431],[59.822211,29.967316],[59.816563,30.012207],[59.815913,30.076178],[59.801366,30.148366],[59.802641,30.173356],[59.812262,30.198768],[59.825935,30.233399],[59.833165,30.281853],[59.812214,30.319813],[59.811782,30.343651],[59.816016,30.380928],[59.825793,30.435141],[59.845107,30.458015],[59.853578,30.487691],[59.865128,30.527404],[59.889652,30.524301],[59.91036,30.526205],[59.927852,30.533823],[59.949187,30.543342],[59.966752,30.552995],[59.979217,30.525869],[59.984258,30.496359],[59.999108,30.47677],[60.012867,30.471708],[60.025186,30.450557],[60.041604,30.437535],[60.052483,30.404479],[60.066082,30.38521],[60.090189,30.371481],[60.095391,30.323246],[60.099381,30.27874 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$kad['Санкт-Петербург'] = array([59.908456,29.659262],[59.885888,29.679213],[59.869938,29.74622],[59.863651,29.793783],[59.826761,29.824958],[59.812481,29.891431],[59.822211,29.967316],[59.816563,30.012207],[59.815913,30.076178],[59.801366,30.148366],[59.802641,30.173356],[59.812262,30.198768],[59.825935,30.233399],[59.833165,30.281853],[59.812214,30.319813],[59.811782,30.343651],[59.816016,30.380928],[59.825793,30.435141],[59.845107,30.458015],[59.853578,30.487691],[59.865128,30.527404],[59.889652,30.524301],[59.91036,30.526205],[59.927852,30.533823],[59.949187,30.543342],[59.966752,30.552995],[59.979217,30.525869],[59.984258,30.496359],[59.999108,30.47677],[60.012867,30.471708],[60.025186,30.450557],[60.041604,30.437535],[60.052483,30.404479],[60.066082,30.38521],[60.090189,30.371481],[60.095391,30.323246],[60.099381,30.278742],[60.092028,30.24515],[60.084021,30.214452],[60.07635,30.182448],[60.058877,30.144609],[60.045573,30.044505],[60.039066,29.980322],[60.028953,29.865704],[60.020797,29.741338],[60.0011 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Криво работает, хотя должно работать хорошо | |
//Узнать находится ли точка внутри полигона | |
//Санкт-Петербург | |
$polygon_points = array("59.908456,29.659262","59.905894,29.659723","59.905293,29.659839","59.904766,29.659926","59.903862,29.660083","59.903123,29.660207","59.902343,29.660334","59.901598,29.660484","59.900626,29.660775","59.899732,29.661114","59.899362,29.661283","59.89862,29.661638","59.897921,29.662026","59.897444,29.662333","59.896872,29.66272","59.896398,29.66305","59.896042,29.663332","59.895619,29.663662","59.895001,29.66421","59.894362,29.664813","59.893615,29.665624","59.89327,29.666024","59.892639,29.66676","59.891885,29.667728","59.891011,29.668968","59.890278,29.670077","59.88992,29.670673","59.889275,29.671771","59.888952,29.672345","59.888597,29.673015","59.888531,29.673147","59.887685,29.67492","59.887186,29.675988","59.886609,29.677327","59.886045,29.678779","59.885888,29.679213","59.885659,29.679844","59.885324,29.680875","59.884895,29.682255","59.884594,29.683271","59.884321,29. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
1. Открыть яндекс карты | |
2. Сделать поиск "КАД СПБ", на карте отобразится линия КАД | |
3. Отрыть исходный код страницы | |
4. Скопировать вес код страницы в буфер (CTRL+C) | |
5. Вопсропьзоваться http://jsbeautifier.org/ для получения читаемости кода | |
6. Найти в коде: Санкт-Петербург, КАД и чуть ниже массив с кординатами КАД | |
7. ВАЖНО!!! Числовые значения каждой координаты поменять местами, тогда массив будет корректным для поиска координат | |
(видимо в яндекс картак придерживаютязаписи: Широта, Долгота) а нам надо Долгота, Широта. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class deliveryRusPochta { | |
private $address = ''; //Адрес получателя, куда отправлять посылку | |
private $order_total = 0; //Сума заказа | |
private $weight = 0; //Вес отправления | |
private $index_to = 0; //Индекс, выичленный на основе строки адреса | |
private $index_from = xxxxxx; //Индекс места отправления соглалснго догвору с Почтой Росссии | |
private $insurance = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
This class return result in array: | |
array(3) { | |
["data"]=> | |
array(6) { | |
["in_polygon"]=> | |
string(7) "outside" | |
["min_distance"]=> |
NewerOlder