@@ -62,17 +62,19 @@ func (c Continent) HasData() bool {
62
62
63
63
// Location contains data for the location record associated with an IP address.
64
64
type Location struct {
65
- // TimeZone is the time zone associated with location, as specified by
66
- // the IANA Time Zone Database (e.g., "America/New_York")
67
- TimeZone string `json:"time_zone,omitzero" maxminddb:"time_zone"`
68
65
// Latitude is the approximate latitude of the location associated with
69
66
// the IP address. This value is not precise and should not be used to
70
- // identify a particular address or household.
71
- Latitude float64 `json:"latitude" maxminddb:"latitude"`
67
+ // identify a particular address or household. Will be nil if not present
68
+ // in the database.
69
+ Latitude * float64 `json:"latitude,omitzero" maxminddb:"latitude"`
72
70
// Longitude is the approximate longitude of the location associated with
73
71
// the IP address. This value is not precise and should not be used to
74
- // identify a particular address or household.
75
- Longitude float64 `json:"longitude" maxminddb:"longitude"`
72
+ // identify a particular address or household. Will be nil if not present
73
+ // in the database.
74
+ Longitude * float64 `json:"longitude,omitzero" maxminddb:"longitude"`
75
+ // TimeZone is the time zone associated with location, as specified by
76
+ // the IANA Time Zone Database (e.g., "America/New_York")
77
+ TimeZone string `json:"time_zone,omitzero" maxminddb:"time_zone"`
76
78
// MetroCode is a metro code for targeting advertisements.
77
79
//
78
80
// Deprecated: Metro codes are no longer maintained and should not be used.
@@ -89,6 +91,11 @@ func (l Location) HasData() bool {
89
91
return l != zeroLocation
90
92
}
91
93
94
+ // HasCoordinates returns true if both latitude and longitude are present.
95
+ func (l Location ) HasCoordinates () bool {
96
+ return l .Latitude != nil && l .Longitude != nil
97
+ }
98
+
92
99
// RepresentedCountry contains data for the represented country associated
93
100
// with an IP address. The represented country is the country represented
94
101
// by something like a military base or embassy.
@@ -342,15 +349,13 @@ type Enterprise struct {
342
349
// Continent contains data for the continent record associated with the IP
343
350
// address.
344
351
Continent Continent `json:"continent,omitzero" maxminddb:"continent"`
345
- // City contains data for the city record associated with the IP address.
346
- City EnterpriseCityRecord `json:"city,omitzero" maxminddb:"city"`
347
- // Postal contains data for the postal record associated with the IP address.
348
- Postal EnterprisePostal `json:"postal,omitzero" maxminddb:"postal"`
349
352
// Subdivisions contains data for the subdivisions associated with the IP
350
353
// address. The subdivisions array is ordered from largest to smallest. For
351
354
// instance, the response for Oxford in the United Kingdom would have England
352
355
// as the first element and Oxfordshire as the second element.
353
356
Subdivisions []EnterpriseSubdivision `json:"subdivisions,omitzero" maxminddb:"subdivisions"`
357
+ // Postal contains data for the postal record associated with the IP address.
358
+ Postal EnterprisePostal `json:"postal,omitzero" maxminddb:"postal"`
354
359
// RepresentedCountry contains data for the represented country associated
355
360
// with the IP address. The represented country is the country represented
356
361
// by something like a military base or embassy.
@@ -363,11 +368,13 @@ type Enterprise struct {
363
368
// with the IP address. This record represents the country where the ISP has
364
369
// registered the IP block and may differ from the user's country.
365
370
RegisteredCountry CountryRecord `json:"registered_country,omitzero" maxminddb:"registered_country"`
366
- // Traits contains various traits associated with the IP address
367
- Traits EnterpriseTraits `json:"traits ,omitzero" maxminddb:"traits "`
371
+ // City contains data for the city record associated with the IP address.
372
+ City EnterpriseCityRecord `json:"city ,omitzero" maxminddb:"city "`
368
373
// Location contains data for the location record associated with the IP
369
374
// address
370
375
Location Location `json:"location,omitzero" maxminddb:"location"`
376
+ // Traits contains various traits associated with the IP address
377
+ Traits EnterpriseTraits `json:"traits,omitzero" maxminddb:"traits"`
371
378
}
372
379
373
380
// HasData returns true if any GeoIP data was found for the IP in the Enterprise database.
0 commit comments