dragndrop_hld/INFO_LAYERS_TEST_RESULTS.md
alex f81dcccbb6 FULL WORKING V 1.0
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-22 16:15:50 -07:00

6.4 KiB

Info Layers Test Results - Map ID 16950

Test Date: 2025-12-09 Test Layers: parcels, cabinet_boundaries, cables Test Type: First 10 records per layer (3 for boundaries/parcels, 3 for cables in actual shapefile) Map ID: 16950

Summary

Layer Records Attempted Records Uploaded Status
cabinet_boundaries.shp 3 0 API Error
cables.shp 3 0 API Error
parcels.shp 3 0 API Error

Overall: 0 out of 9 records uploaded (0% success rate)


Progress Made

Metric Field Calculation Working

The metric field is now being calculated correctly:

Cables (LineString):

{
  "metric": "Mileage: 0.9196; Footage: 4856"
}

Boundaries & Parcels (Polygon):

{
  "metric": "Square Miles: 3.3141"
}

Formula Used:

  • Lines: At 40° latitude, 1° longitude ≈ 53 miles, 1° latitude ≈ 69 miles
  • Polygons: At 40° latitude, 1 degree² ≈ 3,657 square miles

Code Added:

  • _calculate_line_metric() - Line length calculation
  • _calculate_polygon_metric() - Polygon area calculation

Current Blocker

API Error: Field 'data' doesn't have a default value

Error Message:

Database Exception: SQLSTATE[HY000]: General error: 1364
Field 'data' doesn't have a default value
The SQL being executed was: INSERT INTO `mapobject` (`mapprojectId`, `name`, ...

What We Tried:

  1. Attempt 1: Send data as nested array of lat/lng objects

    • Result: Same error
  2. Attempt 2: JSON-encode data field as a string

    • Result: Same error

Example Data Being Sent:

{
  "mapProjectId": 16950,
  "name": "Zone 01 Boundary",
  "mapinfoobjecttypeId": 3,
  "data": "[{\"lat\": 40.7723..., \"lng\": -124.1857...}, ...]",
  "color": "#ffffff",
  "alpha": "0.40",
  "metric": "Square Miles: 3.3141"
}

Analysis

Root Cause

The error message "Field 'data' doesn't have a default value" is a MySQL database error, not a validation error. This indicates:

  1. The Verofy API backend is attempting to INSERT into the mapobject table
  2. The data field we're sending is not being included in the INSERT statement
  3. The database column data has no default value, causing the query to fail

Possible Reasons

1. API Endpoint Not Fully Implemented

The /map-info-object/create endpoint may not properly handle the data field during creation.

2. Missing Required Field

There may be another field we need to send that tells the API how to interpret the data field.

3. Field Name Different for Creation

The field might be named differently when creating vs reading:

  • Reading: data (from GET /map-info-object/{id})
  • Creating: ??? (for POST /map-info-object/create)

4. Data Format Issue

The data field might need a different structure than what we see in GET responses.


Comparison with Export

From Map 15685 Export (GET response):

Type 2 (Polyline/Cable):

{
  "mapinfoobjecttypeId": 2,
  "data": [
    {"lat": 40.760037779, "lng": -124.174677888},
    {"lat": 40.760068861, "lng": -124.171780846}
  ]
}

Type 3 (Polygon):

{
  "mapinfoobjecttypeId": 3,
  "data": [
    {"lat": 40.761573196, "lng": -124.17190395},
    {"lat": 40.760796168, "lng": -124.173069332},
    ...
  ]
}

What We're Sending (POST request):

Exactly the same format - but API is not accepting it.


Recommendations

Option 1: Contact Verofy API Support

This appears to be an API bug or undocumented requirement. We should ask:

  1. Is the /map-info-object/create endpoint fully implemented?
  2. What is the correct format for the data field when creating info objects?
  3. Are there any required fields beyond what's documented?

Option 2: Test with Manual Web Interface

Create an info object manually through Verofy's web interface, then:

  1. Retrieve it via GET /map-info-object/{id}
  2. Compare the structure
  3. Look for any additional fields that were set

Option 3: Alternative Approach

If info objects can't be created via API, we may need to:

  1. Skip these layers for now
  2. Import them manually through Verofy's web interface
  3. Wait for API endpoint to be fixed

Code Changes Made

File: /home/ahall/Sandbox/dragnddrop/backend/verofy_uploader.py

Lines 131-170: Added metric calculation functions

def _calculate_line_metric(self, geometry) -> str:
    """Calculate mileage and footage for cable lines"""
    # Implementation...

def _calculate_polygon_metric(self, geometry) -> str:
    """Calculate square miles for boundaries and parcels"""
    # Implementation...

Lines 663-675: Updated _upload_cabinet_boundaries()

metric = self._calculate_polygon_metric(row.geometry)
info_data = {
    ...
    "metric": metric
}

Lines 709-721: Updated _upload_cables()

metric = self._calculate_line_metric(row.geometry)
info_data = {
    ...
    "metric": metric
}

Lines 756-768: Updated _upload_parcels()

metric = self._calculate_polygon_metric(row.geometry)
info_data = {
    ...
    "metric": metric
}

Lines 958-986: Updated _create_info_object()

# JSON-encode the data field as a string (API may expect this)
if 'data' in info_data:
    info_data_copy = info_data.copy()
    info_data_copy['data'] = json.dumps(info_data['data'])
    # Send encoded version...

Next Steps

  1. Document the API Issue

    • Report to Verofy API team
    • Provide exact error message and request/response details
  2. Test Alternative Approaches

    • Try different field names (dataAsText, geometry, etc.)
    • Try sending data without JSON encoding
    • Try minimal payload to see what works
  3. Verify Endpoint Status

    • Check if endpoint is in beta/deprecated
    • Look for alternative endpoints for info objects
  4. Focus on Working Layers

    • Continue with poles, segments, sites (working)
    • Fix access_points, network_elements, splicing
    • Come back to info layers once API issue is resolved

Test Data

Successfully Calculated Metrics

Cabinet Boundary "Zone 01":

  • Area: 3.3141 square miles
  • 6 coordinate points

Cable "144F/EUR_Z07_DC_001":

  • Length: 0.9196 miles (4,856 feet)
  • 2 coordinate points

Parcel (Zone 01):

  • Area: 0.1362 square miles
  • 5 coordinate points (closed polygon)

All metric calculations are working correctly and match expected format from Verofy exports.