handlers

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalyseHandler

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

AnalyseHandler handles image analysis requests (EXIF extraction + FOV calculation)

func NewAnalyseHandler

func NewAnalyseHandler(maxUploadSize int64) *AnalyseHandler

NewAnalyseHandler creates a new analyse handler

func (*AnalyseHandler) ServeHTTP

func (h *AnalyseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP godoc

@Summary		Analyse image EXIF and calculate FOV
@Description	Extracts camera information from EXIF data and calculates field of view. Returns recommended scale parameters for use with the offline Astrometry.net plate-solving engine. This is a fast operation (< 1 second) that does NOT perform plate-solving.
@Tags			Analysis
@Accept			multipart/form-data
@Produce		json
@Param			image	formData	file				true	"Image file (JPG, JPEG, PNG with EXIF)"
@Success		200		{object}	AnalyseResponse		"Analysis complete"
@Failure		400		{object}	AnalyseResponse		"Bad request"
@Failure		405		{object}	AnalyseResponse		"Method not allowed"
@Failure		413		{object}	AnalyseResponse		"File too large"
@Router			/analyse [post]

type AnalyseResponse

type AnalyseResponse struct {
	Success      bool     `json:"success"`
	Make         string   `json:"make,omitempty"`
	Model        string   `json:"model,omitempty"`
	FocalLength  float64  `json:"focal_length,omitempty"`
	SensorName   string   `json:"sensor_name,omitempty"`
	DetectedFrom string   `json:"detected_from,omitempty"`
	FOV          *FOVData `json:"fov,omitempty"`
	ScaleLow     float64  `json:"scale_low,omitempty"`
	ScaleHigh    float64  `json:"scale_high,omitempty"`
	ScaleUnits   string   `json:"scale_units,omitempty"`
	HasEXIF      bool     `json:"has_exif"`
	Error        string   `json:"error,omitempty"`
}

AnalyseResponse represents the image analysis response

type AstrometryClient

type AstrometryClient interface {
	Solve(ctx context.Context, imagePath string, opts *client.SolveOptions) (*client.Result, error)
}

AstrometryClient interface for testing

type FOVData

type FOVData struct {
	WidthDegrees  float64 `json:"width_degrees"`
	HeightDegrees float64 `json:"height_degrees"`
	WidthArcmin   float64 `json:"width_arcmin"`
	HeightArcmin  float64 `json:"height_arcmin"`
	DiagonalDeg   float64 `json:"diagonal_degrees"`
}

FOVData represents field of view information

type HealthHandler

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

HealthHandler handles health check requests

func NewHealthHandler

func NewHealthHandler() *HealthHandler

NewHealthHandler creates a new health handler

func (*HealthHandler) ServeHTTP

func (h *HealthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP godoc

@Summary		Health check
@Description	Returns server health status and uptime
@Tags			Health
@Produce		json
@Success		200	{object}	HealthResponse	"Server is healthy"
@Failure		405	{string}	string			"Method not allowed"
@Router			/health [get]

type HealthResponse

type HealthResponse struct {
	Status  string  `json:"status"`
	Uptime  float64 `json:"uptime_seconds"`
	Version string  `json:"version"`
}

HealthResponse represents the health check response

type MockAstroClient

type MockAstroClient struct {
	SolveFunc func(ctx context.Context, imagePath string, opts *client.SolveOptions) (*client.Result, error)
}

MockAstroClient mocks the astrometry client for testing

func (*MockAstroClient) Solve

func (m *MockAstroClient) Solve(ctx context.Context, imagePath string, opts *client.SolveOptions) (*client.Result, error)

type SolveHandler

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

SolveHandler handles plate-solving requests

func NewSolveHandler

func NewSolveHandler(c AstrometryClient, maxUploadSize int64) *SolveHandler

NewSolveHandler creates a new solve handler

func (*SolveHandler) ServeHTTP

func (h *SolveHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP godoc

@Summary		Plate-solve an astronomical image using offline Astrometry.net engine
@Description	Performs plate-solving using the offline Astrometry.net solving engine to determine celestial coordinates and orientation. Recommended: First call /analyse to get optimal scale parameters for 3-5x faster solving.
@Tags			Solving
@Accept			multipart/form-data
@Produce		json
@Param			image				formData	file			true	"Image file (JPG, JPEG, PNG, FITS, FIT)"
@Param			scale_low			formData	number			false	"Lower bound of image scale"
@Param			scale_high			formData	number			false	"Upper bound of image scale"
@Param			scale_units			formData	string			false	"Units for scale bounds (degwidth, arcminwidth, arcsecperpix)"	default(arcminwidth)
@Param			downsample_factor	formData	int				false	"Downsample factor (higher = faster but less accurate)"	default(2)
@Param			depth_low			formData	int				false	"Minimum number of quads to try"	default(10)
@Param			depth_high			formData	int				false	"Maximum number of quads to try"	default(20)
@Param			ra					formData	number			false	"Right Ascension hint in degrees (J2000)"
@Param			dec					formData	number			false	"Declination hint in degrees (J2000)"
@Param			radius				formData	number			false	"Search radius in degrees (requires ra/dec)"
@Param			keep_temp_files		formData	boolean			false	"Preserve temporary files for debugging"	default(false)
@Success		200					{object}	SolveResponse	"Solve complete (check solved field)"
@Failure		400					{object}	SolveResponse	"Bad request"
@Failure		405					{object}	SolveResponse	"Method not allowed"
@Failure		413					{object}	SolveResponse	"File too large"
@Failure		500					{object}	SolveResponse	"Internal server error"
@Router			/solve [post]

type SolveRequest

type SolveRequest struct {
	ScaleLow         float64 `json:"scale_low"`
	ScaleHigh        float64 `json:"scale_high"`
	ScaleUnits       string  `json:"scale_units"`
	DownsampleFactor int     `json:"downsample_factor"`
	DepthLow         int     `json:"depth_low"`
	DepthHigh        int     `json:"depth_high"`
	RA               float64 `json:"ra"`
	Dec              float64 `json:"dec"`
	Radius           float64 `json:"radius"`
}

SolveRequest represents the solve request parameters

type SolveResponse

type SolveResponse struct {
	Solved      bool              `json:"solved"`
	RA          float64           `json:"ra,omitempty"`
	Dec         float64           `json:"dec,omitempty"`
	PixelScale  float64           `json:"pixel_scale,omitempty"`
	Rotation    float64           `json:"rotation,omitempty"`
	FieldWidth  float64           `json:"field_width,omitempty"`
	FieldHeight float64           `json:"field_height,omitempty"`
	WCSHeader   map[string]string `json:"wcs_header,omitempty"`
	SolveTime   float64           `json:"solve_time,omitempty"`
	RawOutput   string            `json:"raw_output,omitempty"`
	Error       string            `json:"error,omitempty"`

	// AnnotatedImage is the base64-encoded annotated overlay (PNG), in the same
	// orientation as the uploaded image. Populated only when annotate=true and
	// the solve succeeded.
	AnnotatedImage  string `json:"annotated_image,omitempty"`
	AnnotatedFormat string `json:"annotated_format,omitempty"`
}

SolveResponse represents the solve response

type VersionHandler added in v1.0.0

type VersionHandler struct{}

VersionHandler handles version requests

func NewVersionHandler added in v1.0.0

func NewVersionHandler() *VersionHandler

NewVersionHandler creates a new version handler

func (*VersionHandler) ServeHTTP added in v1.0.0

func (h *VersionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP godoc

@Summary		Get Astrometry.net solver version
@Description	Returns the version of the solve-field binary included in this API server. This is a fast operation that executes solve-field --version and returns the output.
@Tags			Health
@Produce		json
@Success		200	{object}	VersionResponse	"Version information"	example({"version":"0.98-21-gf33d1e76"})
@Failure		500	{object}	VersionResponse	"Failed to get version"
@Router			/version [get]

type VersionResponse added in v1.0.0

type VersionResponse struct {
	Version string `json:"version"`
	Error   string `json:"error,omitempty"`
}

VersionResponse represents the version response

Jump to

Keyboard shortcuts

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