wip
This commit is contained in:
Regular → Executable
+20
@@ -627,6 +627,18 @@ class MLS_Sync_Engine {
|
||||
$this->emit_progress('property_created', array('listing_key' => $listing_key));
|
||||
}
|
||||
|
||||
// Update spatial location column (wpdb can't handle ST_PointFromText directly)
|
||||
$lat = $property['Latitude'] ?? null;
|
||||
$lng = $property['Longitude'] ?? null;
|
||||
if ($lat !== null && $lng !== null) {
|
||||
$wpdb->query($wpdb->prepare(
|
||||
"UPDATE {$this->db->properties_table()} SET location = ST_PointFromText(CONCAT('POINT(', %f, ' ', %f, ')'), 4326) WHERE listing_key = %s",
|
||||
(float) $lat,
|
||||
(float) $lng,
|
||||
$listing_key
|
||||
));
|
||||
}
|
||||
|
||||
// Process media if present
|
||||
if (isset($property['Media']) && is_array($property['Media'])) {
|
||||
$this->media_handler->sync_property_media($listing_key, $property['Media'], false, $this->progress_callback);
|
||||
@@ -652,6 +664,13 @@ class MLS_Sync_Engine {
|
||||
* @return array Mapped data for database
|
||||
*/
|
||||
private function map_property_data($property) {
|
||||
// Validate coordinates against state boundaries
|
||||
$coordinates_invalid = MLS_Geo_Validator::validate_coordinates(
|
||||
$property['Latitude'] ?? null,
|
||||
$property['Longitude'] ?? null,
|
||||
$property['StateOrProvince'] ?? 'MN'
|
||||
) ? 0 : 1;
|
||||
|
||||
return array(
|
||||
'listing_id' => $property['ListingId'] ?? null,
|
||||
'originating_system' => $property['OriginatingSystemName'] ?? 'northstar',
|
||||
@@ -673,6 +692,7 @@ class MLS_Sync_Engine {
|
||||
'county' => $property['CountyOrParish'] ?? null,
|
||||
'latitude' => $property['Latitude'] ?? null,
|
||||
'longitude' => $property['Longitude'] ?? null,
|
||||
'coordinates_invalid' => $coordinates_invalid,
|
||||
|
||||
'property_type' => $property['PropertyType'] ?? null,
|
||||
'property_sub_type' => $property['PropertySubType'] ?? null,
|
||||
|
||||
Reference in New Issue
Block a user