示例#1
0
/* **************************************************************** */
PointLla pointUtmToPointLla(PointUtm pointUtm)
{
	PointLla pointLla = pointLlaCreate();
	
	utminv(pointUtm->xMeters, pointUtm->yMeters, &pointLla->longitudeRadians, &pointLla->latitudeRadians);
	
	return pointLla;
}
示例#2
0
int vehicleSimStartup(void)
{
    FILE * propertyFile = NULL;
    char *property = NULL;
    pthread_attr_t attr;	// Thread attributed for the component threads spawned in this function
    char fileName[128] = {0};

    // Create vehiclePosLla object
    vehiclePosLla = pointLlaCreate();
    if(!vehiclePosLla)
    {
        //cError("vehicleSim: Could not create vehicleSimThread\n");
        vehicleSimShutdown();
        return VEHICLE_SIM_MALLOC_ERROR;
    }

    sprintf(fileName, "%svehicleSim.conf", CONFIG_DIRECTORY);
    propertyFile = fopen(fileName, "r");
    if(propertyFile)
    {
        vehicleSimProperties = propertiesCreate();
        vehicleSimProperties = propertiesLoad(vehicleSimProperties, propertyFile);
        fclose(propertyFile);
    }
    else
    {
        //cError("vehicleSim: Cannot find or open properties file\n");
        return VEHICLE_SIM_LOAD_CONFIGURATION_ERROR;
    }

    property = propertiesGetProperty(vehicleSimProperties, "INITIAL_LAT_DEGREES");
    if(property)
    {
        vehiclePosLla->latitudeRadians = atof( property );
        //cDebug(3, "vehicleSim: Property loaded INITIAL_LAT_DEGREES: %lf\n", vehiclePosLla->latitudeRadians);
        vehiclePosLla->latitudeRadians *= RAD_PER_DEG;
    }
    else
    {
        //cDebug(3, "vehicleSim: Property INITIAL_LAT_DEGREES not found, using default value: %lf\n", vehiclePosLla->latitudeRadians);
    }

    property = propertiesGetProperty(vehicleSimProperties, "INITIAL_LON_DEGREES");
    if(property)
    {
        vehiclePosLla->longitudeRadians = atof( property );
        //cDebug(3, "vehicleSim: Property loaded INITIAL_LON_DEGREES: %lf\n", vehiclePosLla->longitudeRadians);
        vehiclePosLla->longitudeRadians *= RAD_PER_DEG;
    }
    else
    {
        //cDebug(3, "vehicleSim: Property INITIAL_LON_DEGREES not found, using default value: %lf\n", vehiclePosLla->longitudeRadians);
    }

    property = propertiesGetProperty(vehicleSimProperties, "INITIAL_HEADING_DEGREES");
    if(property)
    {
        vehicleH = atof( property );
        //cDebug(3, "vehicleSim: Property loaded INITIAL_HEADING_DEGREES: %lf\n", vehicleH);
    }
    else
    {
        //cDebug(3, "vehicleSim: Property INITIAL_HEADING_DEGREES not found, using default value: %lf\n", vehicleH);
    }

    pthread_attr_init(&attr);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);

    vehicleSimRun = TRUE;

    if(pthread_create(&vehicleSimThreadId, &attr, vehicleSimThread, NULL) != 0)
    {
        //cError("vehicleSim: Could not create vehicleSimThread\n");
        vehicleSimShutdown();
        pthread_attr_destroy(&attr);
        return VEHICLE_SIM_THREAD_CREATE_ERROR;
    }
    pthread_attr_destroy(&attr);

    return 0;
}