# Claude Requirement – `/gsd-add-phase` Location Coordinate Auto Mapping Enhancement

## Requirement Summary

Implement automatic GIS coordinate generation for assets in `/gsd-add-phase`.

The system shall use the Latitude and Longitude available in `ic3_location_master` as the center reference point and automatically generate unique random coordinates for assets from `ic3_asset_master` within the selected location boundary.

This enhancement is required for GIS visualization when asset coordinates are missing or need to be generated during location setup.

---

## Business Requirement

Currently:

* Location records contain Latitude and Longitude in `ic3_location_master`.
* Asset records may not have valid GIS coordinates.
* Assets cannot be displayed properly on the GIS map.

Required:

* Generate random asset coordinates around the selected location.
* All generated coordinates must remain inside the location boundary.
* No duplicate Latitude/Longitude combinations are allowed.
* Generated coordinates should appear naturally distributed around the location.

---

## Data Source

### Location Master

Table:

```text
ic3_location_master
```

Fields:

```text
location_id
location_name
latitude
longitude
boundary_radius
```

Example:

```text
Location: Naraina D.Cantt UGR Zone

Latitude : 28.613900
Longitude: 77.209000
```

---

### Asset Master

Table:

```text
ic3_asset_master
```

Fields:

```text
asset_id
asset_name
asset_group_id
latitude
longitude
location_id
```

---

## Coordinate Generation Logic

### Step 1

User selects:

```text
Customer
Location
```

System retrieves:

```text
Location Latitude
Location Longitude
```

from:

```text
ic3_location_master
```

---

### Step 2

Retrieve all assets belonging to the selected location.

```text
SELECT *
FROM ic3_asset_master
WHERE location_id = :location_id
```

---

### Step 3

Generate coordinates for each asset.

Rule:

```text
Center Point
=
Location Latitude + Longitude
```

Randomly distribute assets within configurable radius.

Example:

```text
Radius = 500 meters
```

Generated coordinates should fall within:

```text
Latitude  ± random offset
Longitude ± random offset
```

---

## Duplicate Prevention

System must ensure:

```text
(latitude, longitude)
```

combination is unique.

Validation:

```text
No two assets can share identical coordinates.
```

If duplicate detected:

```text
Regenerate coordinate
```

until unique value is obtained.

---

## Asset Distribution Rules

Assets should appear naturally distributed.

Avoid:

```text
Straight line placement
Grid placement
Stacked markers
```

Preferred:

```text
Random circular distribution
```

around the location center point.

---

## Coordinate Accuracy

Generated coordinates should:

* Stay inside location boundary.
* Stay within configured radius.
* Use 6 decimal precision.
* Be GIS compatible.

Example:

```text
Location Center
28.613900, 77.209000

Generated Assets

28.614120, 77.208540
28.613450, 77.209730
28.614620, 77.209250
28.613110, 77.208870
```

---

## Database Update

After generation:

Update asset coordinates.

```text
ic3_asset_master.latitude
ic3_asset_master.longitude
```

must be populated automatically.

---

## GIS Map Requirement

After coordinate generation:

* Reload GIS map automatically.
* Display all assets immediately.
* Use Asset Group image as marker icon.
* Auto-fit map bounds to all generated assets.

---

## Configuration

### Default Radius

```text
500 meters
```

### Future Configurable Radius

Allow administrator to configure:

```text
100m
250m
500m
1000m
2000m
```

per location.

---

## Performance Requirement

Support:

```text
10,000+ assets
```

Generation time:

```text
< 5 seconds
```

for bulk asset creation.

---

## Validation Rules

### Mandatory

* Location Latitude exists.
* Location Longitude exists.

### System Validation

If location coordinates are missing:

Display:

```text
Unable to generate asset coordinates.
Location latitude/longitude not configured.
```

---

## Acceptance Criteria

### Coordinate Generation

✅ Assets receive random coordinates around location center.

✅ Coordinates remain within location boundary.

✅ No duplicate Latitude/Longitude values.

✅ Coordinates stored in `ic3_asset_master`.

---

### GIS Map

✅ Assets visible immediately after generation.

✅ Markers use Asset Group image.

✅ Map auto-zooms to asset coverage area.

---

### Performance

✅ Supports large asset volumes.

✅ Bulk generation completed within acceptable time.

---

## Module

```text
GSD
```

## Screen

```text
/gsd-add-phase
```

## Change Type

```text
Location Coordinate Auto Generation + GIS Asset Placement Enhancement
```
