Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XYZ layer 500 (Internal Server Error) #120

Closed
RenoSun opened this issue Dec 9, 2015 · 10 comments
Closed

XYZ layer 500 (Internal Server Error) #120

RenoSun opened this issue Dec 9, 2015 · 10 comments

Comments

@RenoSun
Copy link

RenoSun commented Dec 9, 2015

Mapguide-Rest - RC3
For the example on the mapguide-rest example site:

I can request the tile.json without any problems.
http://localhost/mapserver/rest/library/Samples/Sheboygan/MapsTiled/SheboyganNoWatermark.MapDefinition/xyz/Base%20Layer%20Group/12/1050/1493/tile.json

However, when I was trying to get the the XYZ png tile, it gave me errors as following one:
GET http://localhost/mapserver/rest/library/Samples/Sheboygan/…anNoWatermark.MapDefinition/xyz/Base%20Layer%20Group/12/1050/1493/tile.png 500 (Internal Server Error)

Any idea about what might be wrong? Thanks you very much!

@jumpinjackie
Copy link
Owner

You can activate logging in app/log_config.php and see what errors are being logged by the tile service controller.

@RenoSun
Copy link
Author

RenoSun commented Dec 10, 2015

It's totally fine if I am using codes of tileservicecontroller.php (RC2). Is there any big change between RC2 and RC3 for generating XYZ tiles?

I saw following message in debug.log.

(2065) MgException caught A file IO exception occurred:

#0 C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2014\www\rest\app\controller\tileservicecontroller.php(298): mgbytesink->tofile('')
#1 C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2014\www\rest\app\controller\tileservicecontroller.php(526): MgTileServiceController->PutTileImageXYZ(Object(mgmap), 'Base Layer Grou...', Object(mgrenderingservice), 'C:\Program File...', 'PNG', -9766817.7261667, 5422748.5346635, -9764371.7412616, 5425194.5195687, NULL, 2065)
#2 C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2014\www\rest\app\routes\v1\routes.library.php(1647): MgTileServiceController->GetTileXYZ(Object(mgresourceidentifier), 'Base Layer Grou...', '4199', '5974', '14', 'png')
#3 [internal function]: {closure}(Array, 'Base Layer Grou...', '14', '4199', '5974', 'png')
#4 C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2014\www\rest\vendor\slim\slim\Slim\Route.php(468): call_user_func_array(Object(Closure), Array)
#5 C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2014\www\rest\vendor\slim\slim\Slim\Slim.php(1357): Slim\Route->dispatch()
#6 C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2014\www\rest\vendor\slim\slim\Slim\Middleware\Flash.php(85): Slim\Slim->call()
#7 C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2014\www\rest\vendor\slim\slim\Slim\Middleware\MethodOverride.php(92): Slim\Middleware\Flash->call()
#8 C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2014\www\rest\vendor\slim\slim\Slim\Middleware\PrettyExceptions.php(67): Slim\Middleware\MethodOverride->call()
#9 C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2014\www\rest\vendor\slim\slim\Slim\Slim.php(1302): Slim\Middleware\PrettyExceptions->call()
#10 C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2014\www\rest\index.php(198): Slim\Slim->run()
#11 {main}
. Releasing lock for C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2014\www\rest/./cache/tile.png/Samples/Sheboygan/MapsTiled/SheboyganNoWatermark/Base Layer Group/14/4199/5974.png
(2065) C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2014\www\rest/./cache/tile.png/Samples/Sheboygan/MapsTiled/SheboyganNoWatermark/Base Layer Group/14/4199/5974.png does not exist. Locking for writing
(2065) Acquired lock for C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2014\www\rest/./cache/tile.png/Samples/Sheboygan/MapsTiled/SheboyganNoWatermark/Base Layer Group/14/4199/5974.png. Checking if path exists again.
(2065) Rendering tile to C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2014\www\rest/./cache/tile.png/Samples/Sheboygan/MapsTiled/SheboyganNoWatermark/Base Layer Group/14/4199/5974.png
(2065) Going down old code path
(2065) Calc bounds from XYZ

@RenoSun
Copy link
Author

RenoSun commented Dec 10, 2015

I changed the following codes under PutTileImageXYZ function, then it has no problem now.

