| 806 | /* polys-> treat ring like line and pull out the consituent points */ |
| 807 | |
| 808 | static int force_to_points(char *wkb, shapeObj *shape) |
| 809 | { |
| 810 | /* we're going to make a 'line' for each entity (point, line or ring) in the geom collection */ |
| 811 | |
| 812 | int offset = 0; |
| 813 | int pt_offset; |
| 814 | int ngeoms; |
| 815 | int t, u, v; |
| 816 | int type, nrings, npoints; |
| 817 | lineObj line = {0, NULL}; |
| 818 | |
| 819 | shape->type = MS_SHAPE_NULL; /* nothing in it */ |
| 820 | |
| 821 | memcpy(&ngeoms, &wkb[5], 4); |
| 822 | offset = 9; /* were the first geometry is */ |
| 823 | for(t=0; t < ngeoms; t++) { |
| 824 | memcpy(&type, &wkb[offset + 1], 4); /* type of this geometry */ |
| 825 | |
| 826 | if(type == 1) { |
| 827 | /* Point */ |
| 828 | shape->type = MS_SHAPE_POINT; |
| 829 | line.numpoints = 1; |
| 830 | line.point = (pointObj *) msSmallMalloc(sizeof(pointObj)); |
| 831 | |
| 832 | memcpy(&line.point[0].x, &wkb[offset + 5], 8); |
| 833 | memcpy(&line.point[0].y, &wkb[offset + 5 + 8], 8); |
| 834 | offset += 5 + 16; |
| 835 | msAddLine(shape, &line); |
| 836 | msFree(line.point); |
| 837 | } else if(type == 2) { |
| 838 | /* Linestring */ |
| 839 | shape->type = MS_SHAPE_POINT; |
| 840 | |
| 841 | memcpy(&line.numpoints, &wkb[offset+5], 4); /* num points */ |
| 842 | line.point = (pointObj *) msSmallMalloc(sizeof(pointObj) * line.numpoints); |
| 843 | for(u = 0; u < line.numpoints; u++) { |
| 844 | memcpy( &line.point[u].x, &wkb[offset+9 + (16 * u)], 8); |
| 845 | memcpy( &line.point[u].y, &wkb[offset+9 + (16 * u)+8], 8); |
| 846 | } |
| 847 | offset += 9 + 16 * line.numpoints; /* length of object */ |
| 848 | msAddLine(shape, &line); |
| 849 | msFree(line.point); |
| 850 | } else if(type == 3) { |
| 851 | /* Polygon */ |
| 852 | shape->type = MS_SHAPE_POINT; |
| 853 | |
| 854 | memcpy(&nrings, &wkb[offset+5],4); /* num rings */ |
| 855 | /* add a line for each polygon ring */ |
| 856 | pt_offset = 0; |
| 857 | offset += 9; /* now points at 1st linear ring */ |
| 858 | for(u = 0; u < nrings; u++) { |
| 859 | /* for each ring, make a line */ |
| 860 | memcpy(&npoints, &wkb[offset], 4); /* num points */ |
| 861 | line.numpoints = npoints; |
| 862 | line.point = (pointObj *) msSmallMalloc(sizeof(pointObj)* npoints); |
| 863 | /* point struct */ |
| 864 | for(v = 0; v < npoints; v++) |
| 865 | { |
no test coverage detected