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

Add Ontario, Canada provider #70

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -77,5 +77,8 @@
SF, SEPTA,

// Australia
SYDNEY, MET
SYDNEY, MET,

// Canada
ONTARIO
}
@@ -0,0 +1,50 @@
/*
* Copyright 2015 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* @author Stephane Berube
*/
package de.schildbach.pte;

import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.Style;
import de.schildbach.pte.dto.Style.Shape;

public class OntarioProvider extends AbstractNavitiaProvider

This comment has been minimized.

@schildbach

schildbach Feb 10, 2016
Owner

You may want to put your name into a JavaDoc author tag here? See the other providers if you want that.

This comment has been minimized.

@chimo

chimo Feb 11, 2016
Author Contributor

Done!

{
private static String API_REGION = "ca-on";

public OntarioProvider(final String apiBase, final String authorization)
{
super(NetworkId.ONTARIO, apiBase, authorization);

setTimeZone("America/Toronto");
}

public OntarioProvider(final String authorization)
{
super(NetworkId.ONTARIO, authorization);

setTimeZone("America/Toronto");
}

@Override
public String region()
{
return API_REGION;
}
}
@@ -0,0 +1,81 @@
/*
* Copyright 2010-2015 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package de.schildbach.pte.live;

import static org.junit.Assert.assertEquals;

import java.util.Date;

import org.junit.Test;

import de.schildbach.pte.NetworkProvider.Accessibility;
import de.schildbach.pte.NetworkProvider.WalkSpeed;
import de.schildbach.pte.OntarioProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;

/**
* @author Stephane Berube
*/
public class OntarioProviderLiveTest extends AbstractNavitiaProviderLiveTest
{
public OntarioProviderLiveTest()
{
super(new OntarioProvider(secretProperty("navitia.authorization")));
}

@Test
public void nearbyStations() throws Exception
{
final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "OAW:SP:CH240"));
print(result);
}

@Test
public void nearbyStationsByCoordinate() throws Exception
{
final NearbyLocationsResult result = queryNearbyStations(Location.coord(45416667, -75683333));
print(result);
}

@Test
public void queryDepartures() throws Exception
{
final QueryDeparturesResult result = queryDepartures("OAW:SP:CH240", false);
print(result);
}

@Test
public void queryDeparturesInvalidStation() throws Exception
{
final QueryDeparturesResult result = queryDepartures("OAW:SP:CHxxx", false);
assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status);
}

@Test
public void suggestLocations() throws Exception
{
final SuggestLocationsResult result = suggestLocations("Airport");
print(result);
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.