Skip to content

Commit

Permalink
Adapt to RadioID API change, remove -tg_source option, since it no lo…
Browse files Browse the repository at this point in the history
…nger applies.
  • Loading branch information
jancona committed Aug 22, 2024
1 parent 4604f52 commit f3c2f76
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 76 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,6 @@ In the case of analog FM zone names, all repeaters go into the specified zone, s
Radius for proximity search (default 25)
-tg
Only include DMR repeaters that have talkgroups defined (default true)
-tg_source string
One of ('most' 'rfinder' 'details').
RadioID has two fields that may contain talkgroup info, 'details' and 'rfinder'.
By default dmrfill uses the data from whichever field has the most talkgroups defined.
Selecting 'rfinder' or 'details' uses the named field. (default "most")
-units string
Distance units for proximity search, one of ('miles' 'km') (default "miles")
-v verbose logging
Expand Down
13 changes: 0 additions & 13 deletions dmrfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ var (
nameLength int
open bool
onAir bool
tgSource string
location string
radius float64
radiusUnits string
Expand All @@ -110,11 +109,6 @@ func init() {
flag.IntVar(&nameLength, "name_lim", 16, "Length limit for generated names")
flag.BoolVar(&open, "open", true, "Only include open repeaters")
flag.BoolVar(&onAir, "on_air", true, "Only include on-air repeaters")
flag.StringVar(&tgSource, "tg_source", "most",
`One of ('most' 'rfinder' 'details').
RadioID has two fields that may contain talkgroup info, 'details' and 'rfinder'.
By default dmrfill uses the data from whichever field has the most talkgroups defined.
Selecting 'rfinder' or 'details' uses the named field.`)
flag.StringVar(&location, "loc", "", "Center location for proximity search, e.g. 'Bangor, ME', 'München'")
flag.Float64Var(&radius, "radius", 25, "Radius for proximity search")
flag.StringVar(&radiusUnits, "units", "miles", "Distance units for proximity search, one of ('miles' 'km')")
Expand Down Expand Up @@ -457,13 +451,6 @@ func parseArguments() (io.ReadCloser, io.WriteCloser) {
fatal("power must be one of (Min Low Mid High Max)")
}

switch tgSource {
case "most", "rfinder", "details":
// good
default:
fatal("tg_source must be one of (most rfinder details)")
}

if radius <= 0.0 {
fatal("radius must be greater than zero")
}
Expand Down
78 changes: 20 additions & 58 deletions radioID.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,40 +116,15 @@ func QueryRadioID(filters filterFlags) (*RadioIDResults, error) {
}
if matchesAll {
// Parse LastUpdated
m := lastUpdatedRegex.FindAllStringSubmatch(r.Rfinder, -1)
m := lastUpdatedRegex.FindAllStringSubmatch(r.Details, -1)
if len(m) > 0 {
r.LastUpdated, err = time.Parse("2006-01-02 15:04:05", m[0][1])
if err != nil {
return nil, fmt.Errorf("error parsing LastUpdated %s: %v", m[0][1], err)
}
}
// Parse talk groups from rfinder field
var rfinderTGs, detailsTGs []TalkGroup
m = talkGroupRegex.FindAllStringSubmatch(r.Rfinder, -1)
for _, s := range m {
id, err := strconv.Atoi(s[2])
if err != nil {
return nil, fmt.Errorf("error parsing TalkGroup ID %s: %v", s[2], err)
}
ts, err := strconv.Atoi(s[1])
if err != nil {
return nil, fmt.Errorf("error parsing TalkGroup TimeSlot %s: %v", s[1], err)
}
name := s[4]
if len(name) > nameLength {
name = name[:nameLength]
}
if ts == 1 || ts == 2 {
rfinderTGs = append(rfinderTGs, TalkGroup{
Number: id,
TimeSlot: ts,
Name: name,
})
} else {
logVerbose("Skipping rfinder talkgroup #%d: %s, bad timeslot %d", id, name, ts)
}
}
// Parse talk groups from details field
var detailsTGs []TalkGroup
m = talkGroupRegex.FindAllStringSubmatch(r.Details, -1)
for _, s := range m {
id, err := strconv.Atoi(s[2])
Expand All @@ -174,22 +149,9 @@ func QueryRadioID(filters filterFlags) (*RadioIDResults, error) {
logVerbose("Skipping details talkgroup #%d: %s, bad timeslot %d", id, name, ts)
}
}
logVerbose("Count - rfinderTGs: %d,\tdetailsTGs: %d", len(rfinderTGs), len(detailsTGs))
// logVerbose("rfinderTGs: %#v", rfinderTGs)
logVerbose("Count - detailsTGs: %d", len(detailsTGs))
// logVerbose("detailsTGs: %#v", detailsTGs)

switch tgSource {
case "most":
if len(rfinderTGs) >= len(detailsTGs) {
r.TalkGroups = rfinderTGs
} else {
r.TalkGroups = detailsTGs
}
case "rfinder":
r.TalkGroups = rfinderTGs
case "details":
r.TalkGroups = detailsTGs
}
r.TalkGroups = detailsTGs
if !talkgroupsRequired || len(r.TalkGroups) > 0 {
newResults = append(newResults, r)
} else {
Expand Down Expand Up @@ -220,22 +182,22 @@ type RadioIDResults struct {
}

type RadioIDResult struct {
Callsign string `json:"callsign"` // "KC1FRJ"
City string `json:"city"` // "Presque Isle"
ColorCode int `json:"color_code"` // 12
Country string `json:"country"` // "United States"
Details string `json:"details"` // "Time Slot #1 - Group Call 759 = SKYWARN<br>Time Slot #1 - Group Call 9998 = Parrot*<br>Time Slot #1 - Group Call 1 = World Wide*<br>Time Slot #1 - Group Call 13 = WW English*<br>Time Slot #1 - Group Call 3 = North America<br>Time Slot #1 - Group Call 3172 = Northeast<br>Time Slot #1 - Group Call 1 = World Wide*<br>Time Slot #1 - Group Call 13 = WW English*<br>Time Slot #1 - Group Call 3 = North America<br>Time Slot #1 - Group Call 3172 = Northeast<br>Time Slot #1 - Group Call 310 = TAC310*<br>Time Slot #1 - Group Call 311 = TAC311*<br>Time Slot #1 - Group Call 113 = UA English 1*<br>Time Slot #1 - Group Call 123 = UA English 2*<br>Time Slot #1 - Group Call 8801 = NETAC 1*<br>------------------------------------<br>Time Slot #2 - Group Call 8802 = NETAC 2*<br>Time Slot #2 - Group Call 3181 = New England Wide<br>Time Slot #2 - Group Call 8 = Region North<br>Time Slot #2 - Group Call 3133 = New Hampshire*<br>Time Slot #2 - Group Call 3123 = ME Statewide<br>Time Slot #1 - Group Call 3029 = New Brunswick<br>Time Slot #2 - Group Call 9 = Local Site<br><br>* PTT Activated<br><br>You Must Have [ARS] Disabled Within Your Radio<br> <br>Contact: Dave, KQ1L<br>Email: [email protected]<br>Website: http://nedecn.org<br>"
Frequency string `json:"frequency"` // "145.18000"
ID int `json:"id"` // 310198
IPSCNetwork string `json:"ipsc_network"` // "NEDECN"
Offset string `json:"offset"` // "-0.600"
Rfinder string `json:"rfinder"` // "IPSC Network:NEDECN - Color Code:12 - Assigned:Peer - TS Linked:TS1 TS2 - Operator:KC1FRJ<br>Time Slot # 1 - Group Call 1 = World Wide*<br>Time Slot # 1 - Group Call 3 = North America<br>Time Slot # 1 - Group Call 13 = WW English*<br>Time Slot # 1 - Group Call 113 = UA English 1*<br>Time Slot # 1 - Group Call 123 = UA English 2*<br>Time Slot # 1 - Group Call 310 = TAC310*<br>Time Slot # 1 - Group Call 311 = TAC311*<br>Time Slot # 1 - Group Call 759 = SKYWARN<br>Time Slot # 1 - Group Call 3029 = New Brunswick<br>Time Slot # 1 - Group Call 3172 = Northeast<br>Time Slot # 1 - Group Call 8801 = NETAC 1*<br>Time Slot # 1 - Group Call 9998 = Parrot*<br>Time Slot # 2 - Group Call 8 = Region North<br>Time Slot # 2 - Group Call 9 = Local Site<br>Time Slot # 2 - Group Call 3123 = ME Statewide<br>Time Slot # 2 - Group Call 3133 = New Hampshire*<br>Time Slot # 2 - Group Call 3181 = New England Wide<br>Time Slot # 2 - Group Call 8802 = NETAC 2*<br><br>Last Update: 2024-06-24 21:06:51"
State string `json:"state"` // "Maine"
Trustee string `json:"trustee"` // "KC1FRJ"
TSLinked string `json:"ts_linked"` // "TS1 TS2"
LastUpdated time.Time
Band string
TalkGroups []TalkGroup
Callsign string `json:"callsign"` // "KC1FRJ"
City string `json:"city"` // "Presque Isle"
ColorCode int `json:"color_code"` // 12
Country string `json:"country"` // "United States"
Details string `json:"details"` // "Time Slot #1 - Group Call 759 = SKYWARN\u003Cbr\u003ETime Slot #1 - Group Call 9998 = Parrot*\u003Cbr\u003ETime Slot #1 - Group Call 1 = World Wide*\u003Cbr\u003ETime Slot #1 - Group Call 13 = WW English*\u003Cbr\u003ETime Slot #1 - Group Call 3 = North America\u003Cbr\u003ETime Slot #1 - Group Call 3172 = Northeast\u003Cbr\u003ETime Slot #1 - Group Call 310 = TAC310*\u003Cbr\u003ETime Slot #1 - Group Call 311 = TAC311*\u003Cbr\u003ETime Slot #1 - Group Call 113 = UA English 1*\u003Cbr\u003ETime Slot #1 - Group Call 123 = UA English 2*\u003Cbr\u003ETime Slot #1 - Group Call 8801 = NETAC 1*\u003Cbr\u003E------------------------------------\u003Cbr\u003ETime Slot #2 - Group Call 8802 = NETAC 2*\u003Cbr\u003ETime Slot #2 - Group Call 3181 = New England Wide\u003Cbr\u003ETime Slot #2 - Group Call 8 = Region North\u003Cbr\u003ETime Slot #2 - Group Call 3133 = NH Statewide\u003Cbr\u003ETime Slot #2 - Group Call 3123 = ME Statewide\u003Cbr\u003ETime Slot #1 - Group Call 3029 = New Brunswick\u003Cbr\u003ETime Slot #2 - Group Call 9 = Local Site\u003Cbr\u003E\u003Cbr\u003E* PTT Activated\u003Cbr\u003E\u003Cbr\u003EYou Must Have [ARS] Disabled Within Your Radio\u003Cbr\u003EContact: Dave, KQ1L\u003Cbr\u003EEmail: [email protected]\u003Cbr\u003EWebsite: http://nedecn.org"
Frequency string `json:"frequency"` // "145.18000"
ID int `json:"id"` // 310198
IPSCNetwork string `json:"ipsc_network"` // "NEDECN"
Offset string `json:"offset"` // "-0.600"
RfinderDetails int `json:"rfinder_details"` // 0
State string `json:"state"` // "Maine"
Trustee string `json:"trustee"` // "KC1FRJ"
TSLinked string `json:"ts_linked"` // "TS1 TS2"
LastUpdated time.Time
Band string
TalkGroups []TalkGroup
}

func (r RadioIDResult) GetCallsign() string {
Expand Down

0 comments on commit f3c2f76

Please sign in to comment.