Välkommen till Trafiklab:s användare- och supportforum! Ställ frågor, rapportera problem och hjälp oss med förslag och idéer!
Vid felrapporter ber vi dig inkludera exakt API-namn och om möjligt ett exempelanrop för att underlätta felsökningen. Glöm inte att ta bort din API-nyckel när du delar ditt exempelanrop.
Undrar du hur du får tillgäng Trafiklabs data? Läs vår introduktion här: https://www.trafiklab.se/hur-gor-jag
Welcome to Trafiklab's user and supportforum. Ask questions, report issues and help us improve with suggestions and ideas!
If you open a new issue, please always include the exact API you're talking about, and, if applicable, include a sample request so we can check if contains the right parameters. Don't forget to remove your API keys when sharing example requests.
Välkommen till Trafiklab:s kund- och supportforum! Ställ frågor, rapportera problem och hjälp oss med förslag och idéer!
All of the requests below will return a Response with the value of Type being StopPoint, meaning that the requests are being interpreted as StopPoint requests.
http://api.sl.se/api2/LineData.xml?model=Stop&key=XXX
http://api.sl.se/api2/LineData.xml?model=StopPoint&key=XXX
http://api.sl.se/api2/LineData.xml?model=StopArea&key=XXX
http://api.sl.se/api2/LineData.xml?model=StopFooBar&key=XXX
// Kevin
I meant the xml files I extracted using StopPoint or StopArea. They look the same.
I am using R to read and process the xml files. I hope the codes are self-explanatory.
X1 <- read_xml ("http://api.sl.se/api2/LineData.xml?model=StopArea&key=MYKEY")%>%
x1 <- as_list (x1)
y1 <- x1 $ ResponseData
x2 <- read_xml ( "Http://api.sl.se/api2/LineData.xml?model=StopPoint&key=MYKEY")%>%
x2 <- as_list (x2)
y2 <- x2 $ ResponseData
Then I unlist and make y1, y2, as data.frame. Both return 13183 rows and 9 columns.
The column names are
[8] "StopPointNumber"
[2] "StopPointNumber"
[3] "StopAreaNumber"
[4] "LocationNorthingCoordinate"
[5] "LocationEastingCoordinate"
[6] "ZoneShortName"
[7] "StopAreaTypeCode"
[8] "LastModifiedUtcDateTime"
[9 ] "ExistsFromDate"
And the data look identical.
By the way, I also get identical results from querying JourneyPattern and JourneyPatternPointOnline.
I'm guessing that you're confused by the documentation (which, to be fair, I was as well) that can be found here: https://www.trafiklab.se/api/sl-hallplatser-och-linjer-2/dokumentation
The different concepts described at the top of the page are not acceptable values for the "model" parameter in the request. Instead they are listed as sub-headers under the large header called "Example". There you will find sub-headers like "site", "StopPoint", "line", "JourneyPatternPointOnline" and "transportMode". These are the values that you would want to use in your model-parameter during requests.
This would also explain why you get the same result when using "JourneyPattern" and "JourneyPatternPointOnline" as the model-parameter, they are both returning a JourneyPatternPointOnline response.
// Kevin
A followup question:
one column in JourneyPatternPointOnline is JourneyPatternPointNumber, which I assume matches StopPointNumber in StopPoint.
Let's say
a = JourneyPatternPointOnline$JourneyPatternPointNumber
b = StopPoint$StopPointNumber
But the number of unique value of a is 11615, and the number of unique value of b is 13170. The number of intersection between a and b is 10845.
Is there anything unexpected here?
You are correct however that a JourneyPatternPointNumber should match a StopPointNumber.
// Kevin
11615 is not a value in a. It is the total number of distinct values in a.
Similarly the number of non-repeating values in b is 13170.
10845 is the number of overlap between distinct a and distinct b.
That is to say, a and b are not fully matched.
I hope this time I made it clear.
/Otto
If you've found a JourneyPatternPointNumber that has no matching StopPointNumber, something might be wrong with the data. Is this the case, and if yes, could you give some examples?
// Kevin
I double checked the data I extracted from .xml files.
Somehow the StopPointNumber is recognised as integer, instead of character like JourneyPatternPointNumber. I figured this by adding one or two zeros in front of some integers. So the number I mentioned earlier was wrong. But the issue still exists.
I found 303 JourneyPatternPointNumber that are not included in StopPointNumber. Examples are:
"00139" "00141" "00144" "00145" "00147" "00163"
....
"68008" "68007" "68817" "68816" "68508" "68509"
Could you check it from your side?
Thank you again and have a nice weekend.
// Kevin