public abstract class

TilesEntity

extends java.lang.Object

 java.lang.Object

↳androidx.core.location.altitude.impl.db.TilesEntity

Gradle dependencies

compile group: 'androidx.core', name: 'core-location-altitude', version: '1.0.0-alpha02'

  • groupId: androidx.core
  • artifactId: core-location-altitude
  • version: 1.0.0-alpha02

Artifact androidx.core:core-location-altitude:1.0.0-alpha02 it located at Google repository (https://maven.google.com/)

Overview

Defines the entity type and its converters within the Tiles table.

Summary

Constructors
publicTilesEntity()

Methods
public static byte[]fromTile(S2TileProto tile)

Encodes a S2TileProto.

public abstract S2TilePrototile()

Returns a tile within an S2 cell ID to unit interval map.

public abstract java.lang.Stringtoken()

Returns an identifier for a tile within an S2 cell ID to unit interval map.

public static S2TilePrototoTile(byte[] byteArray[])

Decodes a S2TileProto.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public TilesEntity()

Methods

public static byte[] fromTile(S2TileProto tile)

Encodes a S2TileProto.

public static S2TileProto toTile(byte[] byteArray[])

Decodes a S2TileProto.

public abstract java.lang.String token()

Returns an identifier for a tile within an S2 cell ID to unit interval map.

public abstract S2TileProto tile()

Returns a tile within an S2 cell ID to unit interval map.

Source

/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.core.location.altitude.impl.db;

import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.location.altitude.impl.proto.InvalidProtocolBufferException;
import androidx.core.location.altitude.impl.proto.S2TileProto;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
import androidx.room.TypeConverter;

import com.google.auto.value.AutoValue;
import com.google.auto.value.AutoValue.CopyAnnotations;

/** Defines the entity type and its converters within the Tiles table. */
@AutoValue
@Entity(tableName = "Tiles")
public abstract class TilesEntity {

    private static final String TAG = "MapParamsEntity";

    static TilesEntity create(String token, S2TileProto tile) {
        return new AutoValue_TilesEntity(token, tile);
    }

    /** Encodes a {@link S2TileProto}. */
    @NonNull
    @TypeConverter
    public static byte[] fromTile(@NonNull S2TileProto tile) {
        return tile.toByteArray();
    }

    /** Decodes a {@link S2TileProto}. */
    @Nullable
    @TypeConverter
    public static S2TileProto toTile(@NonNull byte[] byteArray) {
        try {
            return S2TileProto.parseFrom(byteArray);
        } catch (InvalidProtocolBufferException e) {
            Log.e(TAG, "Unable to parse tile.");
            return null;
        }
    }

    /** Returns an identifier for a tile within an S2 cell ID to unit interval map. */
    @CopyAnnotations
    @PrimaryKey
    @ColumnInfo(name = "token")
    @NonNull
    public abstract String token();

    /** Returns a tile within an S2 cell ID to unit interval map. */
    @CopyAnnotations
    @ColumnInfo(name = "tile")
    @NonNull
    public abstract S2TileProto tile();
}