Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagohm committed Feb 3, 2024
2 parents 8293ebf + e196692 commit de96a26
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 46 deletions.
4 changes: 2 additions & 2 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import org.springframework.boot.gradle.tasks.bundling.BootJar

plugins {
kotlin("jvm")
id("org.springframework.boot") version "3.2.1"
id("org.springframework.boot") version "3.2.2"
id("io.spring.dependency-management") version "1.1.4"
kotlin("plugin.spring")
kotlin("kapt")
Expand Down Expand Up @@ -43,7 +43,7 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-undertow")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
kapt("org.springframework:spring-context-indexer:6.1.2")
kapt("org.springframework:spring-context-indexer:6.1.3")
testImplementation(project(":nebulosa-skycatalog-stellarium"))
testImplementation(project(":nebulosa-test"))
}
Expand Down
12 changes: 6 additions & 6 deletions api/src/test/kotlin/SimbadDatabaseGenerator.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import de.siegmar.fastcsv.reader.CommentStrategy
import de.siegmar.fastcsv.reader.CsvReader
import de.siegmar.fastcsv.reader.NamedCsvRow
import de.siegmar.fastcsv.reader.NamedCsvRecord
import nebulosa.adql.*
import nebulosa.api.atlas.SimbadDatabaseWriter
import nebulosa.api.atlas.SimbadEntity
Expand Down Expand Up @@ -49,25 +49,25 @@ object SimbadDatabaseGenerator {

@JvmStatic private val CALDWELL = resource("caldwell.csv")!!
.use { stream ->
CSV_READER.build(InputStreamReader(stream, Charsets.UTF_8))
CSV_READER.ofCsvRecord(InputStreamReader(stream, Charsets.UTF_8))
.associate { it.getField(1).ifEmpty { it.getField(2) } to it.getField(0) }
}

@JvmStatic private val BENNETT = resource("bennett.csv")!!
.use { stream ->
CSV_READER.build(InputStreamReader(stream, Charsets.UTF_8))
CSV_READER.ofCsvRecord(InputStreamReader(stream, Charsets.UTF_8))
.associate { it.getField(1) to it.getField(0) }
}

@JvmStatic private val DUNLOP = resource("dunlop.csv")!!
.use { stream ->
CSV_READER.build(InputStreamReader(stream, Charsets.UTF_8))
CSV_READER.ofCsvRecord(InputStreamReader(stream, Charsets.UTF_8))
.associate { it.getField(1) to it.getField(0) }
}

@JvmStatic private val HERSHEL = resource("hershel.csv")!!
.use { stream ->
CSV_READER.build(InputStreamReader(stream, Charsets.UTF_8))
CSV_READER.ofCsvRecord(InputStreamReader(stream, Charsets.UTF_8))
.associate { it.getField(1) to it.getField(0) }
}

Expand Down Expand Up @@ -225,7 +225,7 @@ object SimbadDatabaseGenerator {
}

@JvmStatic
private fun List<NamedCsvRow>.parse(entities: MutableList<SimbadEntity>): List<SimbadEntity> {
private fun List<NamedCsvRecord>.parse(entities: MutableList<SimbadEntity>): List<SimbadEntity> {
var writeCount = 0

for (row in this) {
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

buildscript {
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.0-Beta2")
classpath("org.jetbrains.kotlin:kotlin-allopen:2.0.0-Beta2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.0-Beta3")
classpath("org.jetbrains.kotlin:kotlin-allopen:2.0.0-Beta3")
classpath("com.adarshr:gradle-test-logger-plugin:4.0.0")
classpath("io.objectbox:objectbox-gradle-plugin:3.7.1")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class AstapPlateSolver(path: Path) : PlateSolver {
header.add(NOAOExt.CD2_1, cd21)
header.add(NOAOExt.CD2_2, cd22)

val solution = PlateSolution(true, crota2.deg, cdelt2.deg, crval1.deg, crval2.deg, width.deg, height.deg, header = header)
val solution = PlateSolution(true, crota2.deg, cdelt2.deg, crval1.deg, crval2.deg, width.deg, height.deg)

LOG.info("astap solved. calibration={}", solution)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package nebulosa.astap.star.detection

import de.siegmar.fastcsv.reader.NamedCsvReader
import de.siegmar.fastcsv.reader.CommentStrategy
import de.siegmar.fastcsv.reader.CsvReader
import nebulosa.common.process.ProcessExecutor
import nebulosa.log.loggerFor
import nebulosa.star.detection.ImageStar
Expand Down Expand Up @@ -35,7 +36,7 @@ class AstapStarDetector(path: Path) : StarDetector<Path> {

try {
csvFile.inputStream().use {
for (record in CSV_READER.build(InputStreamReader(it, Charsets.UTF_8))) {
for (record in CSV_READER.ofNamedCsvRecord(InputStreamReader(it, Charsets.UTF_8))) {
detectedStars.add(
Star(
record.getField("x").toDouble(),
Expand All @@ -58,10 +59,10 @@ class AstapStarDetector(path: Path) : StarDetector<Path> {

@JvmStatic private val LOG = loggerFor<AstapStarDetector>()

@JvmStatic private val CSV_READER = NamedCsvReader.builder()
@JvmStatic private val CSV_READER = CsvReader.builder()
.fieldSeparator(',')
.quoteCharacter('"')
.commentCharacter('#')
.skipComments(true)
.commentStrategy(CommentStrategy.SKIP)
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package nebulosa.retrofit

import de.siegmar.fastcsv.reader.NamedCsvReader
import de.siegmar.fastcsv.reader.NamedCsvRow
import de.siegmar.fastcsv.reader.CsvReader
import de.siegmar.fastcsv.reader.NamedCsvRecord
import okhttp3.ResponseBody
import retrofit2.Converter
import java.io.InputStreamReader

data class CSVRecordListConverter(private val reader: NamedCsvReader.NamedCsvReaderBuilder) : Converter<ResponseBody, List<NamedCsvRow>> {
data class CSVRecordListConverter(private val reader: CsvReader.CsvReaderBuilder) : Converter<ResponseBody, List<NamedCsvRecord>> {

override fun convert(value: ResponseBody): List<NamedCsvRow> {
override fun convert(value: ResponseBody): List<NamedCsvRecord> {
val charset = value.contentType()?.charset() ?: Charsets.UTF_8
return value.use { reader.build(InputStreamReader(value.byteStream(), charset)).toList() }
return value.use { reader.ofNamedCsvRecord(InputStreamReader(value.byteStream(), charset)).toList() }
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package nebulosa.retrofit

import de.siegmar.fastcsv.reader.NamedCsvReader
import de.siegmar.fastcsv.reader.CsvReader
import retrofit2.Converter
import retrofit2.Retrofit
import java.lang.reflect.Type

data class CSVRecordListConverterFactory(private val reader: NamedCsvReader.NamedCsvReaderBuilder) : Converter.Factory() {
data class CSVRecordListConverterFactory(private val reader: CsvReader.CsvReaderBuilder) : Converter.Factory() {

override fun responseBodyConverter(
type: Type,
Expand Down
4 changes: 2 additions & 2 deletions nebulosa-simbad/src/main/kotlin/nebulosa/simbad/Simbad.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package nebulosa.simbad

import de.siegmar.fastcsv.reader.NamedCsvRow
import de.siegmar.fastcsv.reader.NamedCsvRecord
import okhttp3.FormBody
import retrofit2.Call
import retrofit2.http.Body
Expand All @@ -9,5 +9,5 @@ import retrofit2.http.POST
interface Simbad {

@POST("simbad/sim-tap/sync")
fun query(@Body body: FormBody): Call<List<NamedCsvRow>>
fun query(@Body body: FormBody): Call<List<NamedCsvRecord>>
}
18 changes: 9 additions & 9 deletions nebulosa-simbad/src/main/kotlin/nebulosa/simbad/SimbadService.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package nebulosa.simbad

import de.siegmar.fastcsv.reader.NamedCsvReader
import de.siegmar.fastcsv.reader.NamedCsvRow
import de.siegmar.fastcsv.reader.CommentStrategy
import de.siegmar.fastcsv.reader.CsvReader
import de.siegmar.fastcsv.reader.NamedCsvRecord
import nebulosa.adql.*
import nebulosa.log.loggerFor
import nebulosa.math.*
Expand Down Expand Up @@ -31,11 +32,11 @@ class SimbadService(

private val service by lazy { retrofit.create<Simbad>() }

fun query(query: Query): Call<List<NamedCsvRow>> {
fun query(query: Query): Call<List<NamedCsvRecord>> {
return query("$query")
}

fun query(query: String): Call<List<NamedCsvRow>> {
fun query(query: String): Call<List<NamedCsvRecord>> {
val body = FormBody.Builder()
.add("request", "doQuery")
.add("lang", "adql")
Expand All @@ -49,9 +50,8 @@ class SimbadService(
}

fun search(query: Query): List<SimbadEntry> {
val rows = query(query).execute().body()
if (rows.isNullOrEmpty()) return emptyList()
val res = ArrayList<SimbadEntry>(rows.size)
val rows = query(query).execute().body() ?: return emptyList()
val res = ArrayList<SimbadEntry>()
val currentTime = UTC.now()

fun matchName(name: String): String? {
Expand Down Expand Up @@ -160,11 +160,11 @@ class SimbadService(

@JvmStatic private val LOG = loggerFor<SimbadService>()

@JvmStatic private val CSV_READER = NamedCsvReader.builder()
@JvmStatic private val CSV_READER = CsvReader.builder()
.fieldSeparator('\t')
.quoteCharacter('"')
.commentCharacter('#')
.skipComments(true)
.commentStrategy(CommentStrategy.SKIP)

@JvmStatic private val BASIC_TABLE = From("basic").alias("b")
@JvmStatic private val FLUX_TABLE = From("allfluxes").alias("f")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package nebulosa.skycatalog.hyg

import de.siegmar.fastcsv.reader.NamedCsvReader
import de.siegmar.fastcsv.reader.CommentStrategy
import de.siegmar.fastcsv.reader.CsvReader
import nebulosa.math.deg
import nebulosa.math.hours
import nebulosa.math.kms
Expand All @@ -23,7 +24,7 @@ class HygDatabase : SkyCatalog<HygEntry>(118005) {
fun load(stream: InputStream) {
clear()

val reader = CSV_READER.build(InputStreamReader(stream, Charsets.UTF_8))
val reader = CSV_READER.ofNamedCsvRecord(InputStreamReader(stream, Charsets.UTF_8))

val names = ArrayList<String>(7)
val currentTime = UTC.now()
Expand Down Expand Up @@ -79,10 +80,10 @@ class HygDatabase : SkyCatalog<HygEntry>(118005) {

companion object {

@JvmStatic private val CSV_READER = NamedCsvReader.builder()
@JvmStatic private val CSV_READER = CsvReader.builder()
.fieldSeparator(',')
.quoteCharacter('"')
.commentCharacter('#')
.skipComments(true)
.commentStrategy(CommentStrategy.SKIP)
}
}
4 changes: 2 additions & 2 deletions nebulosa-vizier/src/main/kotlin/nebulosa/vizier/VizierTAP.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package nebulosa.vizier

import de.siegmar.fastcsv.reader.NamedCsvRow
import de.siegmar.fastcsv.reader.NamedCsvRecord
import okhttp3.FormBody
import retrofit2.Call
import retrofit2.http.Body
Expand All @@ -9,5 +9,5 @@ import retrofit2.http.POST
interface VizierTAP {

@POST("TAPVizieR/tap/sync")
fun query(@Body body: FormBody): Call<List<NamedCsvRow>>
fun query(@Body body: FormBody): Call<List<NamedCsvRecord>>
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package nebulosa.vizier

import de.siegmar.fastcsv.reader.NamedCsvReader
import de.siegmar.fastcsv.reader.NamedCsvRow
import de.siegmar.fastcsv.reader.CommentStrategy
import de.siegmar.fastcsv.reader.CsvReader
import de.siegmar.fastcsv.reader.NamedCsvRecord
import nebulosa.retrofit.CSVRecordListConverterFactory
import nebulosa.retrofit.RetrofitService
import okhttp3.FormBody
Expand All @@ -23,7 +24,7 @@ class VizierTAPService(url: String = "") : RetrofitService(url.ifBlank { URL })

private val service by lazy { retrofit.create<VizierTAP>() }

fun query(query: String): Call<List<NamedCsvRow>> {
fun query(query: String): Call<List<NamedCsvRecord>> {
val body = FormBody.Builder()
.add("request", "doQuery")
.add("lang", "adql")
Expand All @@ -38,10 +39,10 @@ class VizierTAPService(url: String = "") : RetrofitService(url.ifBlank { URL })

const val URL = "http://tapvizier.cds.unistra.fr/"

@JvmStatic private val CSV_READER = NamedCsvReader.builder()
@JvmStatic private val CSV_READER = CsvReader.builder()
.fieldSeparator(',')
.quoteCharacter('"')
.commentCharacter('#')
.skipComments(true)
.commentStrategy(CommentStrategy.SKIP)
}
}
4 changes: 2 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ dependencyResolutionManagement {
library("netty-transport", "io.netty:netty-transport:4.1.106.Final")
library("netty-codec", "io.netty:netty-codec:4.1.106.Final")
library("xml", "com.fasterxml:aalto-xml:1.3.2")
library("csv", "de.siegmar:fastcsv:2.2.2")
library("csv", "de.siegmar:fastcsv:3.0.0")
library("apache-lang3", "org.apache.commons:commons-lang3:3.14.0")
library("apache-codec", "commons-codec:commons-codec:1.16.0")
library("apache-collections", "org.apache.commons:commons-collections4:4.4")
library("oshi", "com.github.oshi:oshi-core:6.4.10")
library("oshi", "com.github.oshi:oshi-core:6.4.11")
library("timeshape", "net.iakovlev:timeshape:2022g.17")
library("jna", "net.java.dev.jna:jna:5.14.0")
library("kotest-assertions-core", "io.kotest:kotest-assertions-core:5.8.0")
Expand Down

0 comments on commit de96a26

Please sign in to comment.