<commit_before><?php

class ArcGISPolyline implements MapPolyline
{
    protected $points;
    protected $centerCoordinate;

    public function getPoints()
    {
        return $this->points;
    }

    public function __construct($geometry)
    {
        $this->points = $geometry;

        $totalLat = 0;
        $totalLon = 0;
        $n = count($this->points);
        foreach ($this->points as $point) {
            $totalLat += $point['lat'];
            $totalLon += $point['lon'];
        }
        $this->centerCoordinate = array('lat' => $totalLat / $n,
                                        'lon' => $totalLon / $n);
    }

    public function getCenterCoordinate()
    {
        return $this->centerCoordinate;
    }

    public function serialize() {
        return serialize(
            array(
                'points' => serialize($this->points),
                'centerCoordinate' => serialize($this->centerCoordinate),
            ));
    }

    public function unserialize($data) {
        $data = unserialize($data);
        $this->points = unserialize($data['points']);
        $this->centerCoordinate = unserialize($data['centerCoordinate']);
    }
}<commit_msg>fix incorrect JSON structure expected in ArcGISPolyline constructor<commit_after><?php

class ArcGISPolyline implements MapPolyline
{
    protected $points;
    protected $centerCoordinate;

    public function getPoints()
    {
        return $this->points;
    }

    public function __construct($geometry)
    {
        $totalLat = 0;
        $totalLon = 0;

        if (isset($geometry['paths'])) {
            // TODO: this assumes all paths are connected
            // this entire structure may need rethinking if this isn't the case
            $this->points = array();
            foreach ($geometry['paths'] as $currentPath) {
                foreach ($currentPath as $xy) {
                    $this->points[] = array('lon' => $xy[0], 'lat' => $xy[1]);
                }
            }
        }

        else {
            // this is how we expect geometry to be passed if constructed via
            // ArcGISPolygon
            $this->points = $geometry;
            foreach ($this->points as $point) {
                $totalLat += $point['lat'];
                $totalLon += $point['lon'];
            }
        }
        $n = count($this->points);
        $this->centerCoordinate = array('lat' => $totalLat / $n,
                                        'lon' => $totalLon / $n);
    }

    public function getCenterCoordinate()
    {
        return $this->centerCoordinate;
    }

    public function serialize() {
        return serialize(
            array(
                'points' => serialize($this->points),
                'centerCoordinate' => serialize($this->centerCoordinate),
            ));
    }

    public function unserialize($data) {
        $data = unserialize($data);
        $this->points = unserialize($data['points']);
        $this->centerCoordinate = unserialize($data['centerCoordinate']);
    }
}
{'fraction_non_alphanumeric': 0.1315702479338843, 'fraction_numerical': 0.0019834710743801653, 'mean_word_length': 1.8386491557223263, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6940499', 'n_tokens_mistral': 816, 'n_tokens_neox': 784, 'n_words': 184}