arcgis

package module
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: AGPL-3.0 Imports: 23 Imported by: 0

README

ArcGIS Go SDK

This isn't affiliated with ArcGIS or Esri.

We needed a way to write go programs against their API so we built this.

Feel free to use it.

License

GNU Affero 3.0. See LICENSE

Documentation

Index

Constants

View Source
const (
	APIErrorUnrecognized     apiErrorType = ""
	APIErrorInvalidAuthToken apiErrorType = "invalid_auth_token"
	APIErrorInvalidRequest   apiErrorType = "invalid_request"
	APIErrorNotPermitted     apiErrorType = "not_permitted"
)
View Source
const R = 6378137.0

Variables

View Source
var (
	ErrorInvalidAuthToken *apiError = &apiError{
		Code:        400,
		Description: "invalid auth token",
		Details:     []string{},
		ErrorType:   APIErrorInvalidAuthToken,
		Message:     "invalid auth token",
	}
	ErrorInvalidRefreshToken *apiError = &apiError{
		Code:        498,
		Description: "invalidated refresh_token",
		Details:     []string{},
		ErrorType:   APIErrorInvalidRequest,
		Message:     "invalidated refresh_token",
	}
	ErrorNotPermitted *apiError = &apiError{
		Code:        403,
		Description: "User does not have permissions to access this service",
		Details:     []string{},
		ErrorType:   APIErrorNotPermitted,
		Message:     "not permitted",
	}
)
View Source
var ServiceTypeNames = map[ServiceType]string{
	ServiceTypeGPServer:      "GPServer",
	ServiceTypeFeatureServer: "FeatureServer",
}

Functions

func Degrees

func Degrees(rad float64) float64

func Lat2y

func Lat2y(lat float64) float64

func LatLngToTile added in v0.0.7

func LatLngToTile(level int, lat, lng float64) (row, column int)

LatLngToTile converts GPS coordinates to ArcGIS tile coordinates

func Lon2x

func Lon2x(lon float64) float64

func MITMProxyTransport added in v0.0.7

func MITMProxyTransport() (*http.Transport, error)

func Radians

func Radians(deg float64) float64

func ServiceRootFromTenant added in v0.0.3

func ServiceRootFromTenant(base string, tenantId string) string

func X2lat

func X2lat(x float64) float64

func Y2lat

func Y2lat(y float64) float64

Types

type AdminInfo added in v0.0.6

type AdminInfo struct {
	CurrentVersion string `json:"currentversion"`
}

type ArcGIS

type ArcGIS struct {
	AccountID string
	// contains filtered or unexported fields
}

Root structure for an instance of the ArcGIS API

func NewArcGIS added in v0.0.3

func NewArcGIS(ctx context.Context) (*ArcGIS, error)

func NewArcGISAuth added in v0.0.7

func NewArcGISAuth(ctx context.Context, auth Authenticator) (*ArcGIS, error)

func NewArcGISTransport added in v0.0.7

func NewArcGISTransport(ctx context.Context, host *string, auth Authenticator, transport *http.Transport) (*ArcGIS, error)

func (*ArcGIS) AdminInfo added in v0.0.6

func (ag *ArcGIS) AdminInfo(ctx context.Context, serviceName string, serviceType ServiceType) (*AdminInfo, error)

func (*ArcGIS) GeocodeFindAddressCandidates added in v0.0.7

func (ag *ArcGIS) GeocodeFindAddressCandidates(ctx context.Context, address string) (*response.GeocodeFindAddressCandidates, error)

func (*ArcGIS) Info

func (ag *ArcGIS) Info(ctx context.Context) (*RestInfo, error)

func (*ArcGIS) MapServices added in v0.0.7

func (ag *ArcGIS) MapServices(ctx context.Context) ([]MapService, error)

func (*ArcGIS) NewServiceFeature added in v0.0.7

func (ag *ArcGIS) NewServiceFeature(ctx context.Context, name string, url url.URL) (*ServiceFeature, error)

func (*ArcGIS) PermissionList added in v0.0.6

func (ag *ArcGIS) PermissionList(ctx context.Context, serviceName string, serviceType ServiceType) (*response.PermissionSlice, error)

func (*ArcGIS) PortalsGlobal added in v0.0.7

func (ag *ArcGIS) PortalsGlobal(ctx context.Context) (*response.Portal, error)

func (*ArcGIS) PortalsSelf added in v0.0.3

func (ag *ArcGIS) PortalsSelf(ctx context.Context) (*response.Portal, error)

func (*ArcGIS) Query added in v0.0.7

func (ag *ArcGIS) Query(ctx context.Context, service string, layer_id uint, query *Query) (*QueryResult, error)

func (*ArcGIS) QueryCount added in v0.0.3

func (ag *ArcGIS) QueryCount(ctx context.Context, service string, layer_id uint) (*QueryResultCount, error)

func (*ArcGIS) QueryRaw added in v0.0.7

func (ag *ArcGIS) QueryRaw(ctx context.Context, service string, layer_id uint, query *Query) ([]byte, error)

func (*ArcGIS) Search added in v0.0.3

func (ag *ArcGIS) Search(ctx context.Context, query string) (*SearchResponse, error)

func (*ArcGIS) SearchInAccount added in v0.0.7

func (ag *ArcGIS) SearchInAccount(ctx context.Context, query string) (*SearchResponse, error)

func (*ArcGIS) Services added in v0.0.3

func (ag *ArcGIS) Services(ctx context.Context) ([]*ServiceFeature, error)

func (*ArcGIS) WebhookList added in v0.0.4

func (ag *ArcGIS) WebhookList(ctx context.Context, serviceName string, serviceType ServiceType) (*WebhookSlice, error)

type AuthInfo

type AuthInfo struct {
	// contains filtered or unexported fields
}

Basic information about the REST API itself

type Authenticator added in v0.0.3

type Authenticator interface {
	// contains filtered or unexported methods
}

type AuthenticatorOAuth added in v0.0.3

type AuthenticatorOAuth struct {
	AccessToken         string
	AccessTokenExpires  time.Time
	RefreshToken        string
	RefreshTokenExpires time.Time
}

type AuthenticatorToken added in v0.0.3

type AuthenticatorToken struct {
	Token string
}

Authentication by adding in a 'token=?' query argument to requests

type AuthenticatorUsernamePassword added in v0.0.7

type AuthenticatorUsernamePassword struct {
	AccessToken        string
	AccessTokenExpires time.Time
	Password           string
	Username           string
}

type CodeWrapper

type CodeWrapper string

func (*CodeWrapper) UnmarshalJSON

func (c *CodeWrapper) UnmarshalJSON(data []byte) (err error)

type CodedValue

type CodedValue struct {
	Code CodeWrapper
	Name string
}

type DefaultValueWrapper

type DefaultValueWrapper string

func (*DefaultValueWrapper) UnmarshalJSON

func (d *DefaultValueWrapper) UnmarshalJSON(data []byte) (err error)

type Domain

type Domain struct {
	CodedValues []CodedValue
	MergePolicy string
	Name        string
	SplitPolicy string
	Type        string
}

type ErrorFromAPI

type ErrorFromAPI struct {
	Code        int      `json:"code"`
	Details     []string `json:"details"`
	Error       string   `json:"error"`
	Description string   `json:"error_description"`
	Message     string   `json:"message"`
}

Errors at the API level

func (ErrorFromAPI) HasDetail added in v0.0.7

func (e ErrorFromAPI) HasDetail(s string) bool

type ErrorResponse added in v0.0.4

type ErrorResponse struct {
	Error ErrorFromAPI `json:"error"`
}

func (ErrorResponse) AsError added in v0.0.4

func (e ErrorResponse) AsError(ctx context.Context) apiError

type Feature

type Feature struct {
	Attributes map[string]any
	Geometry   json.RawMessage
}

type Field

type Field struct {
	Alias        string
	DefaultValue *DefaultValueWrapper
	Domain       *Domain
	Length       int
	Name         string
	SQLType      string
	Type         string
}

type LayerFeature added in v0.0.3

type LayerFeature struct {
	ID                uint
	Name              string
	ParentLayerID     int
	DefaultVisibility bool
	SubLayerIDs       *string
	MinScale          int
	MaxScale          int
	Type              string
	GeometryType      string
}

Feature Server details

type MapService added in v0.0.7

type MapService struct {
	ID    string
	Name  string
	Title string
	URL   string
}

func (MapService) Tile added in v0.0.7

func (ms MapService) Tile(ctx context.Context, ag *ArcGIS, level, row, column int) ([]byte, error)

func (MapService) TileGPS added in v0.0.7

func (ms MapService) TileGPS(ctx context.Context, ag *ArcGIS, level int, lat, lng float64) ([]byte, error)

type Position

type Position struct {
	Latitude  float64
	Longitude float64
}

func GeometryToPosition

func GeometryToPosition(x, y float64) Position

type Query

type Query struct {
	Limit             int
	ObjectIDs         string
	OutFields         string
	ResultRecordCount uint
	ResultOffset      uint
	SpatialReference  string // Should eventually make an enum, probably
	Where             string
}

func NewQuery

func NewQuery() *Query

type QueryResult

type QueryResult struct {
	Features          []Feature
	Fields            []Field
	GeometryType      string
	GlobalIDFieldName string
	ObjectIdFieldName string
	SpatialReference  SpatialReference
	UniqueIdField     UniqueIdField
}

type QueryResultCount

type QueryResultCount struct {
	Count int
}

type ResourceInfo added in v0.0.3

type ResourceInfo struct {
	CurrentVersion        float32 `json:"currentVersion"`
	MapName               string  `json:"mapName"`
	SupportsDynamicLayers bool    `json:"supportsDynamicLayers"`
	//Layers []LayerResource
	//Tables TableResource
	//SpatialReference SpatialReference `json:"spatialReference"`
	SingleFusedMapCache bool `json:"singleFusedMapCache"`
}

type ResponseServiceInfo added in v0.0.7

type ResponseServiceInfo struct {
	CurrentVersion float64
	Services       []ServiceListing
}

type ResponseURLs added in v0.0.7

type ResponseURLs struct {
	URLs ServerURLCollection `json:"urls"`
}

type RestInfo

type RestInfo struct {
	CurrentVersion  float64
	FullVersion     string
	OwningSystemUrl string
	OwningTenant    string
	AuthInfo        AuthInfo
}

type SearchResponse added in v0.0.3

type SearchResponse struct {
	Total     int            `json:"total"`
	Start     int            `json:"start"`
	Num       int            `json:"num"`
	NextStart int            `json:"nextStart"`
	Results   []SearchResult `json:"results"`
}

type SearchResult added in v0.0.3

type SearchResult struct {
	ID                      string                  `json:"id"`
	Owner                   string                  `json:"owner"`
	OrgID                   string                  `json:"orgId"`
	Created                 int64                   `json:"created"`
	IsOrgItem               bool                    `json:"isOrgItem"`
	Modified                int64                   `json:"modified"`
	Guid                    *string                 `json:"guid"`
	Name                    string                  `json:"name"`
	Title                   string                  `json:"title"`
	Type                    string                  `json:"type"`
	TypeKeywords            []string                `json:"typeKeywords"`
	Description             string                  `json:"description"`
	Tags                    []string                `json:"tags"`
	Snippet                 string                  `json:"snippet"`
	Thumbnail               string                  `json:"thumbnail"`
	Documentation           *string                 `json:"documentation"`
	Extent                  [][]float32             `json:"extent"`
	Categories              []string                `json:"categories"`
	SpatialReference        string                  `json:"spatialReference"`
	AccessInformation       string                  `json:"accessInformation"`
	Classification          *string                 `json:"classification"`
	LicenseInfo             string                  `json:"licenseInfo"`
	Culture                 string                  `json:"culture"`
	Properties              *map[string]interface{} `json:"properties"`
	AdvancedSettings        *string                 `json:"advancedSettings"`
	URL                     string                  `json:"url"`
	ProxyFilter             *string                 `json:"proxyFilter"`
	Access                  string                  `json:"access"`
	Size                    int                     `json:"size"`
	SubInfo                 int                     `json:"subInfo"`
	AppCategories           []string                `json:"appCategories"`
	Industries              []string                `json:"industries"`
	Languages               []string                `json:"languages"`
	LargeThumbnail          *string                 `json:"largeThumbnail"`
	Banner                  *string                 `json:"banner"`
	Screenshots             []string                `json:"screenshots"`
	Listed                  bool                    `json:"listed"`
	NumComments             int                     `json:"numComments"`
	NumRatings              int                     `json:"numRatings"`
	AvgRating               int                     `json:"avgRating"`
	NumViews                int                     `json:"numViews"`
	ScoreCompleteness       int                     `json:"scoreCompleteness"`
	GroupDesignations       *string                 `json:"groupDesignations"`
	ApiToken1ExpirationDate int                     `json:"apiToken1ExpirationDate"`
	ApiToken2ExpirationDate int                     `json:"apiToken2ExpirationDate"`
	LastViewed              int64                   `json:"lastViewed"`
}

type ServerURL added in v0.0.7

type ServerURL struct {
	HTTPS []string `json:"https"`
}

type ServerURLCollection added in v0.0.7

type ServerURLCollection struct {
	Features  ServerURL `json:"features"`
	Insights  ServerURL `json:"insights"`
	Notebooks ServerURL `json:"notebooks"`
	Tiles     ServerURL `json:"tiles"`
}

type ServiceFeature added in v0.0.7

type ServiceFeature struct {
	Layers         []response.Layer
	Name           string
	MaxRecordCount uint
	URL            url.URL
	// contains filtered or unexported fields
}

type ServiceListing

type ServiceListing struct {
	Name string
	Type string
	URL  string
}

Listing of available services

type ServiceType added in v0.0.4

type ServiceType int
const (
	ServiceTypeGPServer ServiceType = iota
	ServiceTypeFeatureServer
)

type SpatialReference

type SpatialReference struct {
	LatestWKID int `json:"wkid"`
	WKID       int `json:"latestWkid"`
}

type Table

type Table struct {
	ID                int
	Name              string
	ParentLayerID     int
	DefaultVisibility bool
	SubLayerIDs       *string
	MinScale          int
	MaxScale          int
}

type UniqueIdField

type UniqueIdField struct {
	Name               string
	IsSystemMaintained bool
}

Query endpoint

type Usage

type Usage struct {
	// Units used on the last request
	LastRequest int
	// The maximum units we can use in a minute
	MaxPerMinute int
	// The amount used in the current minute
	ThisMinute int
}

type Webhook added in v0.0.4

type Webhook struct {
	Name string
}

type WebhookListResponse added in v0.0.4

type WebhookListResponse struct {
	Webhooks []Webhook `json:"webhooks"`
}

type WebhookSlice added in v0.0.7

type WebhookSlice = []Webhook

Directories

Path Synopsis
cmd
schema-to-sql command
counts command
exporter command
map-tile command
service-request command
trap-data command
version command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL