diff --git a/Makefile b/Makefile index 356f875..5e6b8f5 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,10 @@ generate: unlocode in/airports.dat in/countries.dat in/continents.geojson $(LOCO --airports in/airports.dat \ --continents in/continents.geojson \ --countries in/countries.dat \ - --in in/$(UNLOCODEPREFIX)\ UNLOCODE\ CodeListPart1.csv,in/$(UNLOCODEPREFIX)\ UNLOCODE\ CodeListPart2.csv,in/$(UNLOCODEPREFIX)\ UNLOCODE\ CodeListPart3.csv \ + --in in/$(UNLOCODEPREFIX)\ UNLOCODE\ CodeListPart1.csv \ + --in in/$(UNLOCODEPREFIX)\ UNLOCODE\ CodeListPart2.csv \ + --in in/$(UNLOCODEPREFIX)\ UNLOCODE\ CodeListPart3.csv \ + --in override.csv \ --subdiv in/$(UNLOCODEPREFIX)\ SubdivisionCodes.csv \ --out $(LOCODEDB) diff --git a/internal/parsers/db/put.go b/internal/parsers/db/put.go index cc6f57a..c2ee780 100644 --- a/internal/parsers/db/put.go +++ b/internal/parsers/db/put.go @@ -26,7 +26,7 @@ func (db *CsvDB) Put(data []Data) error { newRecordsLocode := make([][]string, 0, len(data)) newRecordsCountry := make([][]string, 0, 300) - uniqueKeys := make(map[string]struct{}, len(data)) + uniqueKeys := make(map[string]int, len(data)) uniqueKeysCountry := make(map[string]struct{}, 300) for _, row := range data { @@ -36,12 +36,14 @@ func (db *CsvDB) Put(data []Data) error { // Calculate a unique index for each key keyString := key.CountryCode().String() + key.LocationCode().String() - if _, exists := uniqueKeys[keyString]; exists { - continue // Skip duplicates + if index, exists := uniqueKeys[keyString]; exists { + newRecordsLocode[index][5] = strconv.FormatFloat(float64(rec.Point.Latitude), 'f', -1, 32) + newRecordsLocode[index][6] = strconv.FormatFloat(float64(rec.Point.Longitude), 'f', -1, 32) + continue } // Mark the index as seen - uniqueKeys[keyString] = struct{}{} + uniqueKeys[keyString] = len(newRecordsLocode) newRecord := []string{ keyString, diff --git a/internal/parsers/table/csv/table.go b/internal/parsers/table/csv/table.go index bc53056..cf3abba 100644 --- a/internal/parsers/table/csv/table.go +++ b/internal/parsers/table/csv/table.go @@ -68,7 +68,7 @@ func New(prm Prm, opts ...Option) *Table { } return &Table{ - paths: append(o.extraPaths, prm.Path), + paths: append([]string{prm.Path}, o.extraPaths...), mode: o.mode, subDivPath: prm.SubDivPath, }