Documentation
¶
Overview ¶
Package tmmaps provides Türkmenistan administrative boundary GeoJSON data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidCoordinate indicates latitude or longitude outside its valid range. ErrInvalidCoordinate = errors.New("invalid coordinate") // ErrUnknownRegion indicates that no boundary exists for a requested welaýat slug. ErrUnknownRegion = errors.New("unknown welaýat") // ErrRegionNotFound indicates a coordinate outside the available welaýat boundaries. ErrRegionNotFound = errors.New("coordinate is outside available boundaries") )
var ErrInvalidRadius = errors.New("invalid radius")
ErrInvalidRadius indicates a radius that is not finite and greater than zero.
var ErrInvalidSearchOptions = errors.New("invalid search options")
ErrInvalidSearchOptions indicates an invalid limit or settlement type.
var ErrNoSettlementCoordinates = errors.New("no settlement coordinates available")
ErrNoSettlementCoordinates indicates that the bundled dataset contains no settlement with usable coordinates.
Functions ¶
Types ¶
type NearbySettlement ¶ added in v0.3.0
type NearbySettlement struct {
Settlement
DistanceKM float64 `json:"distance_km"`
}
NearbySettlement contains a settlement and its distance from the requested coordinate in kilometres.
func WithinRadius ¶ added in v0.3.0
func WithinRadius(latitude, longitude, radiusKM float64) ([]NearbySettlement, error)
WithinRadius returns settlements no farther than radiusKM from latitude and longitude. Results are ordered from nearest to farthest.
type NearestResult ¶ added in v0.3.0
type NearestResult struct {
Settlement
DistanceKM float64 `json:"distance_km"`
}
NearestResult contains the nearest settlement and its great-circle distance from the requested coordinate in kilometres.
func Nearest ¶ added in v0.3.0
func Nearest(latitude, longitude float64) (*NearestResult, error)
Nearest finds the closest known settlement to latitude and longitude using coordinates from the embedded dataset. DistanceKM is calculated with the Haversine formula.
type Region ¶
type Region struct {
Slug string `json:"slug"`
NameTM string `json:"name_tm"`
NameEN string `json:"name_en"`
NameRU string `json:"name_ru"`
Type string `json:"type"`
ParentSlug string `json:"parent_slug"`
Latitude *float64 `json:"latitude"`
Longitude *float64 `json:"longitude"`
VerificationStatus string `json:"verification_status"`
}
func FindRegion ¶
type SearchOptions ¶ added in v0.3.0
SearchOptions controls settlement search filtering. A zero Limit means no limit. RegionSlug uses the full region slug, for example turkmenistan-mary.
type Settlement ¶ added in v0.3.0
type Settlement struct {
Slug string `json:"slug"`
NameTM string `json:"name_tm"`
NameEN string `json:"name_en"`
NameRU string `json:"name_ru"`
Type string `json:"type"`
Latitude *float64 `json:"latitude"`
Longitude *float64 `json:"longitude"`
Region *SettlementRegion `json:"region,omitempty"`
}
Settlement is a named populated place in the bundled geographic dataset. Latitude and Longitude are nil when coordinates are not available.
func Search ¶
func Search(query string) ([]Settlement, error)
Search finds settlements whose Turkmen, English, or Russian name contains query. Matching is case-insensitive and uses only the embedded dataset.
func SearchWithOptions ¶ added in v0.3.0
func SearchWithOptions(query string, options SearchOptions) ([]Settlement, error)
SearchWithOptions finds settlements by name and applies result, type, and region filters. Matching is case-insensitive and Unicode-normalized.
type SettlementRegion ¶ added in v0.3.0
type SettlementRegion struct {
Slug string `json:"slug"`
NameTM string `json:"name_tm"`
NameEN string `json:"name_en"`
NameRU string `json:"name_ru"`
Type string `json:"type"`
}
SettlementRegion identifies the top-level welaýat or independent city that contains a settlement. It is nil when the source record has no region assigned.