private function PutTileImageXYZ($map, $groupName, $renderSvc, $path, $format, $boundsMinX, $boundsMinY, $boundsMaxX, $boundsMaxY, $layerNames, $requestId) {
//We don't use RenderTile (as it uses key parameters that are locked to serverconfig.ini), we use RenderMap instead
$env = new MgEnvelope($boundsMinX, $boundsMinY, $boundsMaxX, $boundsMaxY);

    if ($bufferPx > 0)
    {       
    $bufferPx = $this->app->config("MapGuide.XYZTileBuffer");
    $ratio = $bufferPx / self::XYZ_TILE_WIDTH;
    $dx = $boundsMaxX - $boundsMinX;
    $dy = $boundsMaxY - $boundsMinY;
    //If we have a buffer, we have to inflate the bounds by the given ratio
    $minx = $boundsMinX - ($dx * $ratio);
    $miny = $boundsMinY - ($dy * $ratio);
    $maxx = $boundsMaxX + ($dx * $ratio);
    $maxy = $boundsMaxY + ($dx * $ratio);
    $env = new MgEnvelope($minx, $miny, $maxx, $maxy);    
    }

    $strColor = $map->GetBackgroundColor();
    //Make sure the alpha component is transparent
    if (strlen($strColor) == 8) {
        $strColor = substr($strColor, 2)."00";
    } else if (strlen($strColor) == 6) {
        $strColor = $strColor."00";
    }
    if ($layerNames != NULL) {
        $layers = $map->GetLayers();
        for ($i = 0; $i < $layers->GetCount(); $i++) {
            $layer = $layers->GetItem($i);
            $layer->SetVisible(false);
        }
        foreach ($layerNames as $layerName) {
            $layer = $layers->GetItem($layerName);
            $layer->SetVisible(true);
        }
    }
    $bgColor = new MgColor($strColor);
    $tileImg = $renderSvc->RenderMap($map, null, $env, self::XYZ_TILE_WIDTH, self::XYZ_TILE_HEIGHT, $bgColor, $format, false);
    if ($bufferPx > 0)
    {
    $tileImg = $renderSvc->RenderMap($map, null, $env, self::XYZ_TILE_WIDTH + (2 * $bufferPx), self::XYZ_TILE_HEIGHT + (2 * $bufferPx), $bgColor, $format, false);
    }
    $sink = new MgByteSink($tileImg);

@jumpinjackie
Copy link
Owner

There was a change in RC3 where XYZ tiles were buffered to a configurable ratio and rendered at that size, which were then cropped down back to 256x256 (using the PHP GD extension)

This was done to eliminate any labelling/symbology artifacts at tile boundaries.

I notice at line 298, an empty string was fed to the MgByteSink.ToFile(), that's what causing the file IO exception. That should not be the case.

@RenoSun
Copy link
Author

RenoSun commented Jan 17, 2018

Hi Jackie,

I have a problem to generate XYZ tiles with 500 error again.

The request looks like following URL:
https://maps.qualicumbeach.com/qbmap/rest/library/QualicumBeach/TiledMaps/UtilityTiledMap.MapDefinition/xyz/Base%20Layer%20Group/17/20227/44818/tile.png

The UtilityTiledMap is using coordinate system (WGS84.PseudoMercator (WGS84 based Mercator (spherical formulation))).

However, the mapguide-rest only generated the .lck file as following image:
image

I am using Release 1.0 RC5.

I got following error from debug.log as following:
(11746) Checking if C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2017\www\rest/./cache/tile.png/QualicumBeach/TiledMaps/UtilityTiledMap/Base Layer Group/17/20227/44818.png exists (11746) C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2017\www\rest/./cache/tile.png/QualicumBeach/TiledMaps/UtilityTiledMap/Base Layer Group/17/20227/44818.png does not exist. Locking for writing (11746) Acquired lock for C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2017\www\rest/./cache/tile.png/QualicumBeach/TiledMaps/UtilityTiledMap/Base Layer Group/17/20227/44818.png. Checking if path exists again. (11746) Rendering tile to C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2017\www\rest/./cache/tile.png/QualicumBeach/TiledMaps/UtilityTiledMap/Base Layer Group/17/20227/44818.png (11746) Going down old code path (11746) Calc bounds from XYZ (11746) Releasing lock for C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2017\www\rest/./cache/tile.png/QualicumBeach/TiledMaps/UtilityTiledMap/Base Layer Group/17/20227/lock_44818.lck (11746) C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2017\www\rest/./cache/tile.png/QualicumBeach/TiledMaps/UtilityTiledMap/Base Layer Group/17/20227/44818.png does not exist. Locking for writing (11746) Acquired lock for C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2017\www\rest/./cache/tile.png/QualicumBeach/TiledMaps/UtilityTiledMap/Base Layer Group/17/20227/44818.png. Checking if path exists again. (11746) Rendering tile to C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2017\www\rest/./cache/tile.png/QualicumBeach/TiledMaps/UtilityTiledMap/Base Layer Group/17/20227/44818.png (11746) Going down old code path (11746) Calc bounds from XYZ

Windows Server 2016 + AIMS2017 (env)

@jumpinjackie
Copy link
Owner

Is it that particular XYZ coordinate? If you adjust X, Y, or Z by a tile or few, does it still throw http 500?

One thing I'll look at (once things have calmed down with MGOS proper) is enabling the ability to log individual tile render/request failures to log files at that location. So in your case, you'll see:

  • error_44817.log
  • error_44818.log

Which should then hopefully tell you what went wrong. As it stands I have no idea why the tile wasn't rendered. Did the server log any errors for these rendering requests?

@RenoSun
Copy link
Author

RenoSun commented Jan 18, 2018

I am using WGS84.PseudoMercator coordinator system. I am using Google Map API to request XYZ map tiles based on where I zoom or pan to.

Those are the only errors I saw on the log file... No matter what place I zoom on the map. I can simply use Google Hybrid Map with MapGuide-Rest vector tiled GeoJSON to achieve my goal.

I know you're busy. I wish I could help you. Let me know of there are anything I might be able to help you regard of MGOS.

@RenoSun
Copy link
Author

RenoSun commented Jan 18, 2018

All the tiles I requested were returned with 500 errors. I deleted the tile folders to see if it's permission issues. However, MapGuide-Rest was able to create tiled PNG folders based on XYZ, but only .Lck files been generated into the folders. Then, I scratched my head couldn't figure out what is really going on. I turned on the debug logs. It didn't show me anything other than the error logs I posted. Tiles XYZ GeoJson are working well.

@jumpinjackie
Copy link
Owner

jumpinjackie commented Jan 18, 2018

If you use Process Monitor and listen on filesystem activity on php.exe, do you see failed writes on XYZ tile images?

@RenoSun
Copy link
Author

RenoSun commented Jan 18, 2018

Thank you for you help Jackie.

The problem solved by using Process Monitor, and found access denied by C:\Windows\Temp.

I just gave IUSR the permission to modify, and the XYZ tiled was generated again!

Cheers!

@RenoSun RenoSun closed this as completed Jan 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants