Esempio n. 1
0
 function make_output()
 {
     $lat0 = $this->p->latdeg;
     $lon0 = $this->p->londeg;
     $g = new GisDatabase();
     $g->select_radius_m($lat0, $lon0, $this->d * 1000, $this->attr['globe'], $this->attr['type'], $this->attr['arg:type']);
     $all = array();
     $all_pos = array();
     /* temporary store reqd due to sort */
     while ($x = $g->fetch_position()) {
         $id = $x->gis_page;
         $lat = ($x->gis_latitude_min + $x->gis_latitude_max) / 2;
         $lon = ($x->gis_longitude_min + $x->gis_longitude_max) / 2;
         $gc = new greatcircle($lat, $lon, $lat0, $lon0);
         # FIXME: multiple geos in same page are overwritten
         if ($gc->distance > $this->d * 1000) {
             # ignore those points that are within the
             # bounding rectangle, but not within the radius
         } else {
             $all[$id] = $gc->distance;
             $all_pos[$id] = array('lat' => $lat, 'lon' => $lon, 'name' => $x->page_title, 'type' => $x->gis_type, 'octant' => $gc->octant(), 'heading' => $gc->heading);
         }
     }
     /* Sort by distance */
     asort($all, SORT_NUMERIC);
     reset($all);
     /* Generate output */
     $out = "''List of " . count($all) . " locations within " . $this->d . " km of ";
     if ($this->title != "") {
         $out .= $this->title . ", ";
     }
     $out .= "coordinates " . $this->p->make_position($lat0, $lon0) . "''<br /><hr />\r\n";
     $table = "";
     while (list($id, $d) = each($all)) {
         $table .= $this->show_location($id, $d, $all_pos[$id]);
     }
     return "{$out}\n<table class=\"gisneighbourtable\">{$table}</table>\n";
 }
Esempio n. 2
0
/**
 *  Hook function called every time a page is deleted
 */
function articleDeleteGeo($article)
{
    $id = $article->getID();
    $g = new GisDatabase();
    $g->delete_position($id);
    return true;
}
Esempio n. 3
0
		  	</Url>
	  	</NetworkLink>
  	</Folder>
	</kml>
	<?php 
    exit(0);
} else {
    // split the client's BBOX return by commas and spaces to obtain an array of coordinates
    print "<Folder><name>de.wikipedia</name><open>1</open>\n";
    $coords = preg_split('/,|\\s/', $wgRequest->getVal('BBOX', '0,0,0,0'));
    // for clarity, place each coordinate into a clearly marked bottom_left or top_right variable
    $bl_lon = $coords[0];
    $bl_lat = $coords[1];
    $tr_lon = $coords[2];
    $tr_lat = $coords[3];
    $geodb = new GisDatabase();
    $geodb->select_area($bl_lat, $bl_lon, $tr_lat, $tr_lon);
    while ($place = $geodb->fetch_position()) {
        $nt = Title::makeTitle($place->page_namespace, $place->page_title);
        echo '<Placemark>';
        echo '<name>' . $nt->getText() . '</name>' . "\n";
        echo '<description><![CDATA[ Read more about this on <a href="' . $nt->getFullUrl() . '">Wikipedia</a>. ]]></description>' . "\n";
        echo '<styleUrl>root://styles#default</styleUrl><Style><IconStyle><Icon><href>root://icons/palette-4.png</href><x>160</x><y>160</y><w>32</w><h>32</h></Icon><scale>0.75</scale></IconStyle><LabelStyle><color>ffffffaa</color><scale>0.8</scale></LabelStyle></Style>';
        echo '<Point>';
        echo "<coordinates>{$place->gis_longitude_min},{$place->gis_latitude_min},0</coordinates>";
        echo '</Point>' . "\n";
        echo '</Placemark>' . "\n";
    }
    print "</Folder></kml>\n";
}
exit(0);