DEV - Display address pins outside of NC boundaries
Releases
- [ ] https://github.com/hackforla/311-data/issues/1960
Overview
We need to modify our address search capability to notify the user when the searched address is not within one of the Neighborhood Councils so they don't get confused why their address selection does not select a Neighborhood Council.
Action Items
- [ ] in MapSearch.jsx, L120, modify this inline function to do the following
- [ ] loop through all Neighborhood Council geometry objects
- [ ] use Turf's
booleanContainsto determine if ONE NC "contains" the position in the result- [ ] if yes, proceed with address pin as normal
- [ ] if not, display the error that is mocked up by design.
- [ ] Use copy: "Please enter an address in Los Angeles"
- [ ] entered address should remain in the address bar (see comment w/ reasoning)
- [ ] once PR has been merged, release #1960:
- [ ] Move #1960 from Icebox (on hold) (https://github.com/orgs/hackforla/projects/63/views/1?filterQuery=status%3A%22Icebox+%28on+hold%29%22) to New Issue Approval (https://github.com/orgs/hackforla/projects/63/views/1?filterQuery=status%3A%22New+Issue+Approval%22)
- [ ] remove label: https://github.com/hackforla/311-data/labels/Dependency
- [ ] add label: https://github.com/hackforla/311-data/labels/ready%20for%20dev%20lead
Resources/Instructions
Design Hand Off Material
- Figma design file link: Display address pins outside of NC boundaries #1847
- Related previous ticket: https://github.com/hackforla/311-data/issues/1847
Before Screenshot
Example: Far from Los Angeles - Miami
Example: Next to Los Angeles - West Hollywood
Example: Outside Los Angeles but nearby - Thousand Oaks
Finalized Proposed changes
Full Screen
Zoomed
Screenshot of localhost
[insert screenshot here]
Developer Resources: RFC7946 (referenced in Turf.js docs)
Section 1.4: Definitions
Link: Section 1.4: Definitions
Geometries
o Inside this document, the term "geometry type" refers to seven
case-sensitive strings: "Point", "MultiPoint", "LineString",
"MultiLineString", "Polygon", "MultiPolygon", and
"GeometryCollection".
GeoJSON Types (includes Geometries)
o As another shorthand notation, the term "GeoJSON types" refers to
nine case-sensitive strings: "Feature", "FeatureCollection", and
the geometry types listed above.
Collections are just arrays
o The word "Collection" in "FeatureCollection" and
"GeometryCollection" does not have any significance for the
semantics of array members. The "features" and "geometries"
members, respectively, of these objects are standard ordered JSON
arrays, not unordered sets.
Section 3.1: Geometry Objects
Geometry object vs GeoJSON object
A Geometry object represents points, curves, and surfaces in
coordinate space. Every Geometry object is a GeoJSON object no
matter where it occurs in a GeoJSON text.
Geometries are not debatable!
o The value of a Geometry object's "type" member MUST be one of the
seven geometry types (see Section 1.4).
All Geometries have coordinates
o A GeoJSON Geometry object of any type other than
"GeometryCollection" has a member with the name "coordinates".
The value of the "coordinates" member is an array. The structure
of the elements in this array is determined by the type of
geometry. GeoJSON processors MAY interpret Geometry objects with
empty "coordinates" arrays as null objects.
Section 3.1.1: Position
Link: Section 3.1.1: Position
Abridged definition of Position (as it pertains to geocoder results & NC boundaries)
A position is the fundamental geometry construct. The "coordinates"
member of a Geometry object is composed of either:
o one position in the case of a Point geometry,
...
o an array of LineString or linear ring (see [Section 3.1.6](https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.6))
coordinates in the case of a Polygon or MultiLineString geometry,
...
Basic requirements for "position"
A position is an array of numbers. There MUST be two or more
elements. The first two elements are longitude and latitude, or
easting and northing, precisely in that order and using decimal
numbers. Altitude or elevation MAY be included as an optional third
element.
Section 3.2: Feature
Link: Section 3.2: Feature
Features are GeoJSON objects
A Feature object represents a spatially bounded thing. Every Feature
object is a GeoJSON object no matter where it occurs in a GeoJSON
text.
Properties are where we store information about the Feature
o A Feature object has a member with the name "properties". The
value of the properties member is an object (any JSON object or a
JSON null value).
Other Dev Resources
Notes on Turf.js::booleanContains()
- our current build already utilizes Turf.js as a dependency:
- From our package.json ...
"@turf/turf": "^6.5.0",
- From our package.json ...
- we can use
booleanContainsto determine if a Lat/Lng (Feature) are contained within an NC boundary (Geometry)- doc page: https://turfjs.org/docs/api/booleanContains
- Geocoder "result" is the object we receive when selecting an address
- in MapSearch.jsx, L120:
this.geocoder.on('result', ({result}) => { ... } - see example of
resultobject in dropdown - I couldn't find Mapbox documentation for MapboxGeocoder's
on('result', ...), feel free to have a look at the Geocoder API page
- in MapSearch.jsx, L120:
Example of MapSearch.jsx this.geocoder.on('result', ...) JSON Object
When searching "1938 S Bedford Street" and clicking on the dropdown menu item:
{
"id": "address.4043252588369924",
"type": "Feature",
"place_type": [
"address"
],
"relevance": 1,
"properties": {
"accuracy": "rooftop",
"mapbox_id": "dXJuOm1ieGFkcjowODY5YWU4OC0xYjQ3LTQ2NjAtYjhlYy0yNjg1ZTZjZDJhNjg"
},
"text_en-US": "South Bedford Street",
"place_name_en-US": "1938 South Bedford Street, Los Angeles, California 90034, United States",
"text": "South Bedford Street",
"place_name": "1938 South Bedford Street, Los Angeles, California 90034, United States",
"center": [
-118.383005,
34.042748
],
"geometry": {
"type": "Point",
"coordinates": [
-118.383005,
34.042748
]
},
"address": "1938",
"context": [
{
"id": "neighborhood.339086572",
"mapbox_id": "dXJuOm1ieHBsYzpGRFlNN0E",
"text_en-US": "La Cienega Heights",
"text": "La Cienega Heights"
},
{
"id": "postcode.300297964",
"mapbox_id": "dXJuOm1ieHBsYzpFZVl1N0E",
"text_en-US": "90034",
"text": "90034"
},
{
"id": "place.192407788",
"mapbox_id": "dXJuOm1ieHBsYzpDM2ZvN0E",
"wikidata": "Q65",
"text_en-US": "Los Angeles",
"language_en-US": "en",
"text": "Los Angeles",
"language": "en"
},
{
"id": "district.14051052",
"mapbox_id": "dXJuOm1ieHBsYzoxbWJz",
"wikidata": "Q104994",
"text_en-US": "Los Angeles County",
"language_en-US": "en",
"text": "Los Angeles County",
"language": "en"
},
{
"id": "region.419052",
"mapbox_id": "dXJuOm1ieHBsYzpCbVRz",
"wikidata": "Q99",
"short_code": "US-CA",
"text_en-US": "California",
"language_en-US": "en",
"text": "California",
"language": "en"
},
{
"id": "country.8940",
"mapbox_id": "dXJuOm1ieHBsYzpJdXc",
"wikidata": "Q30",
"short_code": "us",
"text_en-US": "United States",
"language_en-US": "en",
"text": "United States",
"language": "en"
}
]
}
Ready for dev lead to approve this for Prioritized Backlog
Before moving forward, I'd like to discuss with the team possibilities for us to identify when an address is not within one of the neighborhood councils.
Discussed with @ryanfchase , please share the Mapbox function to search that the Address input value (lLatLng) is within a NC polygon
Overview
The way I had in mind, we can use Turf.js to calculate whether or not an address (lat/lng) is encapsulated by a Neighborhood Council address. @traycn Can you evaluate and lmk if this is sufficient info? I will adjust action items if they look ok.
- FYI our current build already utilizes Turf.js as a dependency:
- From our package.json ...
"@turf/turf": "^6.5.0",
- From our package.json ...
- we can use
booleanContainsto determine if a Lat/Lng (Feature) are contained within an NC boundary (Geometry)- doc page: https://turfjs.org/docs/api/booleanContains
- Geocoder "result" is the object we receive when selecting an address
- in MapSearch.jsx, L120:
this.geocoder.on('result', ({result}) => { ... } - see example of
resultobject in dropdown below - I couldn't find Mapbox documentation for MapboxGeocoder's
on('result', ...), feel free to have a look at the Geocoder API page
- in MapSearch.jsx, L120:
Proposed Action Items
- in MapSearch.jsx, L120, modify this inline function to do the following
- loop through all Neighborhood Council geometry objects
- use Turf's
booleanContainsto determine if ONE NC "contains" the position in the result- if not, display the error that is mocked up by design.
- clear the address box
Resources
On.Result Object
Example of Result Object
When searching "1938 S Bedford Street" and clicking on the dropdown menu item:
{
"id": "address.4043252588369924",
"type": "Feature",
"place_type": [
"address"
],
"relevance": 1,
"properties": {
"accuracy": "rooftop",
"mapbox_id": "dXJuOm1ieGFkcjowODY5YWU4OC0xYjQ3LTQ2NjAtYjhlYy0yNjg1ZTZjZDJhNjg"
},
"text_en-US": "South Bedford Street",
"place_name_en-US": "1938 South Bedford Street, Los Angeles, California 90034, United States",
"text": "South Bedford Street",
"place_name": "1938 South Bedford Street, Los Angeles, California 90034, United States",
"center": [
-118.383005,
34.042748
],
"geometry": {
"type": "Point",
"coordinates": [
-118.383005,
34.042748
]
},
"address": "1938",
"context": [
{
"id": "neighborhood.339086572",
"mapbox_id": "dXJuOm1ieHBsYzpGRFlNN0E",
"text_en-US": "La Cienega Heights",
"text": "La Cienega Heights"
},
{
"id": "postcode.300297964",
"mapbox_id": "dXJuOm1ieHBsYzpFZVl1N0E",
"text_en-US": "90034",
"text": "90034"
},
{
"id": "place.192407788",
"mapbox_id": "dXJuOm1ieHBsYzpDM2ZvN0E",
"wikidata": "Q65",
"text_en-US": "Los Angeles",
"language_en-US": "en",
"text": "Los Angeles",
"language": "en"
},
{
"id": "district.14051052",
"mapbox_id": "dXJuOm1ieHBsYzoxbWJz",
"wikidata": "Q104994",
"text_en-US": "Los Angeles County",
"language_en-US": "en",
"text": "Los Angeles County",
"language": "en"
},
{
"id": "region.419052",
"mapbox_id": "dXJuOm1ieHBsYzpCbVRz",
"wikidata": "Q99",
"short_code": "US-CA",
"text_en-US": "California",
"language_en-US": "en",
"text": "California",
"language": "en"
},
{
"id": "country.8940",
"mapbox_id": "dXJuOm1ieHBsYzpJdXc",
"wikidata": "Q30",
"short_code": "us",
"text_en-US": "United States",
"language_en-US": "en",
"text": "United States",
"language": "en"
}
]
}
RFC7946 referenced in Turf.js docs:
Section 1.4: Definitions
Link: Section 1.4: Definitions
Geometries
o Inside this document, the term "geometry type" refers to seven
case-sensitive strings: "Point", "MultiPoint", "LineString",
"MultiLineString", "Polygon", "MultiPolygon", and
"GeometryCollection".
GeoJSON Types (includes Geometries)
o As another shorthand notation, the term "GeoJSON types" refers to
nine case-sensitive strings: "Feature", "FeatureCollection", and
the geometry types listed above.
Collections are just arrays
o The word "Collection" in "FeatureCollection" and
"GeometryCollection" does not have any significance for the
semantics of array members. The "features" and "geometries"
members, respectively, of these objects are standard ordered JSON
arrays, not unordered sets.
Section 3.1: Geometry Objects
Geometry object vs GeoJSON object
A Geometry object represents points, curves, and surfaces in
coordinate space. Every Geometry object is a GeoJSON object no
matter where it occurs in a GeoJSON text.
Geometries are not debatable!
o The value of a Geometry object's "type" member MUST be one of the
seven geometry types (see Section 1.4).
All Geometries have coordinates
o A GeoJSON Geometry object of any type other than
"GeometryCollection" has a member with the name "coordinates".
The value of the "coordinates" member is an array. The structure
of the elements in this array is determined by the type of
geometry. GeoJSON processors MAY interpret Geometry objects with
empty "coordinates" arrays as null objects.
Section 3.1.1: Position
Link: Section 3.1.1: Position
Abridged definition of Position (as it pertains to geocoder results & NC boundaries)
A position is the fundamental geometry construct. The "coordinates"
member of a Geometry object is composed of either:
o one position in the case of a Point geometry,
...
o an array of LineString or linear ring (see [Section 3.1.6](https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.6))
coordinates in the case of a Polygon or MultiLineString geometry,
...
Basic requirements for "position"
A position is an array of numbers. There MUST be two or more
elements. The first two elements are longitude and latitude, or
easting and northing, precisely in that order and using decimal
numbers. Altitude or elevation MAY be included as an optional third
element.
Section 3.2: Feature
Link: Section 3.2: Feature
Features are GeoJSON objects
A Feature object represents a spatially bounded thing. Every Feature
object is a GeoJSON object no matter where it occurs in a GeoJSON
text.
Properties are where we store information about the Feature
o A Feature object has a member with the name "properties". The
value of the properties member is an object (any JSON object or a
JSON null value).
Approve the Proposed Action Items. Updated the issue with the action items.
This ticket is ready for picking up.
Question for design lead
- [ ] Do we want to clear the address search IMMEDIATELY once we determine that the searched address is not within one of our neighborhood councils?
@ryanfchase the address shouldn't clear immediately, here is my reasoning:
- Prevents user frustration from losing data they have already entered.
- Allows users to easily identify and correct errors without retyping everything.
- Clearing address is not necessary for security purposes as should generally not be protected information in this use-case
please let me know if you/pm team have any concerns!
Request review from dev lead based on the answer to our earlier question:
- Q: https://github.com/hackforla/311-data/issues/1896#issuecomment-2645901154
- A: https://github.com/hackforla/311-data/issues/1896#issuecomment-2646090339
Going to any references for the same conditions of this ticket to share here. Reviewed requested design functionality:
- Keep address input value
This needs to go back to design lead, for a more accessible notification. The red on dark background is not going to pass accessability standards.
The original color passed AA accessibility but I'm never opposed to increasing accessibility. I increased the brightness and saturation of the original hue to FF3003, which increases the color contrast to 4.85:1 which is AAA for this font size+weight (14 bold).
Product team please let me know if providing the hex code is sufficient or if you'd prefer any additional deliverables. Thank you!
Error Text Color
FF3003
Thanks @Joy-Truex, let's move forward with this new color you've provided. I will update the ticket to reflect this change.
Availability: Weekday Evenings ETA: 6/17 End of Day
@DorianDeptuch FYI I added some post-PR Action Items. Bonnie is having volunteers do it so that PMs aren't chasing down tickets that need to be released from the icebox. Here are the Action Items that I just added to your ticket:
- [ ] once PR has been merged, release #1960:
- [ ] Move #1960 from Icebox (on hold) (https://github.com/orgs/hackforla/projects/63/views/1?filterQuery=status%3A%22Icebox+%28on+hold%29%22) to New Issue Approval (https://github.com/orgs/hackforla/projects/63/views/1?filterQuery=status%3A%22New+Issue+Approval%22)
- [ ] remove label: https://github.com/hackforla/311-data/labels/Dependency
- [ ] add label: https://github.com/hackforla/311-data/labels/ready%20for%20dev%20lead
@DorianDeptuch
Hi Dorian, please provide your weekly update. You can always add more info to the items below 1-4, which are the required minimum.
Instructions
- Progress: "What is the current status of your project? What have you completed and what is left to do?"
- Blockers: "Difficulties or errors encountered."
- Availability: "How much time will you have this week to work on this issue?"
- ETA: "When do you expect this issue to be completed?"
- Pictures (if necessary): "Add any pictures that will help illustrate what you are working on."
- Progress:
- Blockers:
- Availability:
- ETA:
- Pictures (if necessary):
Progress: Have not started Availability: Weekday Evenings ETA: 8/15 End of Day
@DorianDeptuch
Hi Dorian -- any update on this? Are you needing help getting started or are you in a busy period? Let us know in case we need to cycle this ticket over to another volunteer.
Instructions
- Progress: "What is the current status of your project? What have you completed and what is left to do?"
- Blockers: "Difficulties or errors encountered."
- Availability: "How much time will you have this week to work on this issue?"
- ETA: "When do you expect this issue to be completed?"
- Pictures (if necessary): "Add any pictures that will help illustrate what you are working on."
- Progress:
- Blockers:
- Availability:
- ETA:
- Pictures (if necessary):
Unassigning myself due to a limited availability
@ykimdeveloper I need to unassign you: please move this to in-progress then assign if you are prepared to pick up the ticket, as well as provide an ETA and availability. Otherwise, this prevents others from getting started sooner.
Availability: Weekday Evenings & Weekends ETA: 11/08