/**
 * Get the neighborhood name for a pair of lat/long coordinates
 *
 * @param double $longitude decimal longitude
 * @param double $latitude decimal latitude
 *
 * @return string
 */
function get_neighborhood($longitude, $latitude)
{
    $neighborhoods = neighborhoods_array();
    foreach ($neighborhoods as $neighborhood) {
        list($neighborhood_name, $neighborhood_boundary) = $neighborhood;
        if (pointInPolygon($longitude, $latitude, $neighborhood_boundary)) {
            return $neighborhood_name;
        }
    }
    return '';
}
Ejemplo n.º 2
0
        }
    }
    $temp = array('areaName' => $area['properties']['name'], 'polySides' => count($area['geometry']['coordinates'][0]) - 1, 'polyX' => $polyX, 'polyY' => $polyY);
    array_push($areaArray, $temp);
}
//foreach($myC as $gat){
//	var_dump($gat);
//	echo '<br>';
//}
$tweetAndArea = array();
foreach ($myC as $tweet) {
    echo 'försöker updatera.... ';
    $pp = false;
    $testCoord = array($tweet['coordinates']['coordinates'][0], $tweet['coordinates']['coordinates'][1]);
    foreach ($areaArray as $area) {
        if (pointInPolygon($area, $testCoord)) {
            $newdata = array('$set' => array("area" => $area['areaName']));
            $collection->update(array('_id' => $tweet['_id']), $newdata);
            $pp = true;
            //$temp = array('_id' => $tweet['_id'] , 'area' =>$area['areaName']);
            //array_push($tweetAndArea,$temp);
        }
    }
    if (!$pp) {
        $newdata = array('$set' => array("area" => null));
        $collection->update(array('_id' => $tweet['_id']), $newdata);
    }
    echo "updaterad";
    echo '<br>';
}
//var_dump($tweetAndArea);
Ejemplo n.º 3
0
    $nodename = strtolower($node['nodeinfo']['hostname']);
    // Wenn der Knoten in der Blacklist steht
    if (in_array($node_element, $blacklist)) {
        unset($data['nodes'][$node_element]);
        $nodecount--;
    }
    // Wenn der Knoten in der Whiteliste steht
    if (in_array($node_element, $whitelist)) {
        continue;
    }
    // Wenn ein Knoten Koordinaten hat
    if (array_key_exists("location", $node['nodeinfo']) && array_key_exists("latitude", $node['nodeinfo']['location']) && array_key_exists("longitude", $node['nodeinfo']['location'])) {
        $x = $node['nodeinfo']['location']['latitude'];
        $y = $node['nodeinfo']['location']['longitude'];
        // Wenn sich der Knoten innerhalb des Polygons befindet.
        if (!pointInPolygon($polySides, $polyX, $polyY, $x, $y)) {
            unset($data['nodes'][$node_element]);
            $nodecount--;
        }
    } else {
        if (strpos($nodename, $filter_str) === false) {
            unset($data['nodes'][$node_element]);
            $nodecount--;
        }
    }
}
updateApiFile($nodecount);
$new_json = json_encode($data);
file_put_contents(OUTPUT_PATH . "/" . TARGET_FILENAME, $new_json);
$time_end = microtime_float();
$time = $time_end - $time_start;
/**
 * Get the country code for a pair of lat/long coordinates
 *
 * @param double $longitude decimal longitude
 * @param double $latitude  decimal latitude
 *
 * @return string country code or empty
 */
function get_country($longitude, $latitude)
{
    $countries = countries_array();
    foreach ($countries as $country) {
        list($country_code, $country_boundary) = $country;
        if (pointInPolygon($longitude, $latitude, $country_boundary, $country_code)) {
            return $country_code;
        }
    }
    return '';
}