[mapserver-users] Photo Viewer

Jan Hartmann j.l.h.hartmann at uva.nl
Mon Feb 18 03:22:12 PST 2013


I do this by faking a WMS-service, with the pixel size of the scan as 
map boundaries, and using an arbitrary EPSG. It's primitive, but it 
works and I use it a lot, especially for large serieses of scans.

See:

http://mapserver.sara.nl/atlas/georef.html

Left the unreferenced scan, right the referenced maps, both zoomable 
independently. With a little elementary math, you can even align both 
maps (the sync buttons). You can even use it in QGIS or any other 
WMS-enabled program, e.g. to set reference points for warping or 
designing vector art work. Comments appreciated.

Jan

(file: utils.inc)

<?php
function getSizeRaster($data) {
     //Compute size of raster file $data in array $arr
     return ($ar);
}
function createMapFromData($title,$epsg,$parms,$data)
     $oMap = ms_newMapObj("");
     $oMap->setProjection("init=epsg:$epsg");
     $oMap->setMetaData("wms_title",$title);
     $oMap->setMetaData("wms_srs","epsg:$epsg");
     $oMap->setMetadata("wms_contactperson","Jan Hartmann");
     $oMap->setMetadata("wms_contactorganization","University of 
Amsterdam");
$oMap->setMetadata("wms_contactelectronicmailaddress","j.l.h.hartmann at uva.nl");
     $oMap->setMetadata("wms_enable_request","*");
     $pwd = "http://mapserver.sara.nl/" . $_SERVER["SERVER_NAME"];
     $pwd = $pwd .  $_SERVER["PHP_SELF"];
     if ($parms) $pwd = $pwd . "?$parms";
     $oMap->setMetadata("wms_onlineresource",$pwd);
     $l = ms_newLayerObj($oMap);
     $l->set("name",$title);
     $l->setProjection("init=epsg:$epsg");
     $l->setMetadata("wms_title",$title);
     $l->setMetadata("wms_srs","epsg:$epsg");
     $l->set("status",MS_DEFAULT);
     $l->set("type",MS_LAYER_RASTER);
     $l->set("data",$data);
     $ar = getSizeRaster($data);
     $oMap->setExtent($ar[0],$ar[1],$ar[2],$ar[3]);
     $oMap->setMetadata("wms_extent","$ar[0] $ar[1] $ar[2] $ar[3]");
     $l->setMetadata("wms_extent","$ar[0] $ar[1] $ar[2] $ar[3]");
     $oMap->setSize(600,600 * (($ar[3]-$ar[1]) / ($ar[2] - $ar[0])));
     return($oMap);
}
function dispatchMap($oMap) {
     $request = ms_newowsrequestobj();
     $request->loadparams();
     ms_ioinstallstdouttobuffer();
     $oMap->owsdispatch($request);
     $contenttype = ms_iostripstdoutbuffercontenttype();
     if ($contenttype == "text/xml") {
         header("Content-type: application/xml");
         $buffer = ms_iogetstdoutbufferstring();
         echo $buffer;
     } else {
         header("Content-type:$contenttype");
         ms_iogetStdoutBufferBytes();
     }
     ms_ioresethandlers();
}
?>

The simplest WMS-service would be a PHP-script like

<?php
require("utils.inc");
$fn = <path to scan-file>;
$oMap = createMapFromData("WMS_title",28992,"",$fn);
dispatchMap($oMap);
?>

The WMS-service would just be:

mywms.php


When you have a series of numbered scans in subdirectories, you could do:

<?php
require("utils.inc");
$base = <base directory of scans>;
$subdir = $_REQUEST["subdir"];
$nr = $_REQUEST["nr"];
$path = "$base/$subdir/scan_$nr.tif";
$oMap = createMapFromData("scan",28992,"subdir=$subdir&nr=$nr",$path);
dispatchMap($oMap);
?>

And accessl each scan as a WMS service like:

mywms.php?subdir=<subdir>&nr=<nr>


On 02/14/2013 05:03 PM, Weisbender, Eric wrote:
>
> I would like to use MapServer as just an unreferenced image viewer for 
> jpgs so I can zoom in and out on the image. Everything I read says 
> that images have to be georeferenced.  Any idea or even examples would 
> be greatly appreciated.
>
> Thanks,
>
> Eric Weisbender
>
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20130218/ebe29107/attachment-0001.html>


More information about the mapserver-users mailing list