-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6acd35a
commit 367cb3d
Showing
2 changed files
with
80 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
app/src/test/java/org/scottishtecharmy/soundscape/StreetPreviewTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.scottishtecharmy.soundscape | ||
|
||
import com.squareup.moshi.Moshi | ||
import org.junit.Assert | ||
import org.junit.Test | ||
import org.scottishtecharmy.soundscape.geojsonparser.geojson.FeatureCollection | ||
import org.scottishtecharmy.soundscape.geojsonparser.geojson.GeoMoshi | ||
import org.scottishtecharmy.soundscape.geojsonparser.geojson.LngLatAlt | ||
import org.scottishtecharmy.soundscape.utils.getNearestRoad | ||
import org.scottishtecharmy.soundscape.utils.getRoadsFeatureCollectionFromTileFeatureCollection | ||
import org.scottishtecharmy.soundscape.utils.traceLineString | ||
|
||
class StreetPreviewTest { | ||
|
||
@Test | ||
fun streetPreviewTest1() { | ||
// simple first test to move along a road from start to finish | ||
val moshi = GeoMoshi.registerAdapters(Moshi.Builder()).build() | ||
val featureCollectionTest = moshi.adapter(FeatureCollection::class.java) | ||
.fromJson(GeoJsonDataReal.featureCollectionJsonRealSoundscapeGeoJson) | ||
val roadFeatureCollectionTest = getRoadsFeatureCollectionFromTileFeatureCollection( | ||
featureCollectionTest!!) | ||
val nearestRoadTest = getNearestRoad( | ||
LngLatAlt(-2.693002695425122,51.43938442591545), | ||
roadFeatureCollectionTest | ||
) | ||
val nearestRoadString = moshi.adapter(FeatureCollection::class.java).toJson(nearestRoadTest) | ||
// copy and paste into GeoJSON.io | ||
println("Nearest road/linestring $nearestRoadString") | ||
val roadTrace = traceLineString(nearestRoadTest, 30.0) | ||
val roadTraceString = moshi.adapter(FeatureCollection::class.java).toJson(roadTrace) | ||
// copy and paste into GeoJSON.io | ||
println("Road trace: $roadTraceString") | ||
} | ||
} | ||
|