Viktoriia 7 месяцев назад
Родитель
Сommit
5c12a13e0f

+ 1 - 12
Route.tsx

@@ -60,8 +60,7 @@ import TabBarButton from './src/components/TabBarButton';
 import { ParamListBase, RouteProp } from '@react-navigation/native';
 import setupDatabaseAndSync from 'src/database';
 import { MenuDrawer } from 'src/components';
-import { API_URL, setFastestMapHost } from 'src/constants';
-import { determineFastestServer } from 'src/utils/determineServer';
+import { API_URL } from 'src/constants';
 import {
   InfoScreen,
   PlanInfoScreen,
@@ -170,16 +169,6 @@ const Route = () => {
       await openDatabases();
       setDbLoaded(true);
       updateUnreadMessagesCount();
-      await findFastestServer();
-    };
-
-    const findFastestServer = async () => {
-      try {
-        const fastest = await determineFastestServer();
-        setFastestMapHost(fastest);
-      } catch (error) {
-        console.error('Error finding fastest server:', error);
-      }
     };
 
     prepareApp();

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
assets/geojson/nm2022.json


+ 3 - 3
src/components/MenuDrawer/index.tsx

@@ -18,7 +18,7 @@ import InfoIcon from 'assets/icons/info-solid.svg';
 import BellIcon from 'assets/icons/notifications/bell-solid.svg';
 import SharingIcon from 'assets/icons/location-sharing.svg';
 
-import { APP_VERSION, FASTEST_MAP_HOST } from 'src/constants';
+import { APP_VERSION } from 'src/constants';
 import { useNotification } from 'src/contexts/NotificationContext';
 import { useMessagesStore } from 'src/stores/unreadMessagesStore';
 import { SafeAreaView } from 'react-native-safe-area-context';
@@ -153,10 +153,10 @@ export const MenuDrawer = (props: any) => {
 
           <View style={{ gap: 6, marginTop: 16 }}>
             <Text style={styles.bottomText}>Version {APP_VERSION}</Text>
-            <Text style={styles.bottomText}>
+            {/* <Text style={styles.bottomText}>
               Map server:{'\n'}
               {FASTEST_MAP_HOST}
-            </Text>
+            </Text> */}
           </View>
         </View>
       </SafeAreaView>

+ 0 - 4
src/constants/secrets.ts

@@ -10,10 +10,6 @@ export const API_URL = `${API_HOST}/webapi`;
 
 export let FASTEST_MAP_HOST: string = MAP_HOST;
 
-export const setFastestMapHost = (server: string | null) => {
-  FASTEST_MAP_HOST = server ?? MAP_HOST;
-};
-
 export const APP_VERSION = Constants?.expoConfig?.version ?? Constants?.manifest?.version;
 
 export const GOOGLE_MAP_PLACES_APIKEY =

+ 0 - 20
src/screens/InAppScreens/MapScreen/ClusterItem/index.tsx

@@ -1,20 +0,0 @@
-import { View, Text } from 'react-native';
-import { Marker } from 'react-native-maps';
-import { styles } from './styles';
-
-const ClusterItem = ({ cluster }: { cluster: any }) => {
-  return (
-    <Marker
-      coordinate={{
-        latitude: cluster.geometry.coordinates[1] ?? 0,
-        longitude: cluster.geometry.coordinates[0] ?? 0
-      }}
-    >
-      <View style={styles.clusterContainer}>
-        <Text style={styles.text}>{cluster.properties.point_count}</Text>
-      </View>
-    </Marker>
-  );
-};
-
-export default ClusterItem;

+ 0 - 21
src/screens/InAppScreens/MapScreen/ClusterItem/styles.tsx

@@ -1,21 +0,0 @@
-import { StyleSheet } from 'react-native';
-import { Colors } from '../../../../theme';
-
-export const styles = StyleSheet.create({
-  clusterContainer: {
-    height: 28,
-    width: 28,
-    backgroundColor: Colors.TEXT_GRAY,
-    borderRadius: 14,
-    borderWidth: 2,
-    borderColor: Colors.WHITE,
-    alignItems: 'center',
-    justifyContent: 'center',
-  },
-  text: {
-    color: Colors.WHITE,
-    textAlign: 'center',
-    fontSize: 14,
-    fontWeight: '600',
-  },
-});

+ 0 - 54
src/screens/InAppScreens/MapScreen/CustomCallout/index.tsx

@@ -1,54 +0,0 @@
-import { View, Text } from 'react-native';
-import { Callout } from 'react-native-maps';
-
-import { styles } from '../MarkerItem/styles';
-import { ItemSeries } from '../../../../types/map';
-import { Colors } from 'src/theme';
-
-import CheckSvg from 'assets/icons/mark.svg';
-
-const CustomCallout = ({
-  marker,
-  toggleSeries,
-  seriesName,
-  token
-}: {
-  marker: ItemSeries;
-  toggleSeries: (item: any) => void;
-  seriesName: string;
-  token: string;
-}) => {
-  return (
-    <Callout style={styles.customCallout} onPress={() => toggleSeries(marker)}>
-      <View style={[styles.calloutContainer, { flex: 1 }]}>
-        <View style={[styles.calloutTextContainer, { marginTop: 0 }]}>
-          <Text style={styles.seriesName}>{seriesName}</Text>
-          <Text style={styles.markerName}>{marker.name}</Text>
-        </View>
-        <View
-          style={[
-            styles.calloutButton,
-            (marker.visited === 1 &&
-              token && {
-                backgroundColor: Colors.WHITE,
-                borderWidth: 1,
-                borderColor: Colors.BORDER_LIGHT
-              }) ||
-              {}
-          ]}
-        >
-          {marker.visited === 1 && token ? (
-            <View style={styles.completedContainer}>
-              <CheckSvg width={14} height={14} fill={Colors.DARK_BLUE} />
-              <Text style={[styles.calloutButtonText, { color: Colors.DARK_BLUE }]}>Completed</Text>
-            </View>
-          ) : (
-            <Text style={styles.calloutButtonText}>Mark Completed</Text>
-          )}
-        </View>
-      </View>
-    </Callout>
-  );
-};
-
-export default CustomCallout;

+ 0 - 11
src/screens/InAppScreens/TravelsScreen/utils/calculateRegion.ts

@@ -1,11 +0,0 @@
-import * as turf from '@turf/turf';
-
-export const calculateMapRegion = (bounds: turf.BBox) => {
-  const padding = 10;
-  return {
-    latitude: (bounds[1] + bounds[3]) / 2,
-    longitude: (bounds[0] + bounds[2]) / 2,
-    latitudeDelta: Math.abs(bounds[3] - bounds[1]) + padding,
-    longitudeDelta: Math.abs(bounds[2] - bounds[0]) + padding
-  };
-};

+ 0 - 58
src/utils/determineServer.ts

@@ -1,58 +0,0 @@
-import axios from 'axios';
-import { Platform } from 'react-native';
-import { API_URL, APP_VERSION } from 'src/constants';
-import { API } from 'src/types';
-
-const SERVER_LIST_URL = API_URL + '/' + API.GET_SERVERS;
-const TIMEOUT = 1500;
-
-const fetchWithTimeout = (url: string, timeout = TIMEOUT) => {
-  return axios.get(url, { timeout, headers: {'Cache-Control': 'no-cache'} });
-};
-
-const testServerSpeed = async (serverUrl: string) => {
-  const startTime = Date.now();
-  try {
-    await fetchWithTimeout(serverUrl);
-    const endTime = Date.now();
-    return endTime - startTime;
-  } catch (error) {
-    console.error(`Error fetching ${serverUrl}:`, error);
-    return TIMEOUT;
-  }
-};
-
-export const determineFastestServer = async () => {
-  try {
-    const response = await axios.get(SERVER_LIST_URL, {
-      headers: {
-        'App-Version': APP_VERSION,
-        'Platform': Platform.OS
-      }
-    });
-    const servers = response.data?.maps;
-
-    const speedTests = await Promise.allSettled(
-      servers?.map((server: string) => testServerSpeed(server + '/tiles_osm/2/2/2'))
-    );
-
-    let fastestServer = null;
-    let fastestTime = TIMEOUT;
-
-    speedTests.forEach((result, index) => {
-      if (result.status === 'fulfilled' && result.value < fastestTime) {
-        fastestTime = result.value;
-        fastestServer = servers[index];
-      }
-    });
-
-    if (fastestServer) {
-      return fastestServer;
-    } else {
-      return null;
-    }
-  } catch (error) {
-    console.error('Error determining fastest server:', error);
-    throw error;
-  }
-};

+ 0 - 130
src/utils/mapHelpers.ts

@@ -1,130 +0,0 @@
-import * as turf from '@turf/turf';
-import { Feature } from '@turf/turf';
-import { ItemSeries, RegionData } from '../types/map';
-
-export const findRegionInDataset = (dataset: RegionData, point: turf.helpers.Position | turf.helpers.Point | turf.helpers.Feature<turf.helpers.Point, turf.helpers.Properties>): Feature | undefined => {
-  return dataset.features.find((region: any) => {
-    const coordinates = region?.geometry?.coordinates;
-    const type = region?.geometry?.type;
-
-    if (!Array.isArray(coordinates) || coordinates.length === 0) {
-      return false;
-    }
-
-    try {
-      const polygon: any = type === 'Polygon'
-        ? turf.polygon(coordinates)
-        : turf.multiPolygon(coordinates);
-
-      return turf.booleanPointInPolygon(point, polygon);
-    } catch (error) {
-      console.error('Error creating polygon:', error);
-      return false;
-    }
-  });
-};
-
-export const calculateMapRegion = (bounds: turf.BBox): any => {
-  const padding = 1;
-  return {
-    latitude: (bounds[1] + bounds[3]) / 2,
-    longitude: (bounds[0] + bounds[2]) / 2,
-    latitudeDelta: Math.abs(bounds[3] - bounds[1]) + padding,
-    longitudeDelta: Math.abs(bounds[2] - bounds[0]) + padding,
-  };
-};
-
-export const calculateMapCountry = (bbox: turf.BBox, center: number[]): any => {
-  const padding = 1;
-  let latitude = center[1];
-  let longitude = center[0];
-  const [minLng, minLat, maxLng, maxLat] = bbox;
-
-  if (
-    minLat === undefined ||
-    minLng === undefined ||
-    maxLat === undefined ||
-    maxLng === undefined
-  ) {
-    console.error("Invalid bbox coordinates");
-  }
-
-  let latitudeDelta = Math.abs(maxLat - minLat) + padding;
-  let longitudeDelta = Math.abs(maxLng - minLng) + padding;
-
-  if (latitudeDelta < 0 || latitudeDelta > 180) {
-    latitudeDelta = Math.min(Math.max(latitudeDelta, 0), 180);
-  }
-
-  if (longitudeDelta < 0 || longitudeDelta > 360) {
-    longitudeDelta = Math.min(Math.max(longitudeDelta, 0), 360);
-  }
-
-  const validLatitude = Math.min(Math.max(latitude, -90), 90);
-  const validLongitude = Math.min(Math.max(longitude, -180), 180);
-
-  return {
-    latitude: validLatitude,
-    longitude: validLongitude,
-    latitudeDelta,
-    longitudeDelta,
-  };
-};
-
-const isBBoxOverlap = (bbox1: number[], bbox2: number[]) => {
-  return bbox1[0] <= bbox2[2] &&
-         bbox1[2] >= bbox2[0] &&
-         bbox1[1] <= bbox2[3] &&
-         bbox1[3] >= bbox2[1];
-};
-
-export const filterCandidates = (candidates: { features?: any; }, areaPolygon: turf.BBox) => {
-  const visibleAreaPolygon = turf.bboxPolygon(areaPolygon);
-
-  const candidateRegions = candidates.features.filter((feature: any) => {
-    const featureBBox = turf.bbox(feature);
-    return isBBoxOverlap(featureBBox, areaPolygon);
-  });
-
-  return candidateRegions.filter((feature: turf.helpers.Geometry | turf.helpers.Feature<any, turf.helpers.Properties>) => {
-    return turf.booleanIntersects(feature, visibleAreaPolygon) || 
-    turf.booleanOverlap(feature, visibleAreaPolygon);
-  });
-};
-
-export const processMarkerData = (marker: ItemSeries) => {
-  let coordinates = null;
-  if (marker.pointJSON) {
-    coordinates = JSON.parse(marker.pointJSON);
-  }
-  else if (marker.polygonJSON) {
-    const polygon = JSON.parse(marker.polygonJSON);
-    const polygonFeature = turf.polygon(polygon);
-    const center = turf.center(polygonFeature);
-    coordinates = center.geometry.coordinates;
-  }
-  return {
-    ...marker,
-    pointJSON: coordinates ?? null,
-  };
-};
-
-export const filterCandidatesMarkers = (candidatesMarkers: any[], visibleAreaPolygon: turf.helpers.Geometry | turf.helpers.Feature<any, turf.helpers.Properties>) => (
-  candidatesMarkers.filter((marker: { pointJSON: string; polygonJSON: string; }) => {
-    if (marker.pointJSON) {
-      const coordinates = JSON.parse(marker.pointJSON);
-      const point = turf.point([coordinates[1], coordinates[0]]);
-      return turf.booleanPointInPolygon(point, visibleAreaPolygon);
-    }
-    
-    else if (marker.polygonJSON) {
-      const polygonCoords = JSON.parse(marker.polygonJSON);
-      const polygon = turf.polygon(polygonCoords);
-      return turf.booleanOverlap(polygon, visibleAreaPolygon) || 
-            turf.booleanContains(visibleAreaPolygon, polygon) ||
-            turf.booleanWithin(polygon, visibleAreaPolygon);
-    }
-    
-    return false;
-  }
-));

Некоторые файлы не были показаны из-за большого количества измененных файлов