[gnome-maps/wip/mlundblad/transit-plugin-gtfs-local: 2/4] WIP: Add class representing a stop in a GTFS feed
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/transit-plugin-gtfs-local: 2/4] WIP: Add class representing a stop in a GTFS feed
- Date: Sun, 23 Feb 2020 20:25:50 +0000 (UTC)
commit ff34c58c141377530d8e004933c86fa60d274cf0
Author: Marcus Lundblad <ml update uu se>
Date: Sun Feb 23 14:42:37 2020 +0100
WIP: Add class representing a stop in a GTFS feed
lib/maps-gtfs-stop.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++
lib/maps-gtfs-stop.h | 58 ++++++++++++++++++++++++++
lib/maps.h | 1 +
lib/meson.build | 2 +
4 files changed, 173 insertions(+)
---
diff --git a/lib/maps-gtfs-stop.c b/lib/maps-gtfs-stop.c
new file mode 100644
index 00000000..b35ec018
--- /dev/null
+++ b/lib/maps-gtfs-stop.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2020 Marcus Lundblad
+ *
+ * GNOME Maps 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 2 of the License, or (at your
+ * option) any later version.
+ *
+ * GNOME Maps 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 GNOME Maps; if not, see <http://www.gnu.org/licenses/>
+ *
+ * Author: Marcus Lundblad <ml update uu se>
+ */
+
+#include "maps-gtfs-stop.h"
+
+typedef struct
+{
+ gchar *id;
+ gchar *code;
+ gchar *name;
+ gchar *desc;
+ float lat;
+ float lon;
+ MapsGTFSStopLocationType location_type;
+ gchar *parent_station;
+ GTimeZone *timezone;
+} MapsGTFSStopPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (MapsGTFSStop, maps_gtfs_stop, G_TYPE_OBJECT)
+
+enum {
+ PROP_0,
+ N_PROPS
+};
+
+static GParamSpec *properties [N_PROPS];
+
+/**
+ * maps_gtfs_stop_new:
+ *
+ * Create a new #MapsGTFSStop.
+ *
+ * Returns: (transfer full): a newly created #MapsGTFSStop
+ */
+MapsGTFSStop *
+maps_gtfs_stop_new (gchar *id, gchar *code, gchar *name, gchar *desc,
+ float lat, float lon,
+ MapsGTFSStopLocationType location_type,
+ gchar *parent_station, GTimeZone *timezone)
+{
+ return g_object_new (MAPS_TYPE_GTFS_STOP, NULL);
+}
+
+static void
+maps_gtfs_stop_finalize (GObject *object)
+{
+ MapsGTFSStop *self = (MapsGTFSStop *)object;
+ MapsGTFSStopPrivate *priv = maps_gtfs_stop_get_instance_private (self);
+
+ G_OBJECT_CLASS (maps_gtfs_stop_parent_class)->finalize (object);
+}
+
+static void
+maps_gtfs_stop_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ MapsGTFSStop *self = MAPS_GTFS_STOP (object);
+
+ switch (prop_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+maps_gtfs_stop_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ MapsGTFSStop *self = MAPS_GTFS_STOP (object);
+
+ switch (prop_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+maps_gtfs_stop_class_init (MapsGTFSStopClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = maps_gtfs_stop_finalize;
+ object_class->get_property = maps_gtfs_stop_get_property;
+ object_class->set_property = maps_gtfs_stop_set_property;
+}
+
+static void
+maps_gtfs_stop_init (MapsGTFSStop *self)
+{
+}
diff --git a/lib/maps-gtfs-stop.h b/lib/maps-gtfs-stop.h
new file mode 100644
index 00000000..63fb7fb0
--- /dev/null
+++ b/lib/maps-gtfs-stop.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2020 Marcus Lundblad
+ *
+ * GNOME Maps 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 2 of the License, or (at your
+ * option) any later version.
+ *
+ * GNOME Maps 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 GNOME Maps; if not, see <http://www.gnu.org/licenses/>
+ *
+ * Author: Marcus Lundblad <ml update uu se>
+ */
+
+#pragma once
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/**
+ * MapsGTFSStopLocationType:
+ * @MAPS_GTFS_STOP_STOP: Stop or platform.
+ * @MAPS_GTFS_STOP_STATION: A physical structure or area that contains one or more platform.
+ * @MAPS_GTFS_STOP_ENTRANCE_EXIT: Entrance or exit to/from a station.
+ * @MAPS_GTFS_STOP_GENERIC_NODE: A location within a station.
+ * @MAPS_GTFS_STOP_BOARDING_AREA: A specific location on a platform, where passengers can board and/or
alight vehicles.
+ */
+typedef enum
+{
+ MAPS_GTFS_STOP_STOP = 0,
+ MAPS_GTFS_STOP_STATION = 1,
+ MAPS_GTFS_STOP_ENTRANCE_EXIT = 2,
+ MAPS_GTFS_STOP_GENERIC_NODE = 3,
+ MAPS_GTFS_STOP_BOARDING_AREA = 4
+} MapsGTFSStopLocationType;
+
+#define MAPS_TYPE_GTFS_STOP (maps_gtfs_stop_get_type())
+
+G_DECLARE_DERIVABLE_TYPE (MapsGTFSStop, maps_gtfs_stop, MAPS, GTFS_STOP, GObject)
+
+struct _MapsGTFSStopClass
+{
+ GObjectClass parent_class;
+};
+
+MapsGTFSStop *maps_gtfs_stop_new (gchar *id, gchar *code, gchar *name, gchar *desc,
+ float lat, float lon,
+ MapsGTFSStopLocationType location_type,
+ gchar *parent_station, GTimeZone *timezone);
+
+G_END_DECLS
+
diff --git a/lib/maps.h b/lib/maps.h
index a6916d2b..949840a4 100644
--- a/lib/maps.h
+++ b/lib/maps.h
@@ -21,5 +21,6 @@
#include <glib-object.h>
#include "maps-contact-store.h"
#include "maps-contact.h"
+#include "maps-gtfs-stop.h"
#endif
diff --git a/lib/meson.build b/lib/meson.build
index 401325f6..170d43d9 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -5,6 +5,7 @@ headers_private = files(
'maps-contact-store.h',
'maps-file-tile-source.h',
'maps-gtfs-agency.h',
+ 'maps-gtfs-stop.h',
'maps-osm.h',
'maps-osm-changeset.h',
'maps-osm-node.h',
@@ -19,6 +20,7 @@ sources = files(
'maps-contact-store.c',
'maps-file-tile-source.c',
'maps-gtfs-agency.c',
+ 'maps-gtfs-stop.c',
'maps-osm.c',
'maps-osm-changeset.c',
'maps-osm-node.c',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]