(feature)
| 32 | * ``` |
| 33 | */ |
| 34 | export var toGeoJSON = function (feature) { |
| 35 | if (!feature) { |
| 36 | return feature; |
| 37 | } |
| 38 | if (['FeatureCollection', 'Feature', 'Geometry'].indexOf(feature.type) != -1 || feature.coordinates) { |
| 39 | return feature; |
| 40 | } |
| 41 | if (feature.toGeoJSON) { |
| 42 | return feature.toGeoJSON(); |
| 43 | } |
| 44 | if (feature instanceof L.LatLngBounds) { |
| 45 | return L.rectangle(feature).toGeoJSON(); |
| 46 | } |
| 47 | if (feature instanceof L.Bounds) { |
| 48 | return L.rectangle([ |
| 49 | [feature.getTopLeft().x, feature.getTopLeft().y], |
| 50 | [feature.getBottomRight().x, feature.getBottomRight().y] |
| 51 | ]).toGeoJSON(); |
| 52 | } |
| 53 | return new GeoJSONFormat().toGeoJSON(feature); |
| 54 | }; |
| 55 | |
| 56 | /** |
| 57 | * @function toSuperMapGeometry |
no test coverage detected