Skip to content

Commit

Permalink
fix broken tests due to enum issues and parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
jillesvangurp committed Jan 11, 2021
1 parent 19da2b4 commit a65e347
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/commonMain/kotlin/com/jillesvangurp/geo/GeoGeometry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
@file:Suppress("MemberVisibilityCanBePrivate")

package com.jillesvangurp.geo

import kotlin.math.*
Expand Down Expand Up @@ -1058,7 +1060,7 @@ class GeoGeometry {
*/

fun toJson(point: DoubleArray): String {
return if (point.size == 0) {
return if (point.isEmpty()) {
"[]"
} else {
"[" + point[0] + ','.toString() + point[1] + "]"
Expand Down
27 changes: 19 additions & 8 deletions src/commonMain/kotlin/com/jillesvangurp/geo/geojson.kt
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,25 @@ data class FeatureCollection(val features: List<Feature>, val bbox: BoundingBox?
*
* Note, the names are camel case in the spec and the enum name matches that.
*/
enum class GeometryType(val geometryClass: KClass<*>) {
Point(PointGeometry::class),
MultiPoint(MultiPointGeometry::class),
LineString(LineStringGeometry::class),
MultiLineString(MultiLineStringGeometry::class),
Polygon(PolygonGeometry::class),
MultiPolygon(MultiPolygonGeometry::class),
GeometryCollection(GeometryCollection::class);
enum class GeometryType() {

Point,
MultiPoint,
LineString,
MultiLineString,
Polygon,
MultiPolygon,
GeometryCollection;

fun clazz() : KClass<*> = when(this) {
Point -> PointGeometry::class
MultiPoint -> MultiPointGeometry::class
LineString -> LineStringGeometry::class
MultiLineString -> MultiLineStringGeometry::class
Polygon -> PolygonGeometry::class
MultiPolygon -> MultiPolygonGeometry::class
GeometryCollection -> GeometryCollection::class
}
}

data class PointGeometry(val coordinates: PointCoordinates?, val bbox: BoundingBox? = null) : Geometry {
Expand Down

0 comments on commit a65e347

Please sign in to comment.