• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Location类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.luckycatlabs.sunrisesunset.dto.Location的典型用法代码示例。如果您正苦于以下问题:Java Location类的具体用法?Java Location怎么用?Java Location使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Location类属于com.luckycatlabs.sunrisesunset.dto包,在下文中一共展示了Location类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: makeTimeOfDay

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
public static TypeOfDay makeTimeOfDay(DateTime whenDT, double lat, double lon, TimeZoneGetter tzGetter, Logger lg) {
	Location location = new Location(lat, lon);
	
	Calendar when = whenDT.toCalendar(Locale.US);
	DateTimeZone dtz = tzGetter.getTimeZone(new LatLonPair(lat,lon));
	String tzid = dtz.getID();
	LocalTime tod = new LocalTime(whenDT);
	
	SunriseSunsetCalculator calculator = new SunriseSunsetCalculator(location, tzid);
	Calendar rise = calculator.getNauticalSunriseCalendarForDate(when);
	Calendar set = calculator.getNauticalSunsetCalendarForDate(when);
	DateTime riseDatetime = (new DateTime(rise.getTime())).withZone(dtz);
	LocalTime risedt =  new LocalTime(riseDatetime);
	DateTime setDatetime = (new DateTime(set.getTime())).withZone(dtz);
	LocalTime setdt =  new LocalTime(setDatetime);
	
	if(tod.isBefore(risedt.minusMinutes(30))) return TypeOfDay.NIGHTTIME;
	if(tod.isBefore(risedt.plusMinutes(90))) return TypeOfDay.MORNING;
	if(tod.isBefore(setdt.minusMinutes(90))) return TypeOfDay.DAYTIME;
	if(tod.isBefore(setdt.plusMinutes(30))) return TypeOfDay.EVENING;
	return TypeOfDay.NIGHTTIME;
}
 
开发者ID:windbender,项目名称:wildlife-camera-machine,代码行数:23,代码来源:HibernateDataStore.java


示例2: onUpdateData

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
@Override
protected void onUpdateData(int reason) {
    Log.d(TAG, "sunrise onUpdateData: " + sLocationCriteria.toString());
    LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    String provider = lm.getBestProvider(sLocationCriteria, true);
    if (TextUtils.isEmpty(provider)) {
        Log.d(TAG, "No available location providers matching criteria." + lm.getAllProviders());
        return;
    }

    final android.location.Location lastLocation = lm.getLastKnownLocation(provider);

    if (lastLocation == null ||
            (SystemClock.elapsedRealtimeNanos() - lastLocation.getElapsedRealtimeNanos())
                    >= STALE_LOCATION_NANOS) {
        Log.d(TAG, "Stale or missing last-known location; requesting single coarse location "
                + "update.");
        disableOneTimeLocationListener();
        mOneTimeLocationListenerActive = true;
        lm.requestSingleUpdate(provider, mOneTimeLocationListener, null);
    } else {
        publishUpdate(lastLocation);
    }

}
 
开发者ID:bashtian,项目名称:dashclock-sunrise,代码行数:26,代码来源:SunriseExtension.java


示例3: calculateNextAlert

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
/**
 * Calculate the time of the next alert after {@link cal}.
 * 
 * @param cal
 * @return
 */
public Calendar calculateNextAlert(Calendar cal,
        SunsetDefinition sunsetDefinition, int offsetInMinutes,
        String locationString) {
	String[] parts = locationString.split(",");
	Location location = new Location(parts[0], parts[1]);
	SunriseSunsetCalculator calculator = new SunriseSunsetCalculator(
	        location, cal.getTimeZone());
	Calendar alertTime = getSunsetCalendar(cal, sunsetDefinition,
	        calculator);
	alertTime.add(Calendar.MINUTE, offsetInMinutes);
	// advance a day if alert time has already passed for today
	if (!alertTime.after(cal)) {
		Calendar calCopy = Calendar.getInstance(cal.getTimeZone());
		calCopy.setTime(cal.getTime());
		calCopy.add(Calendar.DATE, 1);
		alertTime = getSunsetCalendar(calCopy, sunsetDefinition, calculator);
		alertTime.add(Calendar.MINUTE, offsetInMinutes);
	}
	return alertTime;
}
 
开发者ID:tomwhite,项目名称:chickenalerts,代码行数:27,代码来源:AlertTimeCalculator.java


