Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Changed id type to Union{Int, String} #101

Conversation

AzilAverakot
Copy link

Added functionality to handle String ids.

@AzilAverakot AzilAverakot force-pushed the feature/LRS_added_functionality_to_ingest_MM_file branch from 442dc16 to 5d4bfbf Compare March 6, 2024 22:51
Project.toml Outdated Show resolved Hide resolved
src/constants.jl Outdated Show resolved Hide resolved
src/graph_utilities.jl Outdated Show resolved Hide resolved
Maps node id to index.
"""
node_id_to_index(g::OSMGraph, x::String) = g.node_to_index[x]
node_id_to_index(g::OSMGraph, x::Vector{<:String}) = [node_id_to_index(g, i) for i in x]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't need this if x is typed parametrically


Maps node index to dijkstra state (parents).
"""
index_to_dijkstra_state(g::OSMGraph, x::String) = g.dijkstra_states[x]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here


"""
node_id_to_dijkstra_state(g::OSMGraph, x::Integer)

Maps node id to dijkstra state (parents).
"""
node_id_to_dijkstra_state(g::OSMGraph, x::Integer) = g.dijkstra_states[node_id_to_index(g, x)]
"""
node_id_to_dijkstra_state(g::OSMGraph, x::String)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link

codecov bot commented Mar 6, 2024

Codecov Report

Attention: Patch coverage is 76.59574% with 11 lines in your changes are missing coverage. Please review.

Project coverage is 81.05%. Comparing base (c5a0b8f) to head (fd12a51).

Files Patch % Lines
src/graph_utilities.jl 41.66% 7 Missing ⚠️
src/parse.jl 66.66% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #101      +/-   ##
==========================================
+ Coverage   80.03%   81.05%   +1.02%     
==========================================
  Files          15       15              
  Lines        1142     1151       +9     
==========================================
+ Hits          914      933      +19     
+ Misses        228      218      -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/graph_utilities.jl Outdated Show resolved Hide resolved
src/graph_utilities.jl Outdated Show resolved Hide resolved
src/graph_utilities.jl Outdated Show resolved Hide resolved
src/nearest_node.jl Outdated Show resolved Hide resolved
src/nearest_node.jl Outdated Show resolved Hide resolved
src/nearest_way.jl Outdated Show resolved Hide resolved
@AzilAverakot AzilAverakot force-pushed the feature/LRS_added_functionality_to_ingest_MM_file branch 14 times, most recently from 98e9dbc to b9408a2 Compare March 12, 2024 22:05
src/graph.jl Outdated Show resolved Hide resolved
@AzilAverakot AzilAverakot force-pushed the feature/LRS_added_functionality_to_ingest_MM_file branch from b9408a2 to 18e73d4 Compare March 13, 2024 22:39
src/types.jl Show resolved Hide resolved
src/types.jl Show resolved Hide resolved
src/types.jl Show resolved Hide resolved
src/types.jl Show resolved Hide resolved
src/types.jl Show resolved Hide resolved
src/types.jl Show resolved Hide resolved
src/parse.jl Outdated
@@ -342,7 +343,9 @@ function init_graph_from_object(osm_xml_object::XMLDocument,
filter_network_type::Bool=true
)::OSMGraph
dict_to_parse = osm_dict_from_xml(osm_xml_object)
id_type = typeof(dict_to_parse["node"][1]["id"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment in parse_osm_network_dict function

src/parse.jl Outdated
@@ -357,7 +360,9 @@ function init_graph_from_object(osm_json_object::AbstractDict,
filter_network_type::Bool=true
)::OSMGraph
dict_to_parse = osm_dict_from_json(osm_json_object)
id_type = typeof(dict_to_parse["node"][1]["id"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment in parse_osm_network_dict function

src/parse.jl Outdated
network_type::Symbol=:drive;
filter_network_type::Bool=true
)::OSMGraph
U = DEFAULT_OSM_INDEX_TYPE
T = DEFAULT_OSM_ID_TYPE
T = id_type
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do the check here so you don't need the id_type as a new input arg

Suggested change
T = id_type
T = get_id_type(osm_network_dict)

where

function get_id_type(osm_network_dict::AbstractDict)::Type
    if isempty(dict_to_parse["node"])
        return Int64
    end
    
    first_id = dict_to_parse["node"][1]["id"]

    if first_id isa Integer
        return Int64
    elseif first_id isa String
        return String
    else
        throw(ErrorException("OSM ID type not supported: $(typeof(first_id))"))
    end
end

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also write a doc string describing what is happening and the assumptions we're making:

  1. if the node set is empty we assume IDs are Int32
  2. if first node id is of an Integer type we also assume Int32
  3. if first node id is a String then we assume String

Hybrid types are not supported

test/nearest_node.jl Outdated Show resolved Hide resolved
@AzilAverakot AzilAverakot force-pushed the feature/LRS_added_functionality_to_ingest_MM_file branch 3 times, most recently from a562b27 to 221e90b Compare March 14, 2024 01:22
@captchanjack captchanjack force-pushed the feature/LRS_added_functionality_to_ingest_MM_file branch from 3bba159 to fd12a51 Compare March 14, 2024 02:32
@captchanjack
Copy link
Collaborator

Lgtm

@captchanjack captchanjack reopened this Mar 14, 2024
@captchanjack captchanjack merged commit c30254c into DeloitteOptimalReality:master Mar 14, 2024
11 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants