@param PackedLayer $layerA
@param PackedLayer $layerB

@return int
181881
private function compare(PackedLayer $layerA, PackedLayer $layerB): int
    {
        return ($layerB->getFootprint() <=> $layerA->getFootprint()) ?: ($layerB->getDepth() <=> $layerA->getDepth());
    }
1045502
public function getOrdinal(string $slatJointName): int
  {
    $ordinal = 0;
    $key     = null;
    foreach ($this->slatJoints as $key => $slat_joint)
    {
      if ($key==$slatJointName) break;

      $ordinal += $slat_joint->getColSpan();
    }

    if ($key!=$slatJointName)
    {
      throw new LogicException("SlatJoint '%s' not found.", $slatJointName);
    }

    return $ordinal;
  }
199488
function(layersContext) {
        var layers = [];
        for (var i=0, len=layersContext.length; i<len; i++) {
            var layer = this.getLayerFromContext(layersContext[i]);
            if (layer !== null) {
                layers.push(layer);
            }
        }
        return layers;
    }
259084
function _getLayerJson(layer, callback) {
    var url = null;
    if(layer.layers !== undefined || ((layer.kind || layer.type) !== undefined)) {
      // layer object contains the layer data
      _.defer(function() { callback(layer); });
      return;
    } else if(layer.table !== undefined && layer.user !== undefined) {
      // layer object points to cartodbjson
      url = cartodbUrl(layer);
    } else if(layer.indexOf) {
      // fetch from url
      url = layer;
    }
    if(url) {
      cdb.core.Loader.get(url, callback);
    } else {
      _.defer(function() { callback(null); });
    }
  }
580427
protected function rotateLayersNinetyDegrees(): void
    {
        foreach ($this->layers as $i => $originalLayer) {
            $newLayer = new PackedLayer();
            foreach ($originalLayer->getItems() as $item) {
                $packedItem = new PackedItem($item->getItem(), $item->getY(), $item->getX(), $item->getZ(), $item->getLength(), $item->getWidth(), $item->getDepth());
                $newLayer->insert($packedItem);
            }
            $this->layers[$i] = $newLayer;
        }
    }
25268
private function addLayersToStack($layers, &$stack)
    {
        foreach ($layers as $layer) {
            if ($layer instanceof LayerGroup) {
                $this->addLayersToStack($layer->getLayers(), $stack);
            }

            $stack[] = $layer;
        }
    }
625617
public static function wkt($layerId, $url, $parserOptions = array(), Layer $customLayer = null)
    {
        return new Wkt($layerId, $url, $parserOptions, $customLayer);
    }
477084
public function getDepth(): int
    {
        $layerDepth = 0;

        foreach ($this->items as $item) {
            $layerDepth = max($layerDepth, $item->getZ() + $item->getDepth());
        }

        return $layerDepth - $this->getStartDepth();
    }
526645
public function getFootprint(): int
    {
        $layerWidth = 0;
        $layerLength = 0;

        foreach ($this->items as $item) {
            $layerWidth = max($layerWidth, $item->getX() + $item->getWidth());
            $layerLength = max($layerLength, $item->getY() + $item->getLength());
        }

        return $layerWidth * $layerLength;
    }
288325
def make_layer_stack(layers=gin.REQUIRED, num_layers=6):
  
  return LayerStack([cls() for cls in layers] * num_layers)
898483
public static function compareResourceRecords(ResourceRecord $a, ResourceRecord $b): int
    {
        if ($a->getType() === $b->getType()) {
            return strcmp($a->getName().$a->getRdata()->output(), $b->getName().$b->getRdata()->output());
        }

        $_a = array_search($a->getType(), self::$order);
        $_b = array_search($b->getType(), self::$order);

        if (false !== $_a && false !== $_b) {
            return $_a - $_b;
        }

        if (false === $_a) {
            return 1;
        }

        return -1;
    }
143240
public function getLayoutsCount(bool $includeDrafts, ?bool $shared = null): int
    {
        $query = $this->connection->createQueryBuilder();

        $query->select('count(DISTINCT l.id) AS count')
            ->from('ngbm_layout', 'l');

        if ($includeDrafts) {
            $query->leftJoin(
                'l',
                'ngbm_layout',
                'l2',
                $query->expr()->andX(
                    $query->expr()->eq('l.id', 'l2.id'),
                    $query->expr()->eq('l2.status', ':status')
                )
            );
        }

        if ($shared !== null) {
            $query->where(
                $query->expr()->eq('l.shared', ':shared')
            );
        }

        $statusExpr = $query->expr()->eq('l.status', ':status');
        if ($includeDrafts) {
            $statusExpr = $query->expr()->orX(
                $statusExpr,
                $query->expr()->isNull('l2.id')
            );
        }

        $query->andWhere($statusExpr);

        if ($shared !== null) {
            $query->setParameter('shared', $shared, Type::BOOLEAN);
        }

        $query->setParameter('status', Value::STATUS_PUBLISHED, Type::INTEGER);

        $data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);

        return (int) ($data[0]['count'] ?? 0);
    }
363484
public function collect(Map $map, array $geoJsonLayers = [])
    {
        return $this->collectValues($map->getLayerManager()->getGeoJsonLayers(), $geoJsonLayers);
    }
1196882
protected function getFileCount($resultsCount, $maxLinesInFile, $fileCounter)
    {
        $leftToInsert = $resultsCount - ($fileCounter * $maxLinesInFile);
        if ($leftToInsert <= $maxLinesInFile) {
            $count = $leftToInsert;
        } else {
            $count = $maxLinesInFile;
        }

        return $count;
    }
69099
public void write(Collection<? extends MapLayer> layers) throws IOException {
		if (this.progression != null) {
			this.progression.setProperties(0, 0, layers.size() + 1, false);
		}

		// Write the header
		if (!this.isHeaderWritten) {
			this.isHeaderWritten = true;
			writeHeader();
		}

		if (this.progression != null) {
			this.progression.increment();
		}

		final ObjectOutputStream oos = new ObjectOutputStream(this.tmpOutput);
		for (final MapLayer layer : layers) {
			oos.writeObject(layer);
			++this.length;
			if (this.progression != null) {
				this.progression.increment();
			}
		}
		if (this.progression != null) {
			this.progression.end();
		}
	}
1367040
function hasLayer( $layerID )
    {
        return ( in_array( $layerID, $this->ImageLayers ) and
                 array_key_exists( $layerID, $this->ImageLayerIndex ) );
    }
1108514
public function getMaxAllowedPacket(): int
  {
    if (!isset($this->maxAllowedPacket))
    {
      $query              = "show variables like 'max_allowed_packet'";
      $max_allowed_packet = $this->executeRow1($query);

      $this->maxAllowedPacket = $max_allowed_packet['Value'];

      // Note: When setting $chunkSize equal to $maxAllowedPacket it is not possible to transmit a LOB
      // with size $maxAllowedPacket bytes (but only $maxAllowedPacket - 8 bytes). But when setting the size of
      // $chunkSize less than $maxAllowedPacket than it is possible to transmit a LOB with size
      // $maxAllowedPacket bytes.
      $this->chunkSize = (int)min($this->maxAllowedPacket - 8, 1024 * 1024);
    }

    return (int)$this->maxAllowedPacket;
  }