knime-geospatial-extension
knime-geospatial-extension copied to clipboard
Google Distance Matrix node with support for traffic models
As a user I want to specify the traffic model to use when calculating the distances e.g. to get consistent results independent of the API call time or to compare worst case to best case reachable area. https://developers.google.com/maps/documentation/distance-matrix/distance-matrix#traffic_model
Also needs to include the departure time: https://developers.google.com/maps/documentation/distance-matrix/distance-matrix#departure_time However for letting the user pick a time we would need a date&time picker component in the Python nodes.
Moved milestone to 1.2 because of the dependency on the date&time picker (AP-20404)
Moved to 1.3 because date and time widget is not available yet.
For details about the parameter look at https://knime-python.readthedocs.io/en/latest/extension-development.html#parameters description of the knime.extension.DateTimeParameter or have a look at this example node with the different variants of the parameter:
@knext.node(
name="Python Date Time Parameter Node",
node_type=knext.NodeType.MANIPULATOR,
icon_path="icon.png",
category=node_category,
)
@knext.output_table(
name="Output Table",
description="Output table.",
)
class DateTimeParameterNode:
"""A node with a DateTimeParameter"""
date_time_param = knext.DateTimeParameter(
"Date Time Parameter",
"Basic parameter for date & time",
show_time=True,
show_seconds=True,
)
date_time_bounds_param = knext.DateTimeParameter(
"Date Time Parameter with bounds",
"Basic parameter for date & time with bounds",
show_time=True,
show_seconds=True,
min_value="2022-06-12",
max_value="2023-06-12",
)
date_time_timezone_param = knext.DateTimeParameter(
"Date Time Parameter with timezone",
"Basic parameter for date & time with timezone",
show_time=True,
show_seconds=True,
show_milliseconds=False,
timezone="America/Dawson_Creek",
)
date_time_with_format_param = knext.DateTimeParameter(
"Date Time Parameter with format",
"Basic parameter for date & time with format",
show_time=False,
show_seconds=False,
show_milliseconds=False,
date_format="%d-%m-%Y",
default_value="28-04-1996",
)
def configure(self, config_context):
tz_date_time_type = knext.datetime(timezone=True)
date_type = knext.datetime(time=False)
local_dt_type = knext.datetime()
columns = [
knext.Column(ktype=local_dt_type, name="Date Time"),
knext.Column(ktype=local_dt_type, name="Date Time with bounds"),
knext.Column(ktype=tz_date_time_type, name="Date Time with timezone"),
knext.Column(ktype=date_type, name="Date Time with format"),
]
return knext.Schema.from_columns(columns)
def execute(self, exec_context):
import pandas as pd
df = pd.DataFrame(
{
"Date Time": [self.date_time_param],
"Date Time with bounds": [self.date_time_bounds_param],
"Date Time with timezone": [self.date_time_timezone_param],
"Date Time with format": [self.date_time_with_format_param],
}
)
return knext.Table.from_pandas(df)