Package org.geoforge.mdldatecl

Source Code of org.geoforge.mdldatecl.GfrMdlDatSetTlosEclPlc

/*
*  Copyright (C) 2011-2014 GeoForge Project
*
*  This program is free software; you can redistribute it and/or
*  modify it under the terms of the GNU Lesser General Public License
*  as published by the Free Software Foundation; either version 2
*  of the License, or (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU Lesser General Public License for more details.
*
*  You should have received a copy of the GNU Lesser General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

package org.geoforge.mdldatecl;

import gov.nasa.worldwind.avlist.AVKey;
import gov.nasa.worldwind.geom.LatLon;
import gov.nasa.worldwind.poi.PointOfInterest;
import java.awt.geom.Point2D;
import org.geoforge.java.lang.system.StopWatch;
import org.geoforge.wrpbasprssynecl.GfrWrpBasTopSynEclPlcs;

/**
*
* @author bantchao
*/
public class GfrMdlDatSetTlosEclPlc extends GfrMdlDatSetTlosEclAbs
{
   static private GfrMdlDatSetTlosEclPlc _INSTANCE_ = null;

   static public GfrMdlDatSetTlosEclPlc getInstance()
   {
      if (GfrMdlDatSetTlosEclPlc._INSTANCE_ == null)
         GfrMdlDatSetTlosEclPlc._INSTANCE_ = new GfrMdlDatSetTlosEclPlc();

      return GfrMdlDatSetTlosEclPlc._INSTANCE_;
   }

   // end static
  
   @Override
    public String clone(String strIdSource) throws Exception
    {
        // write to DB
      String strIdTarget = GfrWrpBasTopSynEclPlcs.getInstance().clone(strIdSource);

      // notify observers
      super._cloneObject(strIdTarget, strIdSource);
     
      return strIdTarget;
    }
  
  
   @Override
   public void deleteObjectWithId(String strId) throws Exception
   {
      GfrWrpBasTopSynEclPlcs.getInstance().deleteTlo(strId);
      super.deleteObjectWithId(strId);
   }

   @Override
   public void deleteAllObjectWithId() throws Exception
   {
      String[] strsId = GfrWrpBasTopSynEclPlcs.getInstance().getIdsTlo();

      GfrWrpBasTopSynEclPlcs.getInstance().deleteAllTlos();

      // notify observers
      super._deleteAll(strsId);
   }
  
   public String newObject(
           PointOfInterest poi)
           throws Exception
   {
       String strNameCandidate = (String) poi.getValue(AVKey.DISPLAY_NAME);
       strNameCandidate = GfrWrpBasTopSynEclPlcs.getInstance().generateUniqueNameCopy(strNameCandidate);
       LatLon lln = poi.getLatlon();
       Point2D.Double p2d = new Point2D.Double(lln.longitude.degrees, lln.latitude.degrees);

       String strId = GfrWrpBasTopSynEclPlcs.getInstance().save(
              strNameCandidate,
              (String) null, // strDescShort,
              (String) null, // strUrl,
              p2d);

      // notify observers
      super._newObject(strId);

      return strId;
   }

   // beg new
   public String newObject(
           String strName,
           String strDescShort,
           String strUrl,
           Point2D.Double p2d)
           throws Exception
   {

      String strId = GfrWrpBasTopSynEclPlcs.getInstance().save(
              strName,
              strDescShort,
              strUrl,
              p2d);

      // notify observers
      super._newObject(strId);

      return strId;
   }

   public String[] newObjects(
           String[] strsName,
           String[] strsDescShort,
           String[] strsUrl,
           Point2D.Double[] p2ds)
           throws Exception
   {
      StopWatch.start();
      String[] strsId = GfrWrpBasTopSynEclPlcs.getInstance().save(
              strsName,
              strsDescShort,
              strsUrl,
              p2ds);

      System.out.println(StopWatch.getTime("end write to DB"));
      StopWatch.start();
     
      //todo : optimize
      for (int i = 0; i < strsId.length; i++)
      {
         super._newObject(strsId[i]);
      }

      System.out.println(StopWatch.getTime("end send events"));


      return strsId;
   }

   // end new
   // beg private
   private GfrMdlDatSetTlosEclPlc()
   {
      super();
   }

}
TOP

Related Classes of org.geoforge.mdldatecl.GfrMdlDatSetTlosEclPlc

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.