|
| 1 | +# Location Field Import Guide |
| 2 | + |
| 3 | +This guide explains how to import location data using the DT CSV Import feature. |
| 4 | + |
| 5 | +## Location Field Types |
| 6 | + |
| 7 | +### 1. `location_grid` |
| 8 | +- **Purpose**: Direct reference to location grid entries |
| 9 | +- **Required Format**: Numeric grid ID only |
| 10 | +- **Example**: `12345` |
| 11 | +- **Validation**: Must be a valid grid ID that exists in the location grid table |
| 12 | + |
| 13 | +### 2. `location_grid_meta` |
| 14 | +- **Purpose**: Flexible location data with optional geocoding |
| 15 | +- **Supported Formats**: |
| 16 | + - **Numeric grid ID**: `12345` |
| 17 | + - **Coordinates**: `40.7128, -74.0060` (latitude, longitude) |
| 18 | + - **Address**: `123 Main St, New York, NY 10001` |
| 19 | +- **Geocoding**: Can use Google Maps or Mapbox to convert addresses to coordinates |
| 20 | + |
| 21 | +### 3. `location` (Legacy) |
| 22 | +- **Purpose**: Generic location field |
| 23 | +- **Behavior**: |
| 24 | + - Numeric values treated as grid IDs |
| 25 | + - Other values treated as location_grid_meta |
| 26 | + |
| 27 | +## Geocoding Services |
| 28 | + |
| 29 | +### Available Services |
| 30 | +1. **Google Maps** - Requires Google Maps API key |
| 31 | +2. **Mapbox** - Requires Mapbox API key |
| 32 | +3. **None** - No geocoding (addresses saved as-is) |
| 33 | + |
| 34 | +### Geocoding Process |
| 35 | +When a geocoding service is selected: |
| 36 | + |
| 37 | +1. **Addresses** → Converted to coordinates → Assigned to location grid |
| 38 | +2. **Coordinates** → Assigned to location grid → Address lookup (reverse geocoding) |
| 39 | +3. **Grid IDs** → Validated and used directly |
| 40 | + |
| 41 | +### Rate Limiting |
| 42 | +- Automatic delays added for large imports to respect API limits |
| 43 | +- Batch processing available for performance |
| 44 | + |
| 45 | +## CSV Format Examples |
| 46 | + |
| 47 | +### location_grid Field |
| 48 | +```csv |
| 49 | +name,location_grid |
| 50 | +John Doe,12345 |
| 51 | +Jane Smith,67890 |
| 52 | +``` |
| 53 | + |
| 54 | +### location_grid_meta Field |
| 55 | +```csv |
| 56 | +name,location_grid_meta |
| 57 | +John Doe,12345 |
| 58 | +Jane Smith,"40.7128, -74.0060" |
| 59 | +Bob Johnson,"123 Main St, New York, NY" |
| 60 | +``` |
| 61 | + |
| 62 | +### Mixed Location Data |
| 63 | +```csv |
| 64 | +name,location_grid_meta,notes |
| 65 | +Person 1,12345,Direct grid ID |
| 66 | +Person 2,"40.7128, -74.0060",Coordinates |
| 67 | +Person 3,"New York City",Address (requires geocoding) |
| 68 | +``` |
| 69 | + |
| 70 | +## Configuration |
| 71 | + |
| 72 | +### Setting Up Geocoding |
| 73 | +1. Configure API keys in DT settings: |
| 74 | + - Google Maps: Settings → Mapping → Google Maps API |
| 75 | + - Mapbox: Settings → Mapping → Mapbox API |
| 76 | + |
| 77 | +2. Select geocoding service during import process |
| 78 | + |
| 79 | +### Import Process |
| 80 | +1. Upload CSV file |
| 81 | +2. Map columns to fields |
| 82 | +3. For location_grid_meta fields, select geocoding service |
| 83 | +4. Preview import to verify location processing |
| 84 | +5. Execute import |
| 85 | + |
| 86 | +## Error Handling |
| 87 | + |
| 88 | +### Common Issues |
| 89 | +- **Invalid grid ID**: Non-existent grid IDs will cause import errors |
| 90 | +- **Invalid coordinates**: Out-of-range lat/lng values will be rejected |
| 91 | +- **Geocoding failures**: Addresses that can't be geocoded will be saved as-is with error notes |
| 92 | +- **API limits**: Rate limiting may slow down large imports |
| 93 | + |
| 94 | +### Error Resolution |
| 95 | +- Check API key configuration |
| 96 | +- Verify data formats |
| 97 | +- Review geocoding service status |
| 98 | +- Use smaller batch sizes for large imports |
| 99 | + |
| 100 | +## Best Practices |
| 101 | + |
| 102 | +1. **Validate Data**: Check grid IDs and coordinate formats before import |
| 103 | +2. **Use Consistent Formats**: Stick to one format per field when possible |
| 104 | +3. **Test Small Batches**: Test with a few records before large imports |
| 105 | +4. **Monitor API Usage**: Be aware of geocoding API limits and costs |
| 106 | +5. **Backup Data**: Always backup before large imports |
| 107 | + |
| 108 | +## Technical Details |
| 109 | + |
| 110 | +### Field Handlers |
| 111 | +- `handle_location_grid_field()`: Validates numeric grid IDs |
| 112 | +- `handle_location_grid_meta_field()`: Processes flexible location data |
| 113 | +- `DT_CSV_Import_Geocoding`: Handles all geocoding operations |
| 114 | + |
| 115 | +### Data Flow |
| 116 | +1. Raw CSV value input |
| 117 | +2. Field type detection |
| 118 | +3. Format validation |
| 119 | +4. Geocoding (if enabled) |
| 120 | +5. Location grid assignment |
| 121 | +6. Data formatting for DT_Posts API |
| 122 | +7. Record creation |
| 123 | + |
| 124 | +### Performance Considerations |
| 125 | +- Geocoding adds processing time |
| 126 | +- Large imports may take longer with geocoding enabled |
| 127 | +- Background processing available for large datasets |
| 128 | +- Progress tracking during import |
| 129 | + |
| 130 | +## Support |
| 131 | + |
| 132 | +For issues with location imports: |
| 133 | +1. Check error logs for detailed error messages |
| 134 | +2. Verify API key configuration |
| 135 | +3. Test with sample data |
| 136 | +4. Review CSV format requirements |
| 137 | +5. Contact system administrator if needed |
0 commit comments