Point-Mapping Extension

GISWiki - Das freie Portal für Geoinformatik (GIS)
Wechseln zu: Navigation, Suche

This Point-Mapping Extension (MapPoint) combines a referenced image / map and point-coordinates. The result is a geo-referenced map with a geo-referenced point.

Über eine Extension können Punktkoordinaten mit georeferenzierten Karten verbunden werden. Diese Möglichkeit wird mit der Point-Mapping_Extension gezeigt. Eine zuvor hochgeladene Deutschlandkarte, wie sie in vielen Artikeln zur Veranschaulichgung von Ortschaften genutzt wird, wird mittels einer MediaWiki-Extension georefernziert. Zusammen mit den ebenfalls an die Extension übergebenen Punktkoordinaten wird eine Karte generiert, in der die Lage des Punktes angezeigt wird.

Parameter

  • $varURLMap: URL der Karte (z.B.: "http://www.giswiki.org/images/c/c1/DeutschlandRef.png";)
  • $varURLPoint: URL des Punktsymbols (z.B.: "http://www.giswiki.org/images/1/1b/Reddot.gif";)
  • $varMapWidth: = Breite der Karte im Ergebnis
  • $PointExt: Punktsymbolgröße
  • $A: Meters/Pixel in horizontaler x östlicher Richtung
  • $E: Meters/Pixel in verticaler y nördlicher Richtung
  • $C: x Easting UTM coordinate of center of upper left pixel in meters
  • $F: y Northing UTM coordinate of center of upper left pixel in meters
  • $varPointLon: Punktkoordinate (Geographische Länge)
  • $varPointLat: Punktkoordinate (Geographische Breite)

To Do's

  • Übergabe mehrere Punkte
  • Kombination mit einer Vorlage (??)
  • Parameterübergabe in mehreren Zeilen
  • Punkte mit URL verbinden
  • Externes URLSymbol (External.png) per CSS verschwinden lassen
  • Alternativtext für Punkte

Samples

Munich

Using a Red Dot

<MapPoint>
http://www.giswiki.org/images/b/b0/DeutschlandGeoref.png
http://www.giswiki.org/images/1/1b/Reddot.gif
6
144
0.028662571242
-0.017977324880
5.499161111111
55.115925000000
11.5750
48.1400
http://de.wikipedia.org/wiki/München
Hier liegt München
</MapPoint>

<MapPoint> http://www.giswiki.org/images/b/b0/DeutschlandGeoref.png http://www.giswiki.org/images/1/1b/Reddot.gif 6 144 0.028662571242 -0.017977324880 5.499161111111 55.115925000000 11.5750 48.1400 http://de.wikipedia.org/wiki/München München </MapPoint>

using the bavarian flag

<MapPoint>
http://www.giswiki.org/images/b/b0/DeutschlandGeoref.png
http://upload.wikimedia.org/wikipedia/commons/a/a3/Flag_de-bayern_lozenge.png
6
144
0.028662571242
-0.017977324880
5.499161111111
55.115925000000
11.5750
48.1400
http://de.wikipedia.org/wiki/München
</MapPoint>

<MapPoint> http://www.giswiki.org/images/b/b0/DeutschlandGeoref.png http://upload.wikimedia.org/wikipedia/commons/a/a3/Flag_de-bayern_lozenge.png 20 144 0.028662571242 -0.017977324880 5.499161111111 55.115925000000 11.5750 48.1400 http://de.wikipedia.org/wiki/München </MapPoint>

Berlin

using a bigger symbol

<MapPoint>
http://www.giswiki.org/images/b/b0/DeutschlandGeoref.png
http://www.giswiki.org/images/1/1b/Reddot.gif
20
140
0.028662571242
-0.017977324880
5.499161111111
55.115925000000
13.394444
52.516667
http://de.wikipedia.org/wiki/Berlin
</MapPoint>

<MapPoint> http://www.giswiki.org/images/b/b0/DeutschlandGeoref.png http://www.giswiki.org/images/1/1b/Reddot.gif 20 140 0.028662571242 -0.017977324880 5.499161111111 55.115925000000 13.394444 52.516667 http://de.wikipedia.org/wiki/Berlin </MapPoint>

Code


<?php
# MapPoint by Heinz-Josef Lücking h-j.luecking@t-online.de
#
# Copy this text into a file called "MapPoint.php" and save it into the directory "extensions"
# To activate the extension, include it from your LocalSettings.php
# with: include("extensions/MapPoint.php");
#
# visit http://www.giswiki.org
#
#
# Have fun
#
$wgExtensionFunctions[] = "wfMapPoint";

function wfMapPoint() {
  global $wgParser;
  $wgParser->setHook( "MapPoint", "renderMapPoint" );
}

function renderMapPoint( $input ) {

   
  $varAr = explode("\n", $input);
    
  # Image(Map) and Point-files 
  # e.g.:
  # $varURLMap   = "http://www.giswiki.org/images/c/c1/DeutschlandRef.png";
  # $varURLPoint = "http://www.giswiki.org/images/1/1b/Reddot.gif";
  # $varMapWidth = 140;

  $varURLMap   = $varAr[0];
  $varURLPoint = $varAr[1];
  $PointExt    = $varAr[2]; # PointSize (width = height)
   
  # Getting some image-information
   
  $varMapWidth  = $varAr[3];                 # the width the image should be displayed
  $size         = getimagesize("$varURLMap");# the real size of the image
  $height       = $size[1];                  # real height
  $width        = $size[0];                  # real width
  $varZoom      = $varMapWidth / $width;     # zoom-factor
  $varMapHeigth = $height * $varZoom;        # computed image-heigth
   
  # Georeferencing the image (see http://en.wikipedia.org/wiki/World_file)
  #
  # A: meters/pixel in horizontal x Easting direction
  # D: rotation about y axis, always 0
  # B: rotation about x axis, always 0
  # E: meters/pixel in vertical y Northing direction
  # C: x Easting UTM coordinate of center of upper left pixel in meters
  # F: y Northing UTM coordinate of center of upper left pixel in meters
  #
  # Use a dot for commas!
  #
  # Sample for the image above
  #
  # $A = 0.028662571242;
  # $D = 0.000000000000;
  # $B = 0.000000000000;
  # $E = -0.017977324880;
  # $C = 5.499161111111;
  # $F = 55.115925000000;

  $A = $varAr[4];
  $D = 0;
  $B = 0;
  $E = $varAr[5];
  $C = $varAr[6];
  $F = $varAr[7];

  # The point which shall be displayed on the map
  # Coordinates must be Longitude and Latitude with decimal degrees
  # Use a dot for commas!
  #
  # e.g. Munich:
  # $varPointLon = 11.5750
  # $varPointLat = 48.1400;
   
  $varPointLon = $varAr[8];
  $varPointLat = $varAr[9];

  # Calculating the position of the point on the image
  # $varPointX = ((11.5750 - 5.499161111111) / 0.028662571242) - 5;
  # $varPointY = ((48.1400 - 55.115925000000) / -0.017977324880) - 5;
   
  $xImg = ((($varPointLon - $C) / $A) * $varZoom) - ($PointExt / 2);
  $yImg = ((($varPointLat - $F) / $E) * $varZoom) - ($PointExt / 2);
    
  # Building the output

  $MapRand = rand(); # add some random text to <div id="MapPoint...
	
  $output = "<div id=\"MapPoint".$MapRand."\" class=\"MapPoint\" style=\"position: relative; left: 0px; top: 0px; width: ".$varMapWidth."px; height: ".$varMapHeigth."px; visibility: visible; background-color: white;\"> <img name=\"myMap\" style=\"position: absolute; top: 0pt; left: 0pt;\" src=\"".$varURLMap."\" height=\"".$varMapHeigth."\" width=\"".$varMapWidth."\"> <div id=\"myMapPoint\" class=\"\" style=\"position: relative; left: 0px; top: 0px; width: ".$varMapWidth."px; height: ".$varMapHeigth."px; visibility: visible;\"> <a href=\"".$varHRef."\"><img name=\"myMapPoint_\" style=\"opacity: 1.0; position: absolute; top: ".$yImg."px; left: ".$xImg."px;\" src=\"".$varURLPoint."\" height=\"".$PointExt."\" width=\"".$PointExt."\"></a></div></div>";

  return $output;
}
?>


Siehe auch