示例4: createCalculator

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
private void createCalculator() throws ExecutionFailure {
    if (m_LatLong == null || m_LatLong.trim().length() == 0)
        throw new ExecutionFailure("Missing latitude and longitude");
    if (m_timeZoneIdentifier == null || m_timeZoneIdentifier.trim().length() == 0)
        throw new ExecutionFailure("Missing time zone identifier");

    String ll[] = m_LatLong.split(",");
    if (ll.length != 2)
        throw new ExecutionFailure("Illegal lat/long format, use 'long,lat'");

    ll[0] = ll[0].trim();
    ll[1] = ll[1].trim();

    // Location of sunrise/set, as latitude/longitude.
    Location location = new Location(ll[0], ll[1]);
    // Create m_calculator object with the location and time zone
    // identifier.
    m_calculator = new SunriseSunsetCalculator(location,
            m_timeZoneIdentifier);
}
 
开发者ID:stefangs,项目名称:NetHomeServer,代码行数:21,代码来源:FlexableAlarm.java


示例5: setup

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
public void setup(int month, int day, int year, String longitude, String latitude, String timeZoneIdentifier) {
    eventDate = Calendar.getInstance();
    eventDate.set(Calendar.YEAR, year);
    eventDate.set(Calendar.MONTH, month);
    eventDate.set(Calendar.DAY_OF_MONTH, day);
    eventDate.setTimeZone(TimeZone.getTimeZone(timeZoneIdentifier));
    location = new Location(longitude, latitude);
}
 
开发者ID:stefangs,项目名称:NetHomeServer,代码行数:9,代码来源:BaseTestCase.java


示例6: createLocation

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
private Location createLocation(String fileName) {
    String[] latlong = fileName.split("\\-");
    String latitude = latlong[0].replace('_', '.');
    String longitude = latlong[1].replace('_', '.');

    if (latitude.endsWith("S")) {
        latitude = "-" + latitude;
    }
    if (longitude.endsWith("W")) {
        longitude = "-" + longitude;
    }
    latitude = latitude.substring(0, latitude.length() - 1);
    longitude = longitude.substring(0, longitude.length() - 1);
    return new Location(latitude, longitude);
}
 
开发者ID:stefangs,项目名称:NetHomeServer,代码行数:16,代码来源:SunriseSunsetDataTest.java


示例7: isSunDown

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
public static boolean isSunDown(SharedPreferences settings)
{
	double latitude = settings.getFloat(PebbleNotificationCenter.LATITUDE, 0);
	double longitude = settings.getFloat(PebbleNotificationCenter.LONGITUDE, 0);


	Location location = new Location(latitude, longitude);
	SunriseSunsetCalculator sunriseSunsetCalculator = new SunriseSunsetCalculator(location, TimeZone.getDefault());

	boolean sunUp = TimeUtil.isBetweenTimes(Calendar.getInstance(),
			sunriseSunsetCalculator.getCivilSunriseCalendarForDate(Calendar.getInstance()),
			sunriseSunsetCalculator.getCivilSunsetCalendarForDate(Calendar.getInstance()));

	return !sunUp;
}
 
开发者ID:matejdro,项目名称:PebbleNotificationCenter-Android,代码行数:16,代码来源:SunriseSunsetCalculator.java


示例8: computeAndSaveTime

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
/**
 * Computes sunset and sunrise time and saves in the preference
 * @param context Ok where was the shrug emoji again?
 * @param onComputeCompleteListener OnComputeListener to invoke when compute is completed
 * @return Current instance
 */
public TwilightManager computeAndSaveTime(Context context, OnComputeCompleteListener onComputeCompleteListener) {
    Location mLocation = new Location(latitude, longitude);

    SunriseSunsetCalculator sunriseSunsetCalculator = new SunriseSunsetCalculator(mLocation, TimeZone.getDefault());
    Calendar calendar = Calendar.getInstance();

    String sunsetTime = sunriseSunsetCalculator.getOfficialSunsetForDate(calendar);
    String sunriseTime = sunriseSunsetCalculator.getOfficialSunriseForDate(calendar);

    PreferenceHelper.putString(context, Constants.PREF_START_TIME, sunsetTime);
    PreferenceHelper.putString(context, Constants.PREF_END_TIME, sunriseTime);

    AlarmUtils.setAlarms(context, sunsetTime, sunriseTime, false);

    if (onComputeCompleteListener != null) onComputeCompleteListener.onComputeComplete();;

    return this;
}
 
开发者ID:corphish,项目名称:NightLight,代码行数:25,代码来源:TwilightManager.java


示例9: onLocationChanged

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
@Override
public void onLocationChanged(android.location.Location location) {
    publishUpdate(location);
    disableOneTimeLocationListener();
}
 
开发者ID:bashtian,项目名称:dashclock-sunrise,代码行数:6,代码来源:SunriseExtension.java


示例10: SunriseSunsetCalculator

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
/**
 * Constructs a new <code>SunriseSunsetCalculator</code> with the given <code>Location</code>
 * 
 * @param location
 *            <code>Location</code> object containing the Latitude/Longitude of the location to compute
 *            the sunrise/sunset for.
 * @param timeZoneIdentifier
 *            String identifier for the timezone to compute the sunrise/sunset times in. In the form
 *            "America/New_York". Please see the zi directory under the JDK installation for supported
 *            time zones.
 */
public SunriseSunsetCalculator(Location location, String timeZoneIdentifier) {
    this.calculator = new SolarEventCalculator(location, timeZoneIdentifier);
}
 
开发者ID:stefangs,项目名称:NetHomeServer,代码行数:15,代码来源:SunriseSunsetCalculator.java


示例11: getSunrise

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
/**
 * Computes the sunrise for an arbitrary declination.
 * 
 * @param latitude
 * @param longitude
 *            Coordinates for the location to compute the sunrise/sunset for.
 * @param timeZone
 *            timezone to compute the sunrise/sunset times in.
 * @param date
 *            <code>Calendar</code> object containing the date to compute the official sunset for.
 * @param degrees
 *            Angle under the horizon for which to compute sunrise. For example, "civil sunrise"
 *            corresponds to 6 degrees.
 * @return the requested sunset time as a <code>Calendar</code> object.
 */

public static Calendar getSunrise(double latitude, double longitude, TimeZone timeZone, Calendar date, double degrees) {
    SolarEventCalculator solarEventCalculator = new SolarEventCalculator(new Location(latitude, longitude), timeZone);
    return solarEventCalculator.computeSunriseCalendar(new Zenith(90 - degrees), date);
}
 
开发者ID:stefangs,项目名称:NetHomeServer,代码行数:21,代码来源:SunriseSunsetCalculator.java


示例12: getSunset

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
/**
 * Computes the sunset for an arbitrary declination.
 * 
 * @param latitude
 * @param longitude
 *            Coordinates for the location to compute the sunrise/sunset for.
 * @param timeZone
 *            timezone to compute the sunrise/sunset times in.
 * @param date
 *            <code>Calendar</code> object containing the date to compute the official sunset for.
 * @param degrees
 *            Angle under the horizon for which to compute sunrise. For example, "civil sunset"
 *            corresponds to 6 degrees.
 * @return the requested sunset time as a <code>Calendar</code> object.
 */

public static Calendar getSunset(double latitude, double longitude, TimeZone timeZone, Calendar date, double degrees) {
    SolarEventCalculator solarEventCalculator = new SolarEventCalculator(new Location(latitude, longitude), timeZone);
    return solarEventCalculator.computeSunsetCalendar(new Zenith(90 - degrees), date);
}
 
开发者ID:stefangs,项目名称:NetHomeServer,代码行数:21,代码来源:SunriseSunsetCalculator.java


示例13: getLocation

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
/**
 * Returns the location where the sunrise/sunset is calculated for.
 * 
 * @return <code>Location</code> object representing the location of the computed sunrise/sunset.
 */
public Location getLocation() {
    return location;
}
 
开发者ID:stefangs,项目名称:NetHomeServer,代码行数:9,代码来源:SunriseSunsetCalculator.java


示例14: SolarEventCalculator

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
/**
 * Constructs a new <code>SolarEventCalculator</code> using the given parameters.
 * 
 * @param location
 *            <code>Location</code> of the place where the solar event should be calculated from.
 * @param timeZoneIdentifier
 *            time zone identifier of the timezone of the location parameter. For example,
 *            "America/New_York".
 */
public SolarEventCalculator(Location location, String timeZoneIdentifier) {
    this.location = location;
    this.timeZone = TimeZone.getTimeZone(timeZoneIdentifier);
}
 
开发者ID:stefangs,项目名称:NetHomeServer,代码行数:14,代码来源:SolarEventCalculator.java


示例15: SunriseSunsetCalculator

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
/**
 * Constructs a new <code>SunriseSunsetCalculator</code> with the given
 * <code>Location</code>
 * 
 * @param location
 *            <code>Location</code> object containing the Latitude/Longitude
 *            of the location to compute the sunrise/sunset for.
 * @param timeZoneIdentifier
 *            String identifier for the timezone to compute the
 *            sunrise/sunset times in. In the form "America/New_York".
 *            Please see the zi directory under the JDK installation for
 *            supported time zones.
 */
public SunriseSunsetCalculator(Location location, String timeZoneIdentifier) {
	this.calculator = new SolarEventCalculator(location, timeZoneIdentifier);
}
 
开发者ID:matejdro,项目名称:PebbleNotificationCenter-Android,代码行数:17,代码来源:SunriseSunsetCalculator.java


示例16: getSunrise

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
/**
 * Computes the sunrise for an arbitrary declination.
 * 
 * @param latitude
 * @param longitude
 *            Coordinates for the location to compute the sunrise/sunset
 *            for.
 * @param timeZone
 *            timezone to compute the sunrise/sunset times in.
 * @param date
 *            <code>Calendar</code> object containing the date to compute
 *            the official sunset for.
 * @param degrees
 *            Angle under the horizon for which to compute sunrise. For
 *            example, "civil sunrise" corresponds to 6 degrees.
 * @return the requested sunset time as a <code>Calendar</code> object.
 */

public static Calendar getSunrise(double latitude, double longitude, TimeZone timeZone, Calendar date, double degrees) {
	SolarEventCalculator solarEventCalculator = new SolarEventCalculator(new Location(latitude, longitude), timeZone);
	return solarEventCalculator.computeSunriseCalendar(new Zenith(90 - degrees), date);
}
 
开发者ID:matejdro,项目名称:PebbleNotificationCenter-Android,代码行数:23,代码来源:SunriseSunsetCalculator.java


示例17: getSunset

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
/**
 * Computes the sunset for an arbitrary declination.
 * 
 * @param latitude
 * @param longitude
 *            Coordinates for the location to compute the sunrise/sunset
 *            for.
 * @param timeZone
 *            timezone to compute the sunrise/sunset times in.
 * @param date
 *            <code>Calendar</code> object containing the date to compute
 *            the official sunset for.
 * @param degrees
 *            Angle under the horizon for which to compute sunrise. For
 *            example, "civil sunset" corresponds to 6 degrees.
 * @return the requested sunset time as a <code>Calendar</code> object.
 */

public static Calendar getSunset(double latitude, double longitude, TimeZone timeZone, Calendar date, double degrees) {
	SolarEventCalculator solarEventCalculator = new SolarEventCalculator(new Location(latitude, longitude), timeZone);
	return solarEventCalculator.computeSunsetCalendar(new Zenith(90 - degrees), date);
}
 
开发者ID:matejdro,项目名称:PebbleNotificationCenter-Android,代码行数:23,代码来源:SunriseSunsetCalculator.java


示例18: getLocation

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
/**
 * Returns the location where the sunrise/sunset is calculated for.
 * 
 * @return <code>Location</code> object representing the location of the
 *         computed sunrise/sunset.
 */
public Location getLocation() {
	return location;
}
 
开发者ID:matejdro,项目名称:PebbleNotificationCenter-Android,代码行数:10,代码来源:SunriseSunsetCalculator.java


示例19: SolarEventCalculator

import com.luckycatlabs.sunrisesunset.dto.Location; //导入依赖的package包/类
/**
 * Constructs a new <code>SolarEventCalculator</code> using the given
 * parameters.
 * 
 * @param location
 *            <code>Location</code> of the place where the solar event
 *            should be calculated from.
 * @param timeZoneIdentifier
 *            time zone identifier of the timezone of the location
 *            parameter. For example, "America/New_York".
 */
public SolarEventCalculator(Location location, String timeZoneIdentifier) {
	this.location = location;
	this.timeZone = TimeZone.getTimeZone(timeZoneIdentifier);
}
 
开发者ID:matejdro,项目名称:PebbleNotificationCenter-Android,代码行数:16,代码来源:SolarEventCalculator.java



注:本文中的com.luckycatlabs.sunrisesunset.dto.Location类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ComponentManager类代码示例发布时间:2022-05-22
下一篇:
Java Databinding类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap