Skip to content

Commit

Permalink
Added initial hooks into WMS. Removed unused format parameter from ms…
Browse files Browse the repository at this point in the history
…MVTWriteTile().
  • Loading branch information
sdlime committed Feb 9, 2017
1 parent 6773281 commit d542d21
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
23 changes: 19 additions & 4 deletions mapmvt.c
Expand Up @@ -28,6 +28,7 @@
*****************************************************************************/

#include "mapserver.h"
#include "maptile.h"

#ifdef USE_PBF
#include "vector_tile.pb-c.h"
Expand Down Expand Up @@ -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 */
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
5 changes: 2 additions & 3 deletions mapservutil.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
14 changes: 13 additions & 1 deletion mapwms.c
Expand Up @@ -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);

Expand Down

0 comments on commit d542d21

Please sign in to comment.