Replies: 3 comments 5 replies
-
Strict typingDilemaI found an interesting point that I would like. to address - the trade-off between strictness and flexibility in the new version of the library. Here's the dilemma: On one hand, if we introduce strict typing and enforce mandatory properties as per the GPX schema, we could potentially achieve more reliable and bug-free code. This would ensure that all necessary properties are present and correctly typed, leading to a more robust library. However, on the other hand, this could limit the usability of the library for GPX files that are missing minor attributes. For example, if a GPX file does not include the 'name' attribute within the copyright section, under strict rules, it would be deemed "invalid", preventing the library from processing it, despite the rest of the file being perfectly valid and usable. Let's take a look at an example GPX file: <gpx>
<metadata>
<name>Example GPX</name>
<copyright>
<!-- Missing 'name' attribute here -->
<year>2023</year>
<license>http://example.com/license</license>
</copyright>
</metadata>
<!-- More GPX data -->
</gpx> With strict typing and enforced mandatory attributes, this GPX file would be considered invalid due to the absence of the 'name' attribute in the copyright element. This could restrict the library from processing it. Hence, the challenge we face is to determine the right balance between maintaining the strictness that comes with adherence to the GPX schema, and ensuring the flexibility to handle GPX files which may not completely follow the schema. SolutionProperties will be defined as nullable for the sake of input flexibility. The values will be converted to correct type if possible. |
Beta Was this translation helpful? Give feedback.
-
MiddlewaresThe additional computational processes for statistical analysis can be managed through middleware that implement the library interface. These middleware will execute in a specified sequence, post GPX parsing, following the basic statistical computations (or the library may include some middleware for elementary stats by default). To better understand my concept, consider the code below. It is merely a rough draft, hence open to modifications. $phpgpx = new \phpGPX();
$phpgpx->middlewares->add(new \phpGPX\Middlewares\GpxReductionSmoothingMiddleware(2, 5));
$phpgpx->middlewares->add(new \phpGPX\Middlewares\TrackPointExtensionStatsMiddleware());
$phpgpx->middlewares->add(new CustomMiddleware());
$file = $phpgpx->load('example.gpx'); Implementing such a layer should substantially simplify the extension or modification of the library's behavior. I aim to develop a preliminary model for this layer. This should enhance the library's configurability (I'm not particularly fond of the current use of constants for this purpose). |
Beta Was this translation helpful? Give feedback.
-
Removal of Summarizable and toArrayAs part of the new major release, I propose the removal of the The usage of arrays in this context seems antiquated and unnecessarily complex, hence it doesn't align with the direction of our project. I anticipate that the removal of these features won't be a significant loss for the users. However, I welcome any thoughts and potential concerns about this proposed change. |
Beta Was this translation helpful? Give feedback.
-
Motivation
Greetings, all! It's been quite a few years since the
1.x
release of the phpGPX library, which was built upon an API from way back in 2018. That version harks back to the PHP5 era, and since then, we've seen the introduction of PHP 7.x and 8.x. It seems like the right time to begin contemplating a significant update for phpGPX, an exciting opportunity to incorporate lessons learned from past mistakes, and integrate some of the innovative features now available in PHP such as typing - a function that would be particularly fitting for this project.This discussion post serves as a platform for me to collate my thoughts and ideas, and for you to provide your invaluable feedback and suggestions. I welcome any ideas for new features, or alternative viewpoints on the plans I've proposed. This is an open discussion, so if you disagree with any aspect of the plan, feel free to voice your thoughts, and we'll take it from there.
Proposed Changes and Improvements
Summarizable
interface and it'stoArray
method. Models will use \JsonSerializable interface and return GeoJSONInteresting Aspects
1.x
and2.x
.Project Roadmap
All ideas and suggestions are welcome! I'm excited to see where this journey takes us. The future 2.x version lives in
develop
branch.Beta Was this translation helpful? Give feedback.
All reactions