| 862 | |
| 863 | // Return a simplified copy of the Entity to save space. |
| 864 | function _copyEntity(entity) { |
| 865 | const copy = utilObjectOmit(entity, ['type', 'user', 'v', 'version', 'visible']); |
| 866 | |
| 867 | // Note: the copy is no longer an osmEntity, so it might not have `tags` |
| 868 | if (copy.tags && Object.keys(copy.tags).length === 0) { |
| 869 | delete copy.tags; |
| 870 | } |
| 871 | |
| 872 | if (Array.isArray(copy.loc)) { |
| 873 | copy.loc[0] = +copy.loc[0].toFixed(6); |
| 874 | copy.loc[1] = +copy.loc[1].toFixed(6); |
| 875 | } |
| 876 | |
| 877 | const match = entity.id.match(/([nrw])-\d*/); // temporary id |
| 878 | if (match !== null) { |
| 879 | let nrw = match[1]; |
| 880 | let permID; |
| 881 | do { permID = nrw + (++nextID[nrw]); } |
| 882 | while (result.has(permID)); |
| 883 | |
| 884 | permIDs[entity.id] = permID; |
| 885 | copy.id = permID; |
| 886 | } |
| 887 | return copy; |
| 888 | } |
| 889 | |
| 890 | } |
| 891 | |