ademseh / adem_sehirgel

0 stars 0 forks source link

Gazetteer review #1

Open itcareerswitch opened 5 months ago

itcareerswitch commented 5 months ago
itcareerswitch commented 5 months ago
<?php

    /* getCountryISO2AndName.php */

    // The first two lines provide error reporting when the routine is called from a browser, eg:

    // https://coding.itcareerswitch.co.uk/preparatory-task/example-website/libs/php/getCountryISO2AndName.php

    // Remove or comment them out once you are sure that the routine is stable.

    ini_set('display_errors', 'On');
    error_reporting(E_ALL); 

    // Set the return header

    header('Content-Type: application/json; charset=UTF-8');

    // start recording the time taken

    $executionStartTime = microtime(true);

    // Open the file and seralise it to an associative array by using the optional
    // json_decode parameter TRUE. Omitting this will create an object instead.

  $countryData = json_decode(file_get_contents("countryBorders.geo.json"), true);

    // Test that it worked

    if (is_null($countryData)) {

        $output['status']['code'] = "400";
        $output['status']['name'] = "failure";
        $output['status']['executedIn'] = intval((microtime(true) - $executionStartTime) * 1000) . " ms";

    } else {

        // Create output array

        $country = [];

        // Loop through objects

        foreach ($countryData['features'] as $feature) {

            // Create a temporary variable, add two properties to it
            // from current iteration and append it to the array

            $temp = null;
            $temp['code'] = $feature['properties']['iso_a2'];
            $temp['name'] = $feature['properties']['name'];

            array_push($country, $temp);

        }

        // Perform custom sort on name property of each object

        usort($country, function ($item1, $item2) {

            return $item1['name'] <=> $item2['name'];

        });

        $output['status']['code'] = "200";
        $output['status']['name'] = "ok";
        $output['status']['executedIn'] = intval((microtime(true) - $executionStartTime) * 1000) . " ms";
        $output['data'] = $country;

    }

    echo json_encode($output);

?>
ademseh commented 5 months ago

Hi Paddy,

I hope you’re doing well. I've been reviewing the latest version of the project and I have a few inquiries regarding certain details. I was not previously informed in my communication with the tutor.

Firstly, could you please provide more clarification on the implementation of "name marker groups in layers control"?

    Additionally,

At a glance: https://codepen.io/itcareerswitch/pen/mdQxgRx/094165febdac816a99a162d754f5679d Weather example: https://codepen.io/itcareerswitch/pen/vYzEBvX/58fd2357741ed73196232e5d295850e8 News example: https://codepen.io/itcareerswitch/pen/OJaypBQ/01f42a51bbea244d756dcbaf9496c1e5 Currency example: https://codepen.io/itcareerswitch/pen/dygBBam/a9c69b65f132c1f17c2552e72a244238

I understand that the UI differs in these examples, but I would appreciate insight into any underlying functional discrepancies.

Furthermore, there is mention of "Two PHP routines to return information from countryBorders.geo.json." This aspect was not outlined in the project explanation PDF.

Lastly, the requirement for PHP to include more extensive error checking has been noted. However, I am not sure about further actions to take in this regard.

Thank you for your attention to these matters.

Kind regards, Adem

On 30 Apr 2024, at 10:58, IT Career Switch @.***> wrote:

At a glance: https://codepen.io/itcareerswitch/pen/mdQxgRx/094165febdac816a99a162d754f5679d Weather example: https://codepen.io/itcareerswitch/pen/vYzEBvX/58fd2357741ed73196232e5d295850e8 News example: https://codepen.io/itcareerswitch/pen/OJaypBQ/01f42a51bbea244d756dcbaf9496c1e5 Currency example: https://codepen.io/itcareerswitch/pen/dygBBam/a9c69b65f132c1f17c2552e72a244238