arcgis

package module
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: AGPL-3.0 Imports: 24 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 (
	TileSize    = 256       // Standard tile size in pixels
	EarthRadius = 6378137.0 // Earth's radius in meters (Web Mercator)
	OriginShift = math.Pi * EarthRadius
)
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 CalculateTileCount added in v0.0.9

func CalculateTileCount(bounds Envelope, zoomLevel int) (tilesX, tilesY, totalTiles int)

Calculate number of tiles needed to cover the bounds at a given zoom level

func Degrees

func Degrees(rad float64) float64

func Lat2y

func Lat2y(lat float64) float64

func LatLngToTile added in v0.0.7

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

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 MetersToPixels added in v0.0.9

func MetersToPixels(mx, my float64, zoom int) (px, py float64)

Convert Web Mercator meters to pixel coordinates

func MetersToTile added in v0.0.9

func MetersToTile(mx, my float64, zoom int) (tx, ty int)

Convert Web Mercator meters to tile coordinates

func Radians

func Radians(deg float64) float64

func Resolution added in v0.0.9

func Resolution(zoom int) float64

Calculate resolution (meters per pixel) at given zoom level

func ScaleToZoom added in v0.0.9

func ScaleToZoom(scale float64, dpi float64) int

If you have scale instead of zoom, convert it

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) GeometryProject added in v0.0.9

func (ag *ArcGIS) GeometryProject(ctx context.Context, geometries []response.Geometry) (*response.Project, error)

This isn't tested

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

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) 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) ServiceByName added in v0.0.9

func (ag *ArcGIS) ServiceByName(ctx context.Context, name string) (*ServiceFeature, error)

func (*ArcGIS) ServiceByURL added in v0.0.9

func (ag *ArcGIS) ServiceByURL(ctx context.Context, url url.URL) (*ServiceFeature, 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
}

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 Envelope added in v0.0.9

type Envelope struct {
	SpatialReference SpatialReference `json:"spatialReference"`
	XMax             float64          `json:"xmax"`
	YMax             float64          `json:"ymax"`
	XMin             float64          `json:"xmin"`
	YMin             float64          `json:"ymin"`
}

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"`
}

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 Field

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

type MapService added in v0.0.7

type MapService struct {
	ID       string
	Metadata *response.MapServiceMetadata
	Name     string
	Title    string
	URL      url.URL
	// contains filtered or unexported fields
}

func (MapService) PopulateMetadata added in v0.0.9

func (ms MapService) PopulateMetadata(ctx context.Context) (*response.MapServiceMetadata, error)

func (MapService) Tile added in v0.0.7

func (ms MapService) Tile(ctx context.Context, level, row, column uint) ([]byte, error)

func (MapService) TileGPS added in v0.0.7

func (ms MapService) TileGPS(ctx context.Context, level uint, lat, lng float64) ([]byte, error)

type Point added in v0.0.9

type Point struct {
	SpatialReference string
	X                float64 `json:"x"`
	Y                float64 `json:"y"`
}

func ExtentSize added in v0.0.9

func ExtentSize(e Envelope) Point

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 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 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 ServiceFeature added in v0.0.7

type ServiceFeature struct {
	Name     string
	Metadata *response.FeatureService
	URL      url.URL
	// contains filtered or unexported fields
}

func (*ServiceFeature) LayerMetadata added in v0.0.9

func (sf *ServiceFeature) LayerMetadata(ctx context.Context, layer_id uint) (*response.LayerMetadata, error)

func (*ServiceFeature) Layers added in v0.0.7

func (sf *ServiceFeature) Layers(ctx context.Context) ([]response.Layer, error)

func (*ServiceFeature) PopulateMetadata added in v0.0.9

func (sf *ServiceFeature) PopulateMetadata(ctx context.Context) (*response.FeatureService, error)

func (*ServiceFeature) Query added in v0.0.9

func (sf *ServiceFeature) Query(ctx context.Context, layer_id uint, query Query) (*response.QueryResult, error)

func (*ServiceFeature) QueryCount added in v0.0.9

func (sf *ServiceFeature) QueryCount(ctx context.Context, layer_id uint) (*response.QueryResultCount, error)

func (*ServiceFeature) QueryEnvelope added in v0.0.9

func (sf *ServiceFeature) QueryEnvelope(ctx context.Context, layer_id uint, point Point) (*response.QueryResult, error)

func (*ServiceFeature) QueryIDs added in v0.0.9

func (sf *ServiceFeature) QueryIDs(ctx context.Context, layer_id uint, query Query) (*response.QueryResultOnlyIDs, error)

func (*ServiceFeature) QueryRaw added in v0.0.9

func (sf *ServiceFeature) QueryRaw(ctx context.Context, layer_id uint, query Query) ([]byte, error)

func (*ServiceFeature) QueryWithin added in v0.0.9

func (sf *ServiceFeature) QueryWithin(ctx context.Context, layer_id uint, point Point) (*response.QueryResult, error)

func (*ServiceFeature) SchemaRaw added in v0.0.9

func (fs *ServiceFeature) SchemaRaw(ctx context.Context, layer_id uint) ([]byte, error)

type ServiceListing

type ServiceListing struct {
	Name string
	Type string
	URL  string
}

type ServiceType added in v0.0.4

type ServiceType int
const (
	ServiceTypeGPServer ServiceType = iota
	ServiceTypeFeatureServer
)

type SpatialReference

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

type TimeInfo added in v0.0.9

type TimeInfo struct {
	TimeExtent               []int64        `json:"timeExtent"`
	TimeReference            *TimeReference `json:"timeReference,omitempty"`
	TimeRelation             string         `json:"timeRelation"`
	DefaultTimeInterval      int            `json:"defaultTimeInterval"`
	DefaultTimeIntervalUnits string         `json:"defaultTimeIntervalUnits"`
	DefaultTimeWindow        int            `json:"defaultTimeWindow"`
	HasLiveData              bool           `json:"hasLiveData"`
	LiveModeOffsetDirection  string         `json:"liveModeOffsetDirection"`
}

type TimeReference added in v0.0.9

type TimeReference struct {
	TimeZone               string `json:"timeZone"`
	RespectsDaylightSaving bool   `json:"respectsDaylightSaving"`
}

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
dump-map-layer command
exporter command
layer-to-csv 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