<commit_before>package gov.nasa.jpl.hi.marsimages.ui;

import android.app.Activity;
import android.graphics.PointF;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.FrameLayout;

import com.mapbox.mapboxsdk.geometry.BoundingBox;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.overlay.Marker;
import com.mapbox.mapboxsdk.views.MapView;
import com.powellware.marsimages.R;

import org.apache.commons.csv.CSVRecord;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import gov.nasa.jpl.hi.marsimages.JsonReader;

import static gov.nasa.jpl.hi.marsimages.MarsImagesApp.MARS_IMAGES;

public class MapActivity extends Activity {

    public static final String INTENT_ACTION_MAP = "gov.nasa.jpl.hi.marsimages.MAP";
    private static final String MAP = "MissionMap";

    private String tileSet;
    private int minZoom;
    private int maxZoom;
    private int maxNativeZoom;
    private int defaultZoom;
    private double centerLat;
    private double centerLon;
    private double upperLeftLat;
    private double upperLeftLon;
    private double upperRightLat;
    private double upperRightLon;
    private double lowerLeftLat;
    private double lowerLeftLon;
    private int mapPixelWidth;
    private int mapPixelHeight;

    private int latestSiteIndex;
    private MapView mapView;
    private ArrayList<LatLng> points;
    private HashMap<Integer, int[]> rmcsForPoints;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);
        final FrameLayout frameLayout = (FrameLayout) findViewById(R.id.mapContainer);
        String missionName = MARS_IMAGES.getMissionName();
        new AsyncTask<String, Void, Void>() {
            @Override
            protected Void doInBackground(String... params) {
                String missionName = params[0];
                try {
                    String url = "http://merpublic.s3.amazonaws.com/maps/" + missionName + "Map.json";
                    JSONObject jsonObject = JsonReader.readJsonFromUrl(url);
                    parseMapMetadata(jsonObject);

                } catch (Exception e) {
                    Log.e(MAP, e.toString());
                }
                return null;
            }
            @Override
            protected void onPostExecute(Void aVoid) {
                BoundingBox bbox = new BoundingBox(
                        new LatLng(upperRightLat, upperRightLon), new LatLng(lowerLeftLat, lowerLeftLon));
                String tileURLPattern = tileSet+"/{z}/{x}/{y}.png";
                mapView = new MapView(MapActivity.this);
                MarsWebSourceTileLayer ws =
                        new MarsWebSourceTileLayer(tileURLPattern, bbox);
                ws.setName("Mission Map")
                        .setAttribution("NASA/JPL")
                        .setMinimumZoomLevel(minZoom)
                        .setMaximumZoomLevel(maxNativeZoom);
                mapView.setTileSource(ws);
                mapView.setCenter(new LatLng(centerLat, centerLon));
                mapView.setMinZoomLevel(minZoom);
                mapView.setMaxZoomLevel(maxZoom);
                mapView.setZoom(maxZoom-2);
                frameLayout.addView(mapView);

                new AsyncTask<Void, Void, Void>() {
                    @Override
                    protected Void doInBackground(Void... params) {
                        loadLatestTraversePath();
                        return null;
                    }

                    @Override
                    protected void onPostExecute(Void aVoid) {
                        mapView.getController().goTo(points.get(0), new PointF(0,0));

                        for (LatLng point : points) {<commit_msg>Setting maxzoom to only maxnativezoom for now until zooming in past native zoom level is well supported or workaround identified.<commit_after>package gov.nasa.jpl.hi.marsimages.ui;

import android.app.Activity;
import android.graphics.PointF;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.FrameLayout;

import com.mapbox.mapboxsdk.geometry.BoundingBox;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.overlay.Marker;
import com.mapbox.mapboxsdk.views.MapView;
import com.powellware.marsimages.R;

import org.apache.commons.csv.CSVRecord;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import gov.nasa.jpl.hi.marsimages.JsonReader;

import static gov.nasa.jpl.hi.marsimages.MarsImagesApp.MARS_IMAGES;

public class MapActivity extends Activity {

    public static final String INTENT_ACTION_MAP = "gov.nasa.jpl.hi.marsimages.MAP";
    private static final String MAP = "MissionMap";

    private String tileSet;
    private int minZoom;
    private int maxZoom;
    private int maxNativeZoom;
    private int defaultZoom;
    private double centerLat;
    private double centerLon;
    private double upperLeftLat;
    private double upperLeftLon;
    private double upperRightLat;
    private double upperRightLon;
    private double lowerLeftLat;
    private double lowerLeftLon;
    private int mapPixelWidth;
    private int mapPixelHeight;

    private int latestSiteIndex;
    private MapView mapView;
    private ArrayList<LatLng> points;
    private HashMap<Integer, int[]> rmcsForPoints;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);
        final FrameLayout frameLayout = (FrameLayout) findViewById(R.id.mapContainer);
        String missionName = MARS_IMAGES.getMissionName();
        new AsyncTask<String, Void, Void>() {
            @Override
            protected Void doInBackground(String... params) {
                String missionName = params[0];
                try {
                    String url = "http://merpublic.s3.amazonaws.com/maps/" + missionName + "Map.json";
                    JSONObject jsonObject = JsonReader.readJsonFromUrl(url);
                    parseMapMetadata(jsonObject);

                } catch (Exception e) {
                    Log.e(MAP, e.toString());
                }
                return null;
            }
            @Override
            protected void onPostExecute(Void aVoid) {
                BoundingBox bbox = new BoundingBox(
                        new LatLng(upperRightLat, upperRightLon), new LatLng(lowerLeftLat, lowerLeftLon));
                String tileURLPattern = tileSet+"/{z}/{x}/{y}.png";
                mapView = new MapView(MapActivity.this);
                MarsWebSourceTileLayer ws =
                        new MarsWebSourceTileLayer(tileURLPattern, bbox);
                ws.setName("Mission Map")
                        .setAttribution("NASA/JPL")
                        .setMinimumZoomLevel(minZoom)
                        .setMaximumZoomLevel(maxNativeZoom);
                mapView.setTileSource(ws);
                mapView.setCenter(new LatLng(centerLat, centerLon));
                mapView.setMinZoomLevel(minZoom);
                mapView.setMaxZoomLevel(maxZoom);
                mapView.setZoom(maxNativeZoom);  //use maxNativeZoom < n <= maxZoom when it is supported
                frameLayout.addView(mapView);

                new AsyncTask<Void, Void, Void>() {
                    @Override
                    protected Void doInBackground(Void... params) {
                        loadLatestTraversePath();
                        return null;
                    }

                    @Override
                    protected void onPostExecute(Void aVoid) {
                        mapView.getController().goTo(points.get(0), new PointF(0,0));

                        for (LatLng point : points) {
{'fraction_non_alphanumeric': 0.0847331093691676, 'fraction_numerical': 0.0013686699017046162, 'mean_word_length': 2.2139144342263095, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '262576', 'n_tokens_mistral': 2247, 'n_tokens_neox': 2135, 'n_words': 475}