[ka-Map-users] precache2.php bug
Stephen Woodbridge
woodbri at swoodbridge.com
Fri Aug 18 13:45:22 EDT 2006
OK, I think the fix is straight forward after reading the code a bit
more. I changed it to look like this and it seems to be doing what it
was expected to do before:
$aszGroups = $oMap->getAllGroupNames();
// get the default mapfile extents
$minx = $oMap->extent->minx;
$maxx = $oMap->extent->maxx;
$miny = $oMap->extent->miny;
$maxy = $oMap->extent->maxy;
// modify map extent for max_extent metadata
if($oMap->getMetaData('max_extents') != '') {
$szMaxExtents = $oMap->getMetaData('max_extents');
$aszMaxExtents = preg_split('/[\s,]+/', $szMaxExtents);
if(count($aszMaxExtents) == 4) {
$minx = min($aszMaxExtents[0], $aszMaxExtents[2]);
$miny = min($aszMaxExtents[1], $aszMaxExtents[3]);
$maxx = max($aszMaxExtents[0], $aszMaxExtents[2]);
$maxy = max($aszMaxExtents[1], $aszMaxExtents[3]);
$oMap->setExtent($minx, $miny, $maxx, $maxy);
}
}
// modify map extents for extents as arguments
if($_REQUEST['e']) {
$aszMaxExtents = preg_split('/[\s,]+/', $_REQUEST['e']);
if(count($aszMaxExtents) == 4) {
$minx = min($aszMaxExtents[0], $aszMaxExtents[2]);
$miny = min($aszMaxExtents[1], $aszMaxExtents[3]);
$maxx = max($aszMaxExtents[0], $aszMaxExtents[2]);
$maxy = max($aszMaxExtents[1], $aszMaxExtents[3]);
$oMap->setExtent($minx, $miny, $maxx, $maxy);
}
else
exit($usage);
}
// use these as the extents the we want to generate tiles over
$dMinX = $minx;
$dMaxX = $maxx;
$dMinY = $miny;
$dMaxY = $maxy;
print "\nUsing adjusted extents of [$dMinX, $dMinY, $dMaxX, $dMaxY]\n";
-Steve
Stephen Woodbridge wrote:
> Hi Tim, Paul,
>
> I think I have found a bug in precache2.php and I'm not sure of the best
> way to fix it.
>
> I added an argument -e <xmin ymin xmax ymax> to limit cache creation to
> extents so I could use this from then command line or URL instead of
> modifing the mapfile. I modified the code to look like this:
>
> // modify map extent for max_extent metadata
> if($oMap->getMetaData('max_extents') != '') {
> $szMaxExtents = $oMap->getMetaData('max_extents');
> $aszMaxExtents = preg_split('/[\s,]+/', $szMaxExtents);
> if(count($aszMaxExtents) == 4) {
> $minx = min($aszMaxExtents[0], $aszMaxExtents[2]);
> $miny = min($aszMaxExtents[1], $aszMaxExtents[3]);
> $maxx = max($aszMaxExtents[0], $aszMaxExtents[2]);
> $maxy = max($aszMaxExtents[1], $aszMaxExtents[3]);
> $oMap->setExtent($minx, $miny, $maxx, $maxy);
> }
> }
>
> // modify map extents for extents as arguments
> if($_REQUEST['e']) {
> $aszMaxExtents = preg_split('/[\s,]+/', $_REQUEST['e']);
> if(count($aszMaxExtents) == 4) {
> $minx = min($aszMaxExtents[0], $aszMaxExtents[2]);
> $miny = min($aszMaxExtents[1], $aszMaxExtents[3]);
> $maxx = max($aszMaxExtents[0], $aszMaxExtents[2]);
> $maxy = max($aszMaxExtents[1], $aszMaxExtents[3]);
> $oMap->setExtent($minx, $miny, $maxx, $maxy);
> }
> else
> exit($usage);
> }
>
> $dMinX = $oMap->extent->minx;
> $dMaxX = $oMap->extent->maxx;
> $dMinY = $oMap->extent->miny;
> $dMaxY = $oMap->extent->maxy;
>
> print "\nUsing adjusted extents of [$dMinX, $dMinY, $dMaxX, $dMaxY]\n";
>
> So basically, if the command line argument exists is over writes the
> metadata values. This all works fine. I added the print, to see what I
> was getting and to my surprise I got really wild values compared to what
> I was expecting. So the URL and response is below.
>
> http://localhost/ka-map/precache3.php?m=smap-01&s=4000000&e=-142+47+-50+74&f=1
>
>
> Using adjusted extents of [-142, 14.5, -50, 106.5]
>
> Map: smap-01
> Scale: 4000000
> Meta tiles: 7 x 7 = 49
> Tiles: 7 x 7 x 5 x 5 = 1225
> Group: __base__
> row: /u/data/tile-cache/smap-01/4000000/__base__/def/t-8960/l-3840,
> rtime=3, rrate=11.7
> row: /u/data/tile-cache/smap-01/4000000/__base__/def/t-7680/l-3840,
> rtime=2, rrate=17.5
> row: /u/data/tile-cache/smap-01/4000000/__base__/def/t-6400/l-3840,
> rtime=3, rrate=11.7
> row: /u/data/tile-cache/smap-01/4000000/__base__/def/t-5120/l-3840,
> rtime=8, rrate=4.4
> row: /u/data/tile-cache/smap-01/4000000/__base__/def/t-3840/l-3840,
> rtime=128, rrate=0.3
> row: /u/data/tile-cache/smap-01/4000000/__base__/def/t-2560/l-3840,
> rtime=29, rrate=1.2
> row: /u/data/tile-cache/smap-01/4000000/__base__/def/t-1280/l-3840,
> rtime=2, rrate=17.5
> MetaTile Rate = 0.3; Tile Rate = 7.0; Duration = 175 secs
>
> So my analysis is that the code sets:
>
> $mapWidth = $metaWidth * $tileWidth;
> $mapHeight = $metaHeight * $tileHeight;
> $oMap->setSize($mapWidth, $mapHeight);
>
> which is basically square. Then it gets the extents from the command
> line does a:
>
> $oMap->setExtent($minx, $miny, $maxx, $maxy);
>
> which does NOT set the extents entered, but adjusts the extents to be
> the same aspect ratio of the square image set above. So if you request
> extents 2 degrees high and 180 degrees wide you will generate a square
> of tiles 180 x 180 degrees.
>
> Is this analysis correct? Or did I miss something?
>
> I seems the the max extents needs to be converted into correct $dMinX,
> $dMinY, $dMaxX, $dMaxY, but it is not obvious how that should be done.
> Got any thoughts on this?
>
> -Steve
> _______________________________________________
> ka-Map-users mailing list
> ka-Map-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/ka-map-users
>
More information about the ka-Map-users
mailing list