-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Showing
3 changed files
with
68 additions
and
53 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
65 changes: 65 additions & 0 deletions
65
app/src/main/java/org/blitzortung/android/data/provider/standard/JsonRpcData.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,65 @@ | ||
package org.blitzortung.android.data.provider.standard | ||
|
||
import org.blitzortung.android.data.Parameters | ||
import org.blitzortung.android.data.provider.GLOBAL_REGION | ||
import org.blitzortung.android.data.provider.LOCAL_REGION | ||
import org.blitzortung.android.jsonrpc.JsonRpcClient | ||
import org.json.JSONObject | ||
import java.net.URL | ||
|
||
class JsonRpcData( | ||
private val client: JsonRpcClient, | ||
private val serviceUrl: URL, | ||
) { | ||
|
||
fun requestData(parameters: Parameters) : JSONObject { | ||
val intervalDuration = parameters.intervalDuration | ||
val intervalOffset = parameters.intervalOffset | ||
val rasterBaselength = parameters.rasterBaselength | ||
val countThreshold = parameters.countThreshold | ||
val region = parameters.region | ||
val localReference = parameters.localReference | ||
|
||
return when (region) { | ||
GLOBAL_REGION -> { | ||
with( | ||
client.call( | ||
serviceUrl, | ||
"get_global_strikes_grid", | ||
intervalDuration, | ||
rasterBaselength, | ||
intervalOffset, | ||
countThreshold | ||
) | ||
) { | ||
put("y1", 0.0) | ||
put("x0", 0.0) | ||
} | ||
} | ||
LOCAL_REGION -> { | ||
client.call( | ||
serviceUrl, | ||
"get_local_strikes_grid", | ||
localReference!!.x, | ||
localReference.y, | ||
rasterBaselength, | ||
intervalDuration, | ||
intervalOffset, | ||
countThreshold | ||
) | ||
} | ||
else -> { | ||
client.call( | ||
serviceUrl, | ||
"get_strikes_grid", | ||
intervalDuration, | ||
rasterBaselength, | ||
intervalOffset, | ||
region, | ||
countThreshold | ||
) | ||
} | ||
} | ||
|
||
} | ||
} |
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