turash/bugulma/backend/internal/geospatial/config.go
Damir Mukimov 000eab4740
Major repository reorganization and missing backend endpoints implementation
Repository Structure:
- Move files from cluttered root directory into organized structure
- Create archive/ for archived data and scraper results
- Create bugulma/ for the complete application (frontend + backend)
- Create data/ for sample datasets and reference materials
- Create docs/ for comprehensive documentation structure
- Create scripts/ for utility scripts and API tools

Backend Implementation:
- Implement 3 missing backend endpoints identified in gap analysis:
  * GET /api/v1/organizations/{id}/matching/direct - Direct symbiosis matches
  * GET /api/v1/users/me/organizations - User organizations
  * POST /api/v1/proposals/{id}/status - Update proposal status
- Add complete proposal domain model, repository, and service layers
- Create database migration for proposals table
- Fix CLI server command registration issue

API Documentation:
- Add comprehensive proposals.md API documentation
- Update README.md with Users and Proposals API sections
- Document all request/response formats, error codes, and business rules

Code Quality:
- Follow existing Go backend architecture patterns
- Add proper error handling and validation
- Match frontend expected response schemas
- Maintain clean separation of concerns (handler -> service -> repository)
2025-11-25 06:01:16 +01:00

76 lines
2.8 KiB
Go

package geospatial
// Config holds all geospatial calculation configuration
type Config struct {
// Earth model parameters
EarthRadiusKm float64 `json:"earth_radius_km"` // Default: 6371.0 km
EarthRadiusMeters float64 `json:"earth_radius_meters"` // Default: 6371000.0 m
// Distance calculation preferences
DefaultDistanceMethod string `json:"default_distance_method"` // "haversine" or "vincenty"
UseEllipsoidalModel bool `json:"use_ellipsoidal_model"` // Use WGS84 ellipsoid for Vincenty
// Coordinate system defaults
DefaultCoordinateSystem CoordinateSystem `json:"default_coordinate_system"` // Default: WGS84
// Validation parameters
MaxLatitude float64 `json:"max_latitude"` // Default: 90.0
MinLatitude float64 `json:"min_latitude"` // Default: -90.0
MaxLongitude float64 `json:"max_longitude"` // Default: 180.0
MinLongitude float64 `json:"min_longitude"` // Default: -180.0
// Route calculation parameters
AverageSpeedKmh float64 `json:"average_speed_kmh"` // Default: 50 km/h for urban areas
// Clustering defaults
DefaultClusteringAlgorithm ClusteringAlgorithm `json:"default_clustering_algorithm"`
DefaultClusteringRadiusKm float64 `json:"default_clustering_radius_km"`
DefaultMinPointsPerCluster int `json:"default_min_points_per_cluster"`
// PostGIS integration
PostGISEnabled bool `json:"postgis_enabled"`
PostGISSRID int `json:"postgis_srid"` // Default: 4326 (WGS84)
// Performance tuning
MaxDistanceMatrixSize int `json:"max_distance_matrix_size"` // Prevent excessive memory usage
}
// DefaultConfig returns the default configuration
func DefaultConfig() *Config {
return &Config{
EarthRadiusKm: 6371.0,
EarthRadiusMeters: 6371000.0,
DefaultDistanceMethod: "haversine",
UseEllipsoidalModel: false, // Use spherical model by default for speed
DefaultCoordinateSystem: WGS84,
MaxLatitude: 90.0,
MinLatitude: -90.0,
MaxLongitude: 180.0,
MinLongitude: -180.0,
AverageSpeedKmh: 50.0, // Urban average speed
DefaultClusteringAlgorithm: AlgorithmDBSCAN,
DefaultClusteringRadiusKm: 5.0, // 5km default radius
DefaultMinPointsPerCluster: 3,
PostGISEnabled: false, // Enable when PostGIS is available
PostGISSRID: 4326,
MaxDistanceMatrixSize: 1000, // Prevent matrices larger than 1000x1000
}
}
// Validate validates the configuration
func (c *Config) Validate() error {
if c.EarthRadiusKm <= 0 {
return ErrInvalidEarthRadius
}
if c.MaxLatitude <= c.MinLatitude {
return ErrInvalidLatitudeRange
}
if c.MaxLongitude <= c.MinLongitude {
return ErrInvalidLongitudeRange
}
if c.DefaultDistanceMethod != "haversine" && c.DefaultDistanceMethod != "vincenty" {
return ErrInvalidDistanceMethod
}
return nil
}