(json)
| 19 | |
| 20 | |
| 21 | function encode(json) { |
| 22 | if (json.UTF8Encoding) { |
| 23 | return; |
| 24 | } |
| 25 | |
| 26 | json.UTF8Encoding = true; |
| 27 | |
| 28 | var features = json.features; |
| 29 | |
| 30 | features.forEach(function (feature){ |
| 31 | var encodeOffsets = feature.geometry.encodeOffsets = []; |
| 32 | var coordinates = feature.geometry.coordinates; |
| 33 | if (feature.geometry.type === 'MultiPolygon') { |
| 34 | coordinates.forEach(function (polygon, idx1){ |
| 35 | encodeOffsets[idx1] = []; |
| 36 | polygon.forEach(function (coordinate, idx2) { |
| 37 | coordinates[idx1][idx2] = encodeRing( |
| 38 | coordinate, encodeOffsets[idx1][idx2] = [] |
| 39 | ); |
| 40 | }); |
| 41 | }); |
| 42 | } |
| 43 | else if (feature.geometry.type == 'Polygon' |
| 44 | || feature.geometry.type == 'MultiLineString' |
| 45 | ) { |
| 46 | coordinates.forEach(function (coordinate, idx){ |
| 47 | coordinates[idx] = encodeRing( |
| 48 | coordinate, encodeOffsets[idx] = [] |
| 49 | ); |
| 50 | }); |
| 51 | } |
| 52 | else if (feature.geometry.type === 'LineString') { |
| 53 | feature.geometry.coordinates = encodeRing(coordinates, encodeOffsets) |
| 54 | } |
| 55 | }); |
| 56 | |
| 57 | return json; |
| 58 | } |
| 59 | |
| 60 | function encodeRing(coordinates, encodeOffsets) { |
| 61 |
no test coverage detected
searching dependent graphs…