# Market Share Data ## current data from listing-editor ```json= { "meta": { "total": 11452980, "count": 1 }, "data": [ { "_index": "kwlslistings", "_type": "record", "_id": "211aa267-c8b9-4046-a9e1-e2fd949a3e0a", "_score": 1, "_source": { "hoa": [ { "assoc_fee": 550, "assoc_fee_freq": "Monthly" } ], "raw": { "prop_type": "Attached Single", "list_status": "Active", "prop_type_id": 2, "parking_total": "2", "list_status_id": 1, "source_list_id": "200_2146574179" }, "kw_mc": false, "taxes": [ { "tax_year": "2017" } ], "mls_id": "IL_MRED", "photos": [ { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969.JPG", "ph_order": 1 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_1.JPG", "ph_order": 2 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_2.JPG", "ph_order": 3 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_3.JPG", "ph_order": 4 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_4.JPG", "ph_order": 5 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_5.JPG", "ph_order": 6 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_6.JPG", "ph_order": 7 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_7.JPG", "ph_order": 8 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_8.JPG", "ph_order": 9 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_9.JPG", "ph_order": 10 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_10.JPG", "ph_order": 11 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_11.JPG", "ph_order": 12 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_12.JPG", "ph_order": 13 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_13.JPG", "ph_order": 14 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_14.JPG", "ph_order": 15 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_15.JPG", "ph_order": 16 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_16.JPG", "ph_order": 17 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_17.JPG", "ph_order": 18 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_18.JPG", "ph_order": 19 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_19.JPG", "ph_order": 20 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_20.JPG", "ph_order": 21 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_21.JPG", "ph_order": 22 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_22.JPG", "ph_order": 23 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_23.JPG", "ph_order": 24 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_24.JPG", "ph_order": 25 }, { "ph_url": "http://photos.mredllc.com/photos/property/969/10164969_25.JPG", "ph_order": 26 } ], "list_dt": "2019-01-04T00:00:00Z", "version": "1.0.0", "kw_agent": false, "list_key": "IL_MRED-10164969", "location": { "county": "Kane", "subdivision": "Whitmore Place", "prop_directions": "Rt 25 (N of Army Trail) to Carl Lee Rd W to Whitmore" }, "mls_name": "Midwest Real Estate Data", "brokerage": { "name": "RE/MAX Excels" }, "full_bath": 3, "half_bath": 1, "list_desc": "Stunning townhome in sought after Whitmore Place. Open and inviting with wood floors and a fire place. This 3 bedroom 3 full and 1 half bath home is a delight to see. The first floor has a kitchen, dining area, living room, and half bath. The eat in kitchen has 42\" maple cabinets, Corian countertops and tile floor. The eating area has a sliding glass door that opens to a patio and park like setting. The second floor boasts a master bedroom suite with vaulted ceiling, double bowl vanity sep shower & soaking tub. There are 2 additional spacious bedrooms and full hall bath. The convenient laundry is also located on the second floor. The basement has been professionally finished with rec room and full bath. This is a must see! Can lighting, drywall, and beautiful trim complete this package. There is also plenty of storage. This is the one you have been waiting for. See it soon. Nothing to do but move in!", "list_type": "MLS Listing", "list_uuid": "211aa267-c8b9-4046-a9e1-e2fd949a3e0a", "prop_type": "Residential", "structure": { "floorings": [ "Living Room: Hardwood" ], "utilities": [ "Public" ], "appliances": [ "Oven/Range", "Microwave", "Dishwasher", "Refrigerator", "Washer", "Dryer", "Disposal", "Water Softener Owned" ], "has_garage": true, "roof_types": [ "Asphalt/Glass (Shingles)" ], "has_parking": true, "basement_desc": "Full,Bathrooms: No,Finished", "parking_total": 2, "fireplace_desc": "Gas Logs,Living Room", "heating_cooling": [ "Central Air", "Fuel: Gas", "Fuel: Forced Air" ], "fireplaces_total": 1, "parking_features": [ "Type: Attached", "Number of Cars: 2", "Garage" ], "exterior_features": { "has_deck": false, "has_dock": false, "has_pond": false, "has_pool": false, "has_patio": false, "has_porch": false, "has_garden": false, "has_rv_parking": false, "is_water_front": true, "has_gated_entry": false, "has_green_house": false, "has_hot_tub_spa": false, "has_sports_court": false, "has_barbecue_area": false, "has_disabled_access": true, "has_sprinkler_system": false }, "interior_features": { "is_wired": false, "has_sauna": false, "has_wet_bar": false, "has_skylight": false, "has_fireplace": true, "is_cable_ready": false, "has_ceiling_fan": false, "has_mother_in_law": false, "has_jetted_bath_tub": false, "has_security_system": false, "has_vaulted_ceiling": false }, "foundation_details": [ "Concrete" ], "is_new_construction": true }, "syndicate": [ "KW My MC", "KW My Country", "KW All", "KW Consumer", "KW Global" ], "total_bed": 3, "is_deleted": false, "kw_listing": false, "mls_number": "10164969", "total_bath": 3, "year_built": "2005", "kwls_status": "Accepted", "list_status": "Active", "living_area": 1881, "luxury_home": false, "photos_lock": false, "kw_expiry_dt": "2019-04-08", "list_address": { "city": "St. Charles", "zip_4": "5606", "state_prov": "IL", "postal_code": "60174", "street_name": "Whitmore", "unit_number": "B", "street_number": "6N325", "street_suffix": "Cir", "coordinates_gp": { "lat": 41.961391, "lon": -88.292978 }, "coordinates_gs": { "type": "Point", "coordinates": [ -88.292978, 41.961391 ] }, "full_street_address": "6N325 Whitmore Circle" }, "manual_entry": false, "prop_subtype": "Condominium", "prop_type_id": 2, "currency_code": "USD", "kw_updated_at": "2019-04-04T06:03:06.772Z", "kw_updated_by": "Smarter Agent", "list_category": "For Sale", "mls_source_id": 200, "list_desc_lock": false, "list_status_id": 1, "marketing_info": { "vow": false, "display_photo": true, "courtesy_label": "Courtesy of", "display_address": true, "display_internet": true, "courtesy_location": "BOTTOM", "display_list_price": true, "photo_courtesy_required": false }, "mls_updated_at": "2019-01-10T06:05:24.000Z", "prop_type_lock": false, "prop_subtype_id": 2, "list_category_id": 2, "list_status_lock": false, "one_quarter_bath": 0, "property_address": { "zip_4": "5673", "city_long": "Saint Charles", "unit_type": "Unit", "city_short": "St Charles", "street_long": "Whitmore", "unit_number": "B", "street_number": "6N325", "coordinates_gp": { "lat": 41.94324, "lon": -88.29865 }, "coordinates_gs": { "type": "Point", "coordinates": [ -88.29865, 41.94324 ] }, "postal_code_long": "60174-5673", "state_prov_short": "IL", "postal_code_short": "60174", "full_street_address": "6N325 Whitmore Cir Unit B", "street_suffix_short": "Cir" }, "kw_expiry_dt_lock": false, "list_agent_office": { "list_agent_key": "IL_MRED-30-783", "list_office_key": "IL_MRED-30", "list_agent_email": "pam.raverteam@gmail.com", "list_office_name": "RE/MAX Excels", "list_agent_mls_id": "783", "list_office_email": "chrishansen@remax.net", "list_office_phone": "(630) 208-7400", "list_office_mls_id": "30", "list_agent_full_name": "Pamela Raver", "list_agent_preferred_phone": "6305133189" }, "living_area_units": "SF", "prop_subtype_lock": false, "current_list_price": 265000, "source_system_name": "Smarter Agent", "three_quarter_bath": 0, "days_on_market": 186 } } ] } ``` ## Current Data from Bounding Box ```json= { "meta": { "total": 1671, "count": 1 }, "data": [ { "id": "32034", "type": "area", "attributes": { "city": "Austin", "type_id": "neighborhood", "country": "US", "location": { "type": "MultiPolygon", "coordinates": [ [ [ [ -97.777205, 30.425327 ], [ -97.777201, 30.425407 ], [ -97.777392, 30.425903 ], [ -97.77696, 30.426128 ], [ -97.77649, 30.426228 ], [ -97.775569, 30.426281 ], [ -97.776161, 30.42775 ], [ -97.776238, 30.428261 ], [ -97.776016, 30.428308 ], [ -97.77571, 30.428287 ], [ -97.775596, 30.428369 ], [ -97.775173, 30.428281 ], [ -97.775138, 30.428427 ], [ -97.774939, 30.428699 ], [ -97.774664, 30.428869 ], [ -97.773482, 30.429255 ], [ -97.773322, 30.429447 ], [ -97.773295, 30.429423 ], [ -97.773011, 30.429659 ], [ -97.773253, 30.42994 ], [ -97.772364, 30.430739 ], [ -97.772098, 30.430886 ], [ -97.770339, 30.431625 ], [ -97.769789, 30.43203 ], [ -97.76908, 30.432634 ], [ -97.768606, 30.433147 ], [ -97.767867, 30.432473 ], [ -97.762359, 30.428855 ], [ -97.761421, 30.428256 ], [ -97.759181, 30.427164 ], [ -97.758862, 30.426923 ], [ -97.760677, 30.424105 ], [ -97.757512, 30.422571 ], [ -97.7592585423278, 30.4198674887081 ], [ -97.762418, 30.421314 ], [ -97.762995, 30.420389 ], [ -97.763635, 30.419397 ], [ -97.76504, 30.417213 ], [ -97.765347, 30.416719 ], [ -97.766892, 30.417486 ], [ -97.766635, 30.417902 ], [ -97.766674, 30.418044 ], [ -97.768217, 30.418778 ], [ -97.772725, 30.420953 ], [ -97.772964, 30.420672 ], [ -97.773367, 30.421054 ], [ -97.7737, 30.421202 ], [ -97.774269, 30.421259 ], [ -97.774697, 30.421009 ], [ -97.774846, 30.421005 ], [ -97.775028, 30.420836 ], [ -97.775189, 30.420631 ], [ -97.776013, 30.42016 ], [ -97.77645, 30.420637 ], [ -97.777311, 30.421181 ], [ -97.777575, 30.421437 ], [ -97.777921, 30.422637 ], [ -97.777359, 30.423399 ], [ -97.77726, 30.423747 ], [ -97.777387, 30.424288 ], [ -97.777832, 30.424771 ], [ -97.777205, 30.425327 ] ] ] ] }, "centroid_gp": { "lat": 30.425049, "lon": -97.76879374716111 }, "area_meter_square": 1967771.82, "state_or_province": "TX", "neighborhood_name": "Oak Forest", "state_or_province_full": "Texas" } } ] } ``` ## Current Data Represantion In UI ### Agent Data (for the side drawer) ```javascript= { "agent_id123": { dataId, fullName, isKwAgent, kwUid, mlsId, phone, email, officeName, brokerage, city, stateProv, listings[], neighborhoods[], } } ``` ### Listing Data ```javascript= { "listingId12312": { coordinate: { lat, long, }, agentId, neighborhoodId, listingId, dataId, isKwMc, isKwListing, marketCenter, } } ``` ### Neighborhood Data ```javascript= { "neighborhoodId123": { coordinates: Polygon[], id, city, locationType, neighborhoodName, } } ``` ### Spec the bounding box and the listing editor api have the same parameter for example > listing editor: `/listing-editor?top_left[lat]=${NeLat}&top_left[lon]=${SwLng}&bottom_right[lat]=${SwLat}&bottom_right[lon]=${NeLng}&page[limit]=${limit}` > > bounding box: `/bounding_box?top_left[lat]=${NeLat}&top_left[lon]=${SwLng}&bottom_right[lat]=${SwLat}&bottom_right[lon]=${NeLng}&filter[boundary_type]=neighborhood&page[limit]=50` > so we can combine them in one proxy url ? ex `/market-share-service?top_left[lat]=${NeLat}&top_left[lon]=${SwLng}&bottom_right[lat]=${SwLat}&bottom_right[lon]=${NeLng}&filter[boundary_type]=neighborhood&page[limit]=50` and just forward those paramater. the response of the service could be something like this. for the concise ```json= { "data": { "neighborhoods": [ { coordinates: Polygon[], id: "123131", city: "New York City", locationType: "MultiPolygon", neighborhoodName: "Haboken", } ], "listings": [ { coordinate: { lat: 81.3113, long: 38.3131, }, agentId: "agent_mls_id", neighborhoodId: "neighborhoodId or null", listingId: "list_key", isKwMc: true, isKwListing: true, marketCenter: 21, } ], "agents": [ { isKwAgent: false, kwUid: "1312313 or null", mlsId: "mls_agent_id", brokerage: "KW Brokerage", city: "New York City", listings: ["listingId1", "listingId2"], neighborhoods: ["NeighborhoodId1", "NeighborhoodId2"], phone: "+12312312312", email: "asddasd@gmail.com", officeName: "Lander Office", } ] } } ``` ## How to Tie Listing Data and Neighborhood Data We can use a geolib/geofencing library to determine if Listings coordinate is inside the neighborhood polygon for example in php using this library https://github.com/mjaschen/phpgeo The lib also have simplify polyline for simplifying neighborhood coordinates https://github.com/mjaschen/phpgeo#simplifying-a-polyline ## Rec