Encodes points

@param array $points
@param array $dists

@return string the encoded points
16892
private function createEncodings($points, $dists)
    {
        $plat = 0;
        $plng = 0;
        $encoded_points = '';

        for ($i = 0; $i < count($points); $i++) {
            if (isset($dists[$i]) || $i == 0 || $i == count($points) - 1) {
                $point = $points[$i];
                $lat = $point[0];
                $lng = $point[1];
                $late5 = floor($lat * 1e5);
                $lnge5 = floor($lng * 1e5);
                $dlat = $late5 - $plat;
                $dlng = $lnge5 - $plng;
                $plat = $late5;
                $plng = $lnge5;
                $encoded_points .= $this->encodeSignedNumber($dlat) . $this->encodeSignedNumber($dlng);
            }
        }
        return $encoded_points;
    }
81450
private function encodeMulticall(array $requests) {

        $composed_requests = [];

    	$this->logger->debug("Performing an XML multicall");

    	$this->logger->debug("Data dump before encoding", $requests);

        foreach ($requests as $request) {

            $composed_requests[] = [
                $request->getMethod(),
                $request->getParameters()
            ];

            foreach ( $request->getSpecialTypes() as $key => $value ) {
                $this->encoder->setValueType($key, $value);
            }

        }

        try {

            $encoded_requests = $this->encoder
                ->setEncoding($this->getEncoding())
                ->encodeMulticall($composed_requests);

        } catch (XmlrpcException $xe) {

            throw $xe;

        }

        $this->logger->debug("Data dump after encoding: ".$encoded_requests);

        return $encoded_requests;

    }
155753
public static function encodeCoordinates($coords)
    {
        static $encoder;

        if ($encoder == null) {
            $encoder = new self();
        }

        $points = [];
        foreach ($coords as $coord) {
            $points[] = explode(',', $coord);
        }

        return "enc:{$encoder->encode($points)}";
    }
165495
public function notEnoughPointToUse(...$points)
    {
        $currentPoint = $this->currentPoint();
        /**
         * 檢查是不是有足夠的點數可以用
         *
         * 如果傳入值是 int，只需要比對總數是否足夠
         *
         * 如果傳入陣列，則需每個比對是否足夠，如果不夠，回應差多少
         */
        if (is_int($points[0]))
            return $currentPoint < $points[0];

        $currentPoint = $this->getCanUsePoints();
        $points = array_shift($points);
        $notEnoughPoint = collect($points)->map(function ($point, $key) use ($currentPoint) {

            $pointType = $currentPoint->where('name', $key)->first();

            //如果使用者沒有擁有這個點數
            if (is_null($pointType))
                return false;
//                return 0 - $pointType;
            //如果使用者這這個點數項目不夠
            else if ($pointType->number < $point)
                return false;
            //返回扣除後剩下幾點
            else
                return $pointType->number - $point;
        })->values()->all();


        return in_array(false ,$notEnoughPoint ,true);
    }
220785
public static function encodePhp( array $data ) {
		$ret = '';
		foreach ( $data as $key => $value ) {
			if ( strcmp( $key, intval( $key ) ) === 0 ) {
				self::$logger->warning( "Ignoring unsupported integer key \"$key\"" );
				continue;
			}
			if ( strcspn( $key, '|!' ) !== strlen( $key ) ) {
				self::$logger->error( "Serialization failed: Key with unsupported characters \"$key\"" );
				return null;
			}
			$v = self::serializeValue( $value );
			if ( $v === null ) {
				return null;
			}
			$ret .= "$key|$v";
		}
		return $ret;
	}
1097756
protected static function _encodeSubIDs(\GMP ...$subids): string
    {
        $data = "";
        foreach ($subids as $subid) {
            // if number fits to one base 128 byte
            if ($subid < 128) {
                $data .= chr(intval($subid));
            } else { // encode to multiple bytes
                $bytes = [];
                do {
                    array_unshift($bytes, 0x7f & gmp_intval($subid));
                    $subid >>= 7;
                } while ($subid > 0);
                // all bytes except last must have bit 8 set to one
                foreach (array_splice($bytes, 0, -1) as $byte) {
                    $data .= chr(0x80 | $byte);
                }
                $data .= chr(reset($bytes));
            }
        }
        return $data;
    }
28492
public function encode(array $args)
    {
        if (!$args) {
            return $args;
        }

        $serializable = [];

        foreach ($args as $arg) {
            $serializable[] = $this->serialize($arg);
        }

        return $serializable;
    }
545646
private function encodeDict(array $data = null)
    {
        $data = is_null($data) ? $this->data : $data;
        ksort($data); // bencode spec requires dicts to be sorted alphabetically

        $dict = "";
        foreach ($data as $key => $value) {
            $dict .= $this->encodeString($key) . $this->doEncode($value);
        }

        return "d{$dict}e";
    }
264945
public static function encode($keys)
    {
        if (is_numeric($keys)) {
            $keys = (string) $keys;
        }

        if (is_string($keys)) {
            $keys = [$keys];
        }

        if (!is_array($keys)) {
            return [];
        }

        $encoded = [];
        foreach ($keys as $key) {
            if (is_array($key)) {
                // handle key modifiers
                $key = implode('', $key) . self::NULL; // the NULL clears the input state (eg. previous modifiers)
            }
            $encoded[] = (string) $key;
        }

        return $encoded;
    }
1318351
protected function encode(array $messages)
    {
        if ($this->encode) {
            foreach ($messages as $key => $message) {
                if (($form = mb_detect_encoding($message)) != self::TARGET_ENCODING) {
                    $messages[$key] = mb_convert_encoding($message, self::TARGET_ENCODING, $form);
                }
            }
        }

        return $messages;
    }
530052
public static function instance(array $schemas = []): EncoderInterface
    {
        $factory   = static::createFactory();
        $container = $factory->createSchemaContainer($schemas);
        $encoder   = $factory->createEncoder($container);

        return $encoder;
    }
356840
public function getDigits(array $decimals)
    {
        $digits = [];

        foreach ($decimals as $decimal) {
            $digits[] = $this->digits->getDigit($decimal);
        }

        return $digits;
    }
518177
public static function encodeArray($uris, $encodeMode = self::ENCODE_ARRAY_ALL, $dotMode = true, $uniqueMode = false)
    {
        $returnValue = [];

        if (is_array($uris)) {
            foreach ($uris as $key => $value) {
                if ($encodeMode == self::ENCODE_ARRAY_KEYS || $encodeMode == self::ENCODE_ARRAY_ALL) {
                    $key = self::encode($key, $dotMode);
                }
                if ($encodeMode == self::ENCODE_ARRAY_VALUES || $encodeMode == self::ENCODE_ARRAY_ALL) {
                    $value = self::encode($value, $dotMode);
                }
                $returnValue[$key] = $value;
            }
        }

        if ($uniqueMode) {
            $returnValue = array_unique($returnValue);
        }

        return $returnValue;
    }
229644
protected function encodeHeaders($headers = [])
    {
        $data = '';

        foreach ($headers as $name=>$values)
        {
            $temp = [];
            $data .= $name . ": ";
            $values = (array) $values;

            foreach ($values as $value)
            {
                $temp[] = $this->encodeHeader($value);
            }

            $data .= implode(", ", $temp);
            $data .= "\r\n";
        }

        return $data;
    }
1036591
private static String encodePath(int dist, IAtom a, IAtom b) {
        return dist + "_" + a.getSymbol() + "_" + b.getSymbol();
    }
535001
@Override
    public int encode ( byte[] dst, int dstIndex ) {
        int start = dstIndex;

        SMBUtil.writeInt2(this.hashAlgos != null ? this.hashAlgos.length : 0, dst, dstIndex);
        SMBUtil.writeInt2(this.salt != null ? this.salt.length : 0, dst, dstIndex + 2);
        dstIndex += 4;

        if ( this.hashAlgos != null ) {
            for ( int hashAlgo : this.hashAlgos ) {
                SMBUtil.writeInt2(hashAlgo, dst, dstIndex);
                dstIndex += 2;
            }
        }

        if ( this.salt != null ) {
            System.arraycopy(this.salt, 0, dst, dstIndex, this.salt.length);
            dstIndex += this.salt.length;
        }

        return dstIndex - start;
    }
201848
protected function validateMultiPointValue($points)
    {
        if ($points instanceof GeometryInterface) {
            $points = $points->toArray();
        }

        foreach ($points as &$point) {
            $point = $this->validatePointValue($point);
        }

        return $points;
    }