MCPcopy Create free account
hub / github.com/MapServer/MapServer / force_to_polygons

Function force_to_polygons

mapmssql2008.c:949–991  ·  view source on GitHub ↗

point -> reject */ line -> reject */ polygon -> lines of linear rings */

Source from the content-addressed store, hash-verified

947/* line -> reject */
948/* polygon -> lines of linear rings */
949static int force_to_polygons(char *wkb, shapeObj *shape)
950{
951 int offset = 0;
952 int pt_offset;
953 int ngeoms;
954 int t, u, v;
955 int type, nrings, npoints;
956 lineObj line = {0, NULL};
957
958 shape->type = MS_SHAPE_NULL; /* nothing in it */
959
960 memcpy(&ngeoms, &wkb[5], 4);
961 offset = 9; /* were the first geometry is */
962 for(t = 0; t < ngeoms; t++) {
963 memcpy(&type, &wkb[offset + 1], 4); /* type of this geometry */
964
965 if(type == 3) {
966 /* polygon */
967 shape->type = MS_SHAPE_POLYGON;
968
969 memcpy(&nrings, &wkb[offset + 5], 4); /* num rings */
970 /* add a line for each polygon ring */
971 pt_offset = 0;
972 offset += 9; /* now points at 1st linear ring */
973 for(u=0; u < nrings; u++) {
974 /* for each ring, make a line */
975 memcpy(&npoints, &wkb[offset], 4); /* num points */
976 line.numpoints = npoints;
977 line.point = (pointObj*) msSmallMalloc(sizeof(pointObj) * npoints);
978 for(v=0; v < npoints; v++) {
979 memcpy(&line.point[v].x, &wkb[offset + 4 + (16 * v)], 8);
980 memcpy(&line.point[v].y, &wkb[offset + 4 + (16 * v) + 8], 8);
981 }
982 /* make offset point to next linear ring */
983 msAddLine(shape, &line);
984 msFree(line.point);
985 offset += 4 + 16 * npoints;
986 }
987 }
988 }
989
990 return MS_SUCCESS;
991}
992
993/* if there is any polygon in wkb, return force_polygon */
994/* if there is any line in wkb, return force_line */

Callers 2

dont_forceFunction · 0.85

Calls 3

msSmallMallocFunction · 0.85
msAddLineFunction · 0.85
msFreeFunction · 0.85

Tested by

no test coverage detected