[Mobilitydb-users] Loading Moving Feature JSON to Mobility DB?

Andrew Koure andrew at koure.org
Mon Apr 14 12:18:43 PDT 2025


Currently I am writing a python program to aggregate GTFS-RT vehicle
positions. I'm looking to both save this data in Moving Feature JSON for
archiving, and also load it to MobilityDB to build out some analysis.

Some example Moving Feature JSON from the program is here:
https://github.com/ankoure/gtfspb_2_mfjson/tree/main/sample_mf_json

The JSON is laid out in the toMFJSON method here:
https://github.com/ankoure/gtfspb_2_mfjson/blob/main/code/helpers/Entity.py

If it would be easier to load to mobilitydb using pymeos I'm open to
doing that as well. However I'm also not sure that I am laying out the
Moving Feature JSON correctly.


On Sat, Apr 12, 2025 at 7:44 AM SCHOEMANS Maxime <maxime.schoemans at ulb.be>
wrote:

> Hi Andrew,
>
> I believe that tgeompointFromMFJSON requires a TemporalGeometry object as
> input, instead of a full MovingFeature object.
> Could you try to use the value of your TemporalGeometry field as input
> instead of the complete JSON?
>
> Additionally, could you explain your use-case in more detail and maybe
> give an example MFJSON that you want to input in MobilityDB?
> Do you want to produce a single tgeompoint object out of it, or does the
> MFJSON also have additional temporal properties (speed, etc.) that you also
> want to input?
> This would give us a better idea of how these functions are used in
> practice.
> If these functions work differently to how you might expect them to, don't
> hesitate to let us know so we can potentially improve their documentation
> or their behavior.
>
> Best regards,
> Maxime
>
> On 12/04/2025 06:16, Andrew Koure via Mobilitydb-users wrote:
>
> Dear Esteban,
> Thanks for the advice!
>
> I am receiving this error: SQL Error [XX000]: ERROR: Invalid 'type' value
> in MFJSON string. The types for my TemporalProperties objects are
> "Measure", on temporalGeometry it is "MovingPoint", and the top level type
> is Feature.
>
> I suspect that I may not be formatting my MFJSON files correctly, is there
> a way to validate MFJSON easily? I can also send some examples if that is
> helpful.
>
> All the Best,
> Andrew
>
> On Fri, Apr 11, 2025 at 12:25 PM Esteban Zimanyi <estebanzimanyi at gmail.com>
> wrote:
>
>> Dear Andrew
>>
>> As part of our CI tests we do the following kind of queries to ensure
>> that the input/output for MFJSON works correctly.
>>
>> --------------------------------------------------------------
>> test=# SELECT COUNT(*) FROM tbl_tgeompoint WHERE asEWKT(temp) !=
>> asEWKT(tgeompointFromMFJSON(asMFJSON(temp)));
>>  count
>> -------
>>      0
>> (1 row)
>>
>>
>> test=# SELECT COUNT(*) FROM tbl_tgeompoint3D WHERE asEWKT(temp) !=
>> asEWKT(tgeompointFromMFJSON(asMFJSON(temp)));
>>  count
>> -------
>>      0
>> (1 row)
>>
>> test=# SELECT COUNT(*) FROM tbl_tgeogpoint WHERE asEWKT(temp) !=
>> asEWKT(tgeompointFromMFJSON(asMFJSON(temp)));
>>  count
>> -------
>>      0
>> (1 row)
>>
>> test=# SELECT COUNT(*) FROM tbl_tgeogpoint3D WHERE asEWKT(temp) !=
>> asEWKT(tgeompointFromMFJSON(asMFJSON(temp)));
>>  count
>> -------
>>      0
>> (1 row)
>> --------------------------------------------------------------
>>
>> Therefore you should be able to able to input and output in MFJSON format.
>>
>> Please let us know if you find any issues on this.
>>
>> Esteban
>>
>> On Fri, Apr 11, 2025 at 6:12 PM Andrew Koure via Mobilitydb-users <
>> mobilitydb-users at lists.osgeo.org> wrote:
>> >
>> > Hello All,
>> > I have a program that is generating moving feature JSON, and I am
>> looking to load the JSON into MobilityDB.
>> >
>> > Does anyone have guidance on how best to do this? I've tried looking
>> through the documentation for MovingPandas, MobilityDB, and MEOS. Most of
>> what I have found so far is for writing out to MFJSON.
>> >
>> > Thanks in Advance,
>> > Andrew
>> > _______________________________________________
>> > Mobilitydb-users mailing list
>> > Mobilitydb-users at lists.osgeo.org
>> > https://lists.osgeo.org/mailman/listinfo/mobilitydb-users
>>
>
> _______________________________________________
> Mobilitydb-users mailing listMobilitydb-users at lists.osgeo.orghttps://lists.osgeo.org/mailman/listinfo/mobilitydb-users
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mobilitydb-users/attachments/20250414/a53fb6d3/attachment.htm>


More information about the Mobilitydb-users mailing list