Permalink
Browse files

Added initial hooks into WMS. Removed unused format parameter from ms…

…MVTWriteTile().
  • Loading branch information...
sdlime committed Feb 9, 2017
1 parent 6773281 commit d542d215039596646d34bb5ba7d214e92a86f9e4
Showing with 34 additions and 8 deletions.
  1. +19 −4 mapmvt.c
  2. +2 −3 mapservutil.c
  3. +13 −1 mapwms.c
@@ -28,6 +28,7 @@
*****************************************************************************/
#include "mapserver.h"
#include "maptile.h"
#ifdef USE_PBF
#include "vector_tile.pb-c.h"
@@ -73,7 +74,7 @@ static int mvtTransformShape(shapeObj *shape, rectObj *extent, int layer_type, i
shape->line[i].numpoints = outj;
}
msComputeBounds(shape); // might need to limit this to just valid parts...
msComputeBounds(shape); /* TODO: might need to limit this to just valid parts... */
return (shape->numlines == 0)?MS_FAILURE:MS_SUCCESS; /* sucess if at least one line */
}
@@ -274,7 +275,21 @@ static void freeMvtTile( VectorTile__Tile *mvt_tile ) {
free(mvt_tile->layers);
}
int msMVTWriteTile( mapObj *map, outputFormatObj *format, int sendheaders ) {
int msMVTSetup(mapObj *map)
{
/* Ensure all the LAYERs have a projection. */
if( msMapSetLayerProjections(map) != 0 ) return(MS_FAILURE);
/* Set output projection to spherical Mercator. */
if( msLoadProjectionString(&(map->projection), SPHEREMERC_PROJ4) != 0 ) {
msSetError(MS_CGIERR, "Unable to load projection string.", "msMVTSetup()");
return MS_FAILURE;
}
return MS_SUCCESS;
}
int msMVTWriteTile( mapObj *map, int sendheaders ) {
int iLayer,retcode=MS_SUCCESS;
unsigned len;
void *buf;
@@ -455,9 +470,9 @@ int msPopulateRendererVTableMVT(rendererVTableObj * renderer) {
return MS_FAILURE;
}
int msMVTWriteFromQuery( mapObj *map, outputFormatObj *format, int sendheaders ) {
int msMVTWriteTile( mapObj *map, int sendheaders ) {
msSetError(MS_MISCERR, "Vector Tile support is not available.",
"msMVTWriteFromQuery()");
"msMVTWriteTile()");
return MS_FAILURE;
}
#endif
@@ -43,8 +43,6 @@ static char *modeStrings[23] = {"BROWSE","ZOOMIN","ZOOMOUT","MAP","LEGEND","LEGE
"INDEXQUERY","TILE","OWS", "WFS", "MAPLEGEND", "MAPLEGENDICON"
};
int msCGIWriteLog(mapservObj *mapserv, int show_error)
{
FILE *stream;
@@ -1517,7 +1515,8 @@ int msCGIDispatchImageRequest(mapservObj *mapserv)
msTileSetExtent(mapserv);
if(!strcmp(MS_IMAGE_MIME_TYPE(mapserv->map->outputformat), "application/x-protobuf")) {
if((status = msMVTWriteTile(mapserv->map, mapserv->map->outputformat, mapserv->sendheaders)) != MS_SUCCESS) return MS_FAILURE;
// if((status = msMVTSetup(mapserv->map)) != MS_SUCCESS) return MS_FAILURE;
if((status = msMVTWriteTile(mapserv->map, mapserv->sendheaders)) != MS_SUCCESS) return MS_FAILURE;
return MS_SUCCESS;
}
@@ -3668,8 +3668,20 @@ int msWMSGetMap(mapObj *map, int nVersion, char **names, char **values, int nume
msDrawLayer(map, GET_LAYER(map, i), img);
}
} else
} else {
/* intercept requests for Mapbox vector tiles */
if(!strcmp(MS_IMAGE_MIME_TYPE(map->outputformat), "application/x-protobuf")) {
int status=0;
if((status = msMVTSetup(map)) != MS_SUCCESS) return MS_FAILURE;
if((status = msMVTWriteTile(map, MS_TRUE)) != MS_SUCCESS) return MS_FAILURE;
return MS_SUCCESS;
}
img = msDrawMap(map, MS_FALSE);
}
if (img == NULL)
return msWMSException(map, nVersion, NULL, wms_exception_format);

0 comments on commit d542d21

Please sign in to comment.