Point-Mapping Extension: Unterschied zwischen den Versionen

GISWiki - Das freie Portal für Geoinformatik (GIS)
Wechseln zu: Navigation, Suche
(Munich and Berlin)
(Code)
Zeile 203: Zeile 203:
 
=Code=
 
=Code=
  
<pre>
+
[[Point-Mapping Extension/MapPoint.php|Version 0.1 can be found here]]
 
+
<?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[1];
+
  $varURLPoint = $varAr[2];
+
  $PointExt    = $varAr[3]; # PointSize (width = height)
+
 
+
  # Getting some image-information
+
 
+
  $varMapWidth  = $varAr[4];                # 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[5];
+
  $D = 0;
+
  $B = 0;
+
  $E = $varAr[6];
+
  $C = $varAr[7];
+
  $F = $varAr[8];
+
 
+
  # 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[9];
+
  $varPointLat = $varAr[10];
+
 
+
  # 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);
+
 
+
  # Adding an additional Link to the point;
+
  if ($varAr[11] == "")
+
  {
+
    $varHRef = "";
+
  }
+
  else
+
  {
+
    $varHRef = " href=\"".$varAr[11]."\"";
+
  }
+
 
+
  # for Hints (Mousover) and the <alt> tag
+
  if ($varAr[12] == "")
+
  {
+
    $varTitle = "";
+
    $varAlt = "";
+
  }
+
  else
+
  {
+
    $varTitle = " title=\"".$varAr[12]."\"";
+
    $varAlt = " alt=\"".$varAr[12]."\"";
+
  }
+
   
+
  # 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 ".$varHRef." ".$varTitle."><img name=\"myMapPoint_\" style=\"opacity: 1.0; position: absolute; top: ".$yImg."px; left: ".$xImg."px;\" src=\"".$varURLPoint."\" height=\"".$PointExt."\" width=\"".$PointExt."\" ".$varAlt." ></a></div></div>";
+
 
+
  return $output;
+
}
+
?>
+
 
+
</pre>
+
  
 
=Siehe auch=
 
=Siehe auch=

Version vom 24. August 2005, 15:54 Uhr

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.

Features

  • Darstellung eines Lagepunktes mittels geographischer Koordinaten
  • Darstellung belibig vieler Punkte
  • Verknüpfung des Punktes mit einem beliebigen Link
  • Hinweisfenster beim Überfahren des Punktes mit der Maus

Installation

siehe Quellcode

Parameter

  • $varURLMap: URL der Karte/Image-URL (z.B.: "http://www.giswiki.org/images/c/c1/DeutschlandRef.png";)
  • $varURLPoint: URL des Punktsymbols / Symbolimage-URL(z.B.: "http://www.giswiki.org/images/1/1b/Reddot.gif";)
  • $varMapWidth: = gewünschte Kartenbreite / desired width of the map
  • $PointExt: Punktsymbolgröße / desired symbol-size
  • $A: Meters/Pixel in horizontaler x östlicher Richtung / meters/pixel in horizontal x Easting direction
  • $E: Meters/Pixel in verticaler y nördlicher Richtung / 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
  • $varPointLon: Punktkoordinate (Geographische Länge) / point coordinates - Longitude
  • $varPointLat: Punktkoordinate (Geographische Breite) / point coordinates - Latitude
  • $varHRef: Link (optional)
  • $varTitle (=$varAlz): Für Hinweise (Mousover) und das <alt> tag (optional) / for hints and the <alt> tag

Beispiel

<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
Dies ist die Hauptstadt von Bayern
</MapPoint>


Links

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 and Berlin

<MapPoints>
[
http://www.giswiki.org/images/b/b0/DeutschlandGeoref.png
http://www.giswiki.org/images/1/1b/Reddot.gif
6
140
0.028662571242
-0.017977324880
5.499161111111
55.115925000000
]
{
11.5750
48.1400
http://de.wikipedia.org/wiki/München
München
}
{
13.394444
52.516667
http://de.wikipedia.org/wiki/Berlin
Unsere allerliebste Hauptstadt
}
</MapPoints>

<MapPoints> [ http://www.giswiki.org/images/b/b0/DeutschlandGeoref.png http://www.giswiki.org/images/1/1b/Reddot.gif 6 140 0.028662571242 -0.017977324880 5.499161111111 55.115925000000 ] { 11.5750 48.1400 http://de.wikipedia.org/wiki/München München } { 13.394444 52.516667 http://de.wikipedia.org/wiki/Berlin Unsere allerliebste Hauptstadt } </MapPoints>

Munich - using the bavarian flag

<MapPoints>
[
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
Dies ist die Hauptstadt von Bayern
}
</MapPoints>

<MapPoints> [ 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 Dies ist die Hauptstadt von Bayern } </MapPoints>

Berlin - using a bigger symbol

<MapPoints>
[
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
Unsere allerliebste Hauptstadt
}
</MapPoints>

<MapPoints> [ 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 Unsere allerliebste Hauptstadt } </MapPoints>

Code

Version 0.1 can be found here

Siehe